From 3d16ab7d18a09ff96c875a0800e840922ee63867 Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Tue, 17 Dec 2024 09:21:18 +0100 Subject: [PATCH] Refactor deploment, overrading functions to keep compatibility with tests and legacy systems --- .../scripts/deploy/Deploy.s.sol | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol index 54e1fcb822556..5da435ff62d3d 100644 --- a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol @@ -286,6 +286,16 @@ contract Deploy is Deployer { _run(); } + /// @notice Deploy all of the L1 contracts necessary for a full Superchain with a single Op Chain. + /// The two parameters correspond to: + /// 1. Whether or not the Superchain contracts need to be deployed. Set to deploy a new Superchain contracts + /// 2. Whether or not the fault games need to be initialized. Set to false, and execute latter `setupFaultGames()` to initialize + /// when the config `faultGameGenesisOutputRoot` is known + function runCelo() public { + console.log("Deploying a fresh OP Stack including SuperchainConfig"); + _run(true, false); + } + /// @notice Deploy a new OP Chain using an existing SuperchainConfig and ProtocolVersions /// @param _superchainConfigProxy Address of the existing SuperchainConfig proxy /// @param _protocolVersionsProxy Address of the existing ProtocolVersions proxy @@ -332,11 +342,18 @@ contract Deploy is Deployer { /// @notice Compatibility function for tests that override _run(). function _run() internal virtual { - _run(true); + _run(true, true); + } + + /// @notice (Celo) Compatibility function for OP stack + function _run(bool _needsSuperchain) internal virtual { + _run(_needsSuperchain, true); } /// @notice Internal function containing the deploy logic. - function _run(bool _needsSuperchain) internal { + /// @param _needsSuperchain Whether or not the Superchain contracts need to be deployed. + /// @param _initializeFaultGames Whether or not the fault games need to be initialized. + function _run(bool _needsSuperchain, bool _initializeFaultGames) internal { console.log("start of L1 Deploy!"); deploySafe("SystemOwnerSafe"); console.log("deployed Safe!"); @@ -358,7 +375,7 @@ contract Deploy is Deployer { setupOpAltDA(); } } - setupOpChain(); + setupOpChain(_initializeFaultGames); console.log("set up op chain!"); } @@ -392,7 +409,7 @@ contract Deploy is Deployer { } /// @notice Deploy a new OP Chain, with an existing SuperchainConfig provided - function setupOpChain() public { + function setupOpChain(bool _initializeFaultGames) public { console.log("Deploying OP Chain"); // Ensure that the requisite contracts are deployed @@ -403,17 +420,24 @@ contract Deploy is Deployer { deployProxies(); deployImplementations(); - initializeImplementations(); + initializeImplementations(_initializeFaultGames); + + if (_initializeFaultGames) { + setAlphabetFaultGameImplementation({ _allowUpgrade: false }); + setFastFaultGameImplementation({ _allowUpgrade: false }); + setCannonFaultGameImplementation({ _allowUpgrade: false }); + setPermissionedCannonFaultGameImplementation({ _allowUpgrade: false }); + transferDisputeGameFactoryOwnership(); + } transferDelayedWETHOwnership(); } + /// @notice Deploy the fault games and set the implementations. Initialize AnchorStateRegistry. function setupFaultGames() public { setCannonFaultGameImplementation({ _allowUpgrade: false }); setPermissionedCannonFaultGameImplementation({ _allowUpgrade: false }); - initializeAnchorStateRegistry(); - transferDisputeGameFactoryOwnership(); } @@ -487,7 +511,7 @@ contract Deploy is Deployer { } /// @notice Initialize all of the implementations - function initializeImplementations() public { + function initializeImplementations(bool _initializeAnchorStateRegistry) public { console.log("Initializing implementations"); if (cfg.useCustomGasToken()) { @@ -514,7 +538,9 @@ contract Deploy is Deployer { initializeDisputeGameFactory(); initializeDelayedWETH(); initializePermissionedDelayedWETH(); - // initializeAnchorStateRegistry(); + if (_initializeAnchorStateRegistry) { + initializeAnchorStateRegistry(); + } ChainAssertions.checkCustomGasTokenOptimismPortal({ _contracts: _proxies(), _cfg: cfg, _isProxy: true }); }