From 7477592232755e2eb52b35841aa9a1b3ea5185d3 Mon Sep 17 00:00:00 2001 From: Maurelian Date: Wed, 2 Oct 2024 17:41:05 -0400 Subject: [PATCH] feat: Add ChainAssertions for deploySuperchain contracts (#12271) * feat: Add ChainAssertions for deploySuperchain contracts * Update Deploy.s.sol Co-authored-by: Matt Solomon --------- Co-authored-by: Matt Solomon --- .../scripts/deploy/ChainAssertions.sol | 12 +++++++++--- .../scripts/deploy/Deploy.s.sol | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol b/packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol index af1b939014b0..9227dd9141b3 100644 --- a/packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol +++ b/packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol @@ -422,7 +422,8 @@ library ChainAssertions { function checkSuperchainConfig( Types.ContractSet memory _contracts, DeployConfig _cfg, - bool _isPaused + bool _isPaused, + bool _isProxy ) internal view @@ -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. diff --git a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol index 195ce9a8d4dc..4ef9eff43ab4 100644 --- a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol @@ -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