Skip to content

Commit

Permalink
Refactor deploment, overrading functions to keep compatibility with t…
Browse files Browse the repository at this point in the history
…ests and legacy systems
  • Loading branch information
jcortejoso committed Dec 17, 2024
1 parent 5528f13 commit 3d16ab7
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!");
Expand All @@ -358,7 +375,7 @@ contract Deploy is Deployer {
setupOpAltDA();
}
}
setupOpChain();
setupOpChain(_initializeFaultGames);
console.log("set up op chain!");
}

Expand Down Expand Up @@ -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
Expand All @@ -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();
}

Expand Down Expand Up @@ -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()) {
Expand All @@ -514,7 +538,9 @@ contract Deploy is Deployer {
initializeDisputeGameFactory();
initializeDelayedWETH();
initializePermissionedDelayedWETH();
// initializeAnchorStateRegistry();
if (_initializeAnchorStateRegistry) {
initializeAnchorStateRegistry();
}

ChainAssertions.checkCustomGasTokenOptimismPortal({ _contracts: _proxies(), _cfg: cfg, _isProxy: true });
}
Expand Down

0 comments on commit 3d16ab7

Please sign in to comment.