Skip to content

Commit

Permalink
feat: Add ChainAssertions for deploySuperchain contracts (#12271)
Browse files Browse the repository at this point in the history
* feat: Add ChainAssertions for deploySuperchain contracts

* Update Deploy.s.sol

Co-authored-by: Matt Solomon <[email protected]>

---------

Co-authored-by: Matt Solomon <[email protected]>
  • Loading branch information
2 people authored and protolambda committed Oct 7, 2024
1 parent a89ce48 commit e33901f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
12 changes: 9 additions & 3 deletions packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ library ChainAssertions {
function checkSuperchainConfig(
Types.ContractSet memory _contracts,
DeployConfig _cfg,
bool _isPaused
bool _isPaused,
bool _isProxy
)
internal
view
Expand All @@ -433,8 +434,13 @@ library ChainAssertions {
// Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(superchainConfig), _slot: 0, _offset: 0 });

require(superchainConfig.guardian() == _cfg.superchainConfigGuardian());
require(superchainConfig.paused() == _isPaused);
if (_isProxy) {
require(superchainConfig.guardian() == _cfg.superchainConfigGuardian());
require(superchainConfig.paused() == _isPaused);
} else {
require(superchainConfig.guardian() == address(0));
require(superchainConfig.paused() == false);
}
}

/// @dev Asserts that for a given contract the value of a storage slot at an offset is 1.
Expand Down
18 changes: 12 additions & 6 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,18 @@ contract Deploy is Deployer {
save("ProtocolVersionsProxy", address(dso.protocolVersionsProxy()));
save("ProtocolVersions", address(dso.protocolVersionsImpl()));

// Run chain assertions.
// Run assertions for ProtocolVersions and SuperchainConfig proxy contracts.
ChainAssertions.checkProtocolVersions({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true });
ChainAssertions.checkSuperchainConfig({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isPaused: false });
// TODO: Add assertions for SuperchainConfig and ProtocolVersions impl contracts.
// TODO: Add assertions for SuperchainProxyAdmin.
// First run assertions for the ProtocolVersions and SuperchainConfig proxy contracts.
Types.ContractSet memory contracts = _proxiesUnstrict();
ChainAssertions.checkProtocolVersions({ _contracts: contracts, _cfg: cfg, _isProxy: true });
ChainAssertions.checkSuperchainConfig({ _contracts: contracts, _cfg: cfg, _isProxy: true, _isPaused: false });

// Then replace the ProtocolVersions proxy with the implementation address and run assertions on it.
contracts.ProtocolVersions = mustGetAddress("ProtocolVersions");
ChainAssertions.checkProtocolVersions({ _contracts: contracts, _cfg: cfg, _isProxy: false });

// Finally replace the SuperchainConfig proxy with the implementation address and run assertions on it.
contracts.SuperchainConfig = mustGetAddress("SuperchainConfig");
ChainAssertions.checkSuperchainConfig({ _contracts: contracts, _cfg: cfg, _isPaused: false, _isProxy: false });
}

/// @notice Deploy all of the OP Chain specific contracts
Expand Down

0 comments on commit e33901f

Please sign in to comment.