Skip to content

Commit

Permalink
fix: Upgrade tests and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dgusakov committed Jan 10, 2025
1 parent 0966118 commit 73f281b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 8 deletions.
16 changes: 9 additions & 7 deletions script/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@ abstract contract DeployBase is Script {
_avgPerfLeewayBP: config.avgPerfLeewayBP
});

address gateSeal = _deployGateSeal();
address[] memory sealables = new address[](4);
sealables[0] = address(csm);
sealables[1] = address(accounting);
sealables[2] = address(oracle);
sealables[3] = address(verifier);
address gateSeal = _deployGateSeal(sealables);

csm.grantRole(csm.PAUSE_ROLE(), gateSeal);
oracle.grantRole(oracle.PAUSE_ROLE(), gateSeal);
Expand Down Expand Up @@ -356,15 +361,12 @@ abstract contract DeployBase is Script {
return address(proxy);
}

function _deployGateSeal() internal returns (address) {
function _deployGateSeal(
address[] memory sealables
) internal returns (address) {
IGateSealFactory gateSealFactory = IGateSealFactory(
config.gateSealFactory
);
address[] memory sealables = new address[](4);
sealables[0] = address(csm);
sealables[1] = address(accounting);
sealables[2] = address(oracle);
sealables[3] = address(verifier);

address committee = config.sealingCommittee == address(0)
? deployer
Expand Down
14 changes: 13 additions & 1 deletion script/DeployImplementationsBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,20 @@ abstract contract DeployImplementationsBase is DeployBase {
pivotSlot: Slot.wrap(
uint64(config.verifierSupportedEpoch * config.slotsPerEpoch)
),
admin: msg.sender
admin: deployer
});

address[] memory sealables = new address[](4);
sealables[0] = address(csm);
sealables[1] = address(accounting);
sealables[2] = address(oracle);
sealables[3] = address(verifier);
gateSeal = _deployGateSeal(sealables);

verifier.grantRole(verifier.PAUSE_ROLE(), address(gateSeal));
verifier.grantRole(csm.DEFAULT_ADMIN_ROLE(), config.aragonAgent);
verifier.revokeRole(csm.DEFAULT_ADMIN_ROLE(), deployer);

JsonObj memory deployJson = Json.newObj();
deployJson.set("CSModuleImpl", address(csmImpl));
deployJson.set("CSAccountingImpl", address(accountingImpl));
Expand All @@ -92,6 +103,7 @@ abstract contract DeployImplementationsBase is DeployBase {
deployJson.set("CSVerifier", address(verifier));
deployJson.set("CSEarlyAdoption", address(earlyAdoption));
deployJson.set("HashConsensus", address(hashConsensus));
deployJson.set("GateSeal", address(gateSeal));
deployJson.set("git-ref", gitRef);
vm.writeJson(
deployJson.str,
Expand Down
21 changes: 21 additions & 0 deletions script/fork-helpers/SimulateVote.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { DeploymentFixtures } from "test/helpers/Fixtures.sol";
import { IStakingRouter } from "../../src/interfaces/IStakingRouter.sol";
import { OssifiableProxy } from "../../src/lib/proxy/OssifiableProxy.sol";
import { CSModule } from "../../src/CSModule.sol";
import { CSAccounting } from "../../src/CSAccounting.sol";
import { CSFeeOracle } from "../../src/CSFeeOracle.sol";
import { IBurner } from "../../src/interfaces/IBurner.sol";
import { ForkHelpersCommon } from "./Common.sol";

Expand Down Expand Up @@ -100,10 +102,29 @@ contract SimulateVote is Script, DeploymentFixtures, ForkHelpersCommon {

address admin = _prepareAdmin(deploymentConfig.csm);
csm = CSModule(deploymentConfig.csm);
accounting = CSAccounting(deploymentConfig.accounting);
oracle = CSFeeOracle(deploymentConfig.oracle);

vm.startBroadcast(admin);
csm.revokeRole(csm.VERIFIER_ROLE(), address(deploymentConfig.verifier));
csm.grantRole(csm.VERIFIER_ROLE(), address(upgradeConfig.verifier));

csm.revokeRole(csm.PAUSE_ROLE(), address(deploymentConfig.gateSeal));
accounting.revokeRole(
accounting.PAUSE_ROLE(),
address(deploymentConfig.gateSeal)
);
oracle.revokeRole(
oracle.PAUSE_ROLE(),
address(deploymentConfig.gateSeal)
);

csm.grantRole(csm.PAUSE_ROLE(), address(upgradeConfig.gateSeal));
accounting.grantRole(
accounting.PAUSE_ROLE(),
address(upgradeConfig.gateSeal)
);
oracle.grantRole(oracle.PAUSE_ROLE(), address(upgradeConfig.gateSeal));
vm.stopBroadcast();
}
}
3 changes: 3 additions & 0 deletions test/helpers/Fixtures.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ contract DeploymentHelpers is Test {
address verifier;
address earlyAdoption;
address hashConsensus;
address gateSeal;
}

function envVars() public returns (Env memory) {
Expand Down Expand Up @@ -190,6 +191,7 @@ contract DeploymentHelpers is Test {
config,
".HashConsensus"
);
upgradeConfig.gateSeal = vm.parseJsonAddress(config, ".GateSeal");
}

function parseDeployParams(
Expand Down Expand Up @@ -251,6 +253,7 @@ contract DeploymentFixtures is StdCheats, DeploymentHelpers {
earlyAdoption = CSEarlyAdoption(upgradeConfig.earlyAdoption);
verifier = CSVerifier(upgradeConfig.verifier);
hashConsensus = HashConsensus(upgradeConfig.hashConsensus);
gateSeal = IGateSeal(upgradeConfig.gateSeal);
}
}

Expand Down

0 comments on commit 73f281b

Please sign in to comment.