Commit c8a9533c authored by Maurelian's avatar Maurelian Committed by GitHub

feat: Add ChainAssertions for deploySuperchain contracts (#12271)

* feat: Add ChainAssertions for deploySuperchain contracts

* Update Deploy.s.sol
Co-authored-by: default avatarMatt Solomon <matt@mattsolomon.dev>

---------
Co-authored-by: default avatarMatt Solomon <matt@mattsolomon.dev>
parent b1171864
...@@ -422,7 +422,8 @@ library ChainAssertions { ...@@ -422,7 +422,8 @@ library ChainAssertions {
function checkSuperchainConfig( function checkSuperchainConfig(
Types.ContractSet memory _contracts, Types.ContractSet memory _contracts,
DeployConfig _cfg, DeployConfig _cfg,
bool _isPaused bool _isPaused,
bool _isProxy
) )
internal internal
view view
...@@ -433,8 +434,13 @@ library ChainAssertions { ...@@ -433,8 +434,13 @@ library ChainAssertions {
// Check that the contract is initialized // Check that the contract is initialized
assertSlotValueIsOne({ _contractAddress: address(superchainConfig), _slot: 0, _offset: 0 }); assertSlotValueIsOne({ _contractAddress: address(superchainConfig), _slot: 0, _offset: 0 });
require(superchainConfig.guardian() == _cfg.superchainConfigGuardian()); if (_isProxy) {
require(superchainConfig.paused() == _isPaused); 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. /// @dev Asserts that for a given contract the value of a storage slot at an offset is 1.
......
...@@ -318,12 +318,18 @@ contract Deploy is Deployer { ...@@ -318,12 +318,18 @@ contract Deploy is Deployer {
save("ProtocolVersionsProxy", address(dso.protocolVersionsProxy())); save("ProtocolVersionsProxy", address(dso.protocolVersionsProxy()));
save("ProtocolVersions", address(dso.protocolVersionsImpl())); save("ProtocolVersions", address(dso.protocolVersionsImpl()));
// Run chain assertions. // First run assertions for the ProtocolVersions and SuperchainConfig proxy contracts.
// Run assertions for ProtocolVersions and SuperchainConfig proxy contracts. Types.ContractSet memory contracts = _proxiesUnstrict();
ChainAssertions.checkProtocolVersions({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true }); ChainAssertions.checkProtocolVersions({ _contracts: contracts, _cfg: cfg, _isProxy: true });
ChainAssertions.checkSuperchainConfig({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isPaused: false }); ChainAssertions.checkSuperchainConfig({ _contracts: contracts, _cfg: cfg, _isProxy: true, _isPaused: false });
// TODO: Add assertions for SuperchainConfig and ProtocolVersions impl contracts.
// TODO: Add assertions for SuperchainProxyAdmin. // 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 /// @notice Deploy all of the OP Chain specific contracts
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment