From 33bc0bec8012a9000565057f9b406384b05b8726 Mon Sep 17 00:00:00 2001 From: Maurelian Date: Wed, 2 Oct 2024 14:19:06 -0400 Subject: [PATCH] feat: Extract deployment of pre-v1.6.0 code (#12233) * feat: Add a test to simplify deploy script testing * fix: lint * feat: Add clarifying comments to DeployVariations_Test * feat: Extract deployment of pre-v1.6.0 code * feat: combine setupOPChain and DeployOpChain This will help to clarify where the DeployOpcChain script can be used. * fix: op-e2e issues with unfound contracts * fix: Undo conditional init of L2OutputOracle It needs to be in the state no matter what for op-e2e * fix: correct deploy ordering of legacy contracts * ugly but working * clean up legacy deployments * enable FP on system config custom gas token tests * op-e2e: allow no OptimismPortal impl if useFaultProofs * fix: lint --- op-chain-ops/genesis/config.go | 4 + .../scripts/deploy/Deploy.s.sol | 104 ++++++++---------- .../test/L1/SystemConfig.t.sol | 1 + 3 files changed, 49 insertions(+), 60 deletions(-) diff --git a/op-chain-ops/genesis/config.go b/op-chain-ops/genesis/config.go index 26f675b30e7f..40a26ecd5192 100644 --- a/op-chain-ops/genesis/config.go +++ b/op-chain-ops/genesis/config.go @@ -1017,6 +1017,10 @@ func (d *L1Deployments) Check(deployConfig *DeployConfig) error { name == "DisputeGameFactoryProxy") { continue } + if deployConfig.UseFaultProofs && + (name == "OptimismPortal") { + continue + } if !deployConfig.UseAltDA && (name == "DataAvailabilityChallenge" || name == "DataAvailabilityChallengeProxy") { diff --git a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol index b625bdc31d59..b7410ec1efed 100644 --- a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol @@ -144,26 +144,6 @@ contract Deploy is Deployer { return keccak256(bytes(Config.implSalt())); } - /// @notice Returns the proxy addresses. If a proxy is not found, it will have address(0). - function _proxies() internal view returns (Types.ContractSet memory proxies_) { - proxies_ = Types.ContractSet({ - L1CrossDomainMessenger: mustGetAddress("L1CrossDomainMessengerProxy"), - L1StandardBridge: mustGetAddress("L1StandardBridgeProxy"), - L2OutputOracle: mustGetAddress("L2OutputOracleProxy"), - DisputeGameFactory: mustGetAddress("DisputeGameFactoryProxy"), - DelayedWETH: mustGetAddress("DelayedWETHProxy"), - PermissionedDelayedWETH: mustGetAddress("PermissionedDelayedWETHProxy"), - AnchorStateRegistry: mustGetAddress("AnchorStateRegistryProxy"), - OptimismMintableERC20Factory: mustGetAddress("OptimismMintableERC20FactoryProxy"), - OptimismPortal: mustGetAddress("OptimismPortalProxy"), - OptimismPortal2: mustGetAddress("OptimismPortalProxy"), - SystemConfig: mustGetAddress("SystemConfigProxy"), - L1ERC721Bridge: mustGetAddress("L1ERC721BridgeProxy"), - ProtocolVersions: mustGetAddress("ProtocolVersionsProxy"), - SuperchainConfig: mustGetAddress("SuperchainConfigProxy") - }); - } - /// @notice Returns the proxy addresses, not reverting if any are unset. function _proxiesUnstrict() internal view returns (Types.ContractSet memory proxies_) { proxies_ = Types.ContractSet({ @@ -274,7 +254,23 @@ contract Deploy is Deployer { } else { deployImplementations(); } - setupOpChain(); + + // Deploy Current OPChain Contracts + deployOpChain(); + + // Deploy and setup the legacy (pre-faultproofs) contracts + deployERC1967Proxy("L2OutputOracleProxy"); + deployL2OutputOracle(); + initializeL2OutputOracle(); + + // The OptimismPortalProxy contract is used both with and without Fault Proofs enabled, and is deployed by + // deployOPChain. So we only need to deploy the legacy OptimismPortal implementation and initialize with it + // when Fault Proofs are disabled. + if (!cfg.useFaultProofs()) { + deployOptimismPortal(); + initializeOptimismPortal(); + } + if (cfg.useAltDA()) { bytes32 typeHash = keccak256(bytes(cfg.daCommitmentType())); bytes32 keccakHash = keccak256(bytes("KeccakCommitment")); @@ -318,33 +314,18 @@ contract Deploy is Deployer { save("ProtocolVersions", address(dso.protocolVersionsImpl())); } - /// @notice Deploy a new OP Chain, with an existing SuperchainConfig provided - function setupOpChain() public { + /// @notice Deploy all of the OP Chain specific contracts + function deployOpChain() public { console.log("Deploying OP Chain"); deployAddressManager(); deployProxyAdmin({ _isSuperchain: false }); + transferAddressManagerOwnership(); // to the ProxyAdmin // Ensure that the requisite contracts are deployed mustGetAddress("SuperchainConfigProxy"); mustGetAddress("AddressManager"); mustGetAddress("ProxyAdmin"); - deployOpChain(); - initializeOpChain(); - - setAlphabetFaultGameImplementation({ _allowUpgrade: false }); - setFastFaultGameImplementation({ _allowUpgrade: false }); - setCannonFaultGameImplementation({ _allowUpgrade: false }); - setPermissionedCannonFaultGameImplementation({ _allowUpgrade: false }); - - transferDisputeGameFactoryOwnership(); - transferDelayedWETHOwnership(); - } - - /// @notice Deploy all of the OP Chain specific contracts - function deployOpChain() public { - console.log("Deploying OP Chain contracts"); - deployERC1967Proxy("OptimismPortalProxy"); deployERC1967Proxy("SystemConfigProxy"); deployL1StandardBridgeProxy(); @@ -356,26 +337,32 @@ contract Deploy is Deployer { // enabled to prevent a nastier refactor to the deploy scripts. In the future, the L2OutputOracle will be // removed. If fault proofs are not enabled, the DisputeGameFactory proxy will be unused. deployERC1967Proxy("DisputeGameFactoryProxy"); - deployERC1967Proxy("L2OutputOracleProxy"); deployERC1967Proxy("DelayedWETHProxy"); deployERC1967Proxy("PermissionedDelayedWETHProxy"); deployERC1967Proxy("AnchorStateRegistryProxy"); deployAnchorStateRegistry(); - transferAddressManagerOwnership(); // to the ProxyAdmin + initializeOpChain(); + + setAlphabetFaultGameImplementation({ _allowUpgrade: false }); + setFastFaultGameImplementation({ _allowUpgrade: false }); + setCannonFaultGameImplementation({ _allowUpgrade: false }); + setPermissionedCannonFaultGameImplementation({ _allowUpgrade: false }); + + transferDisputeGameFactoryOwnership(); + transferDelayedWETHOwnership(); } /// @notice Deploy all of the implementations function deployImplementations() public { + // TODO: Replace the actions in this function with a call to DeployImplementationsInterop.run() console.log("Deploying implementations"); deployL1CrossDomainMessenger(); deployOptimismMintableERC20Factory(); deploySystemConfig(); deployL1StandardBridge(); deployL1ERC721Bridge(); - deployOptimismPortal(); // todo: pull this out into an override option after DeployImplementations runs - deployL2OutputOracle(); // Fault proofs deployOptimismPortal2(); @@ -387,13 +374,13 @@ contract Deploy is Deployer { /// @notice Deploy all of the implementations function deployImplementationsInterop() public { + // TODO: Replace the actions in this function with a call to DeployImplementationsInterop.run() console.log("Deploying implementations"); deployL1CrossDomainMessenger(); deployOptimismMintableERC20Factory(); deploySystemConfigInterop(); deployL1StandardBridge(); deployL1ERC721Bridge(); - deployL2OutputOracle(); // Fault proofs deployOptimismPortalInterop(); @@ -407,13 +394,11 @@ contract Deploy is Deployer { /// initialize function function initializeOpChain() public { console.log("Initializing Op Chain proxies"); - // Selectively initialize either the original OptimismPortal or the new OptimismPortal2. Since this will upgrade - // the proxy, we cannot initialize both. + // The OptimismPortal Proxy is shared between the legacy and current deployment path, so we should initialize + // the OptimismPortal2 only if using FaultProofs. if (cfg.useFaultProofs()) { console.log("Fault proofs enabled. Initializing the OptimismPortal proxy with the OptimismPortal2."); initializeOptimismPortal2(); - } else { - initializeOptimismPortal(); } initializeSystemConfig(); @@ -421,7 +406,6 @@ contract Deploy is Deployer { initializeL1ERC721Bridge(); initializeOptimismMintableERC20Factory(); initializeL1CrossDomainMessenger(); - initializeL2OutputOracle(); initializeDisputeGameFactory(); initializeDelayedWETH(); initializePermissionedDelayedWETH(); @@ -1108,7 +1092,7 @@ contract Deploy is Deployer { string memory version = config.version(); console.log("SystemConfig version: %s", version); - ChainAssertions.checkSystemConfig({ _contracts: _proxies(), _cfg: cfg, _isProxy: true }); + ChainAssertions.checkSystemConfig({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true }); } /// @notice Initialize the L1StandardBridge @@ -1143,7 +1127,7 @@ contract Deploy is Deployer { string memory version = IL1StandardBridge(payable(l1StandardBridgeProxy)).version(); console.log("L1StandardBridge version: %s", version); - ChainAssertions.checkL1StandardBridge({ _contracts: _proxies(), _isProxy: true }); + ChainAssertions.checkL1StandardBridge({ _contracts: _proxiesUnstrict(), _isProxy: true }); } /// @notice Initialize the L1ERC721Bridge @@ -1168,7 +1152,7 @@ contract Deploy is Deployer { string memory version = bridge.version(); console.log("L1ERC721Bridge version: %s", version); - ChainAssertions.checkL1ERC721Bridge({ _contracts: _proxies(), _isProxy: true }); + ChainAssertions.checkL1ERC721Bridge({ _contracts: _proxiesUnstrict(), _isProxy: true }); } /// @notice Initialize the OptimismMintableERC20Factory @@ -1189,7 +1173,7 @@ contract Deploy is Deployer { string memory version = factory.version(); console.log("OptimismMintableERC20Factory version: %s", version); - ChainAssertions.checkOptimismMintableERC20Factory({ _contracts: _proxies(), _isProxy: true }); + ChainAssertions.checkOptimismMintableERC20Factory({ _contracts: _proxiesUnstrict(), _isProxy: true }); } /// @notice initializeL1CrossDomainMessenger @@ -1235,7 +1219,7 @@ contract Deploy is Deployer { string memory version = messenger.version(); console.log("L1CrossDomainMessenger version: %s", version); - ChainAssertions.checkL1CrossDomainMessenger({ _contracts: _proxies(), _vm: vm, _isProxy: true }); + ChainAssertions.checkL1CrossDomainMessenger({ _contracts: _proxiesUnstrict(), _vm: vm, _isProxy: true }); } /// @notice Initialize the L2OutputOracle @@ -1267,7 +1251,7 @@ contract Deploy is Deployer { console.log("L2OutputOracle version: %s", version); ChainAssertions.checkL2OutputOracle({ - _contracts: _proxies(), + _contracts: _proxiesUnstrict(), _cfg: cfg, _l2OutputOracleStartingTimestamp: cfg.l2OutputOracleStartingTimestamp(), _isProxy: true @@ -1301,7 +1285,7 @@ contract Deploy is Deployer { string memory version = portal.version(); console.log("OptimismPortal version: %s", version); - ChainAssertions.checkOptimismPortal({ _contracts: _proxies(), _cfg: cfg, _isProxy: true }); + ChainAssertions.checkOptimismPortal({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true }); } /// @notice Initialize the OptimismPortal2 @@ -1332,7 +1316,7 @@ contract Deploy is Deployer { string memory version = portal.version(); console.log("OptimismPortal2 version: %s", version); - ChainAssertions.checkOptimismPortal2({ _contracts: _proxies(), _cfg: cfg, _isProxy: true }); + ChainAssertions.checkOptimismPortal2({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true }); } /// @notice Transfer ownership of the DisputeGameFactory contract to the final system owner @@ -1346,7 +1330,7 @@ contract Deploy is Deployer { disputeGameFactory.transferOwnership(finalSystemOwner); console.log("DisputeGameFactory ownership transferred to final system owner at: %s", finalSystemOwner); } - ChainAssertions.checkDisputeGameFactory({ _contracts: _proxies(), _expectedOwner: finalSystemOwner }); + ChainAssertions.checkDisputeGameFactory({ _contracts: _proxiesUnstrict(), _expectedOwner: finalSystemOwner }); } /// @notice Transfer ownership of the DelayedWETH contract to the final system owner @@ -1361,7 +1345,7 @@ contract Deploy is Deployer { console.log("DelayedWETH ownership transferred to final system owner at: %s", finalSystemOwner); } ChainAssertions.checkDelayedWETH({ - _contracts: _proxies(), + _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true, _expectedOwner: finalSystemOwner @@ -1380,7 +1364,7 @@ contract Deploy is Deployer { console.log("DelayedWETH ownership transferred to final system owner at: %s", finalSystemOwner); } ChainAssertions.checkPermissionedDelayedWETH({ - _contracts: _proxies(), + _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true, _expectedOwner: finalSystemOwner diff --git a/packages/contracts-bedrock/test/L1/SystemConfig.t.sol b/packages/contracts-bedrock/test/L1/SystemConfig.t.sol index 91819d8ef70a..aad093e3283a 100644 --- a/packages/contracts-bedrock/test/L1/SystemConfig.t.sol +++ b/packages/contracts-bedrock/test/L1/SystemConfig.t.sol @@ -312,6 +312,7 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init { function setUp() public override { token = new ERC20("Silly", "SIL"); super.enableCustomGasToken(address(token)); + super.enableFaultProofs(); super.setUp(); }