Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split FaultProof initialization to new function initializeAnchorStateRegistry() #286

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions op-e2e/celo/tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export async function setup() {
config.addresses = contractAddrs

const success = await Promise.all([
waitReachable(config.client.l1.public, 10_000),
waitReachable(config.client.l2.public, 10_000),
waitForNextGame(config.client.l1.public, chainConfig.l2, 60_000),
waitReachable(config.client.l1.public, 60_000),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those changes related to this PR?

waitReachable(config.client.l2.public, 60_000),
waitForNextGame(config.client.l1.public, chainConfig.l2, 300_000),
])
if (success.every((v) => v == true)) {
return config
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/celo/tests/tokenduality.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let config = {}

beforeAll(async () => {
config = await setup()
}, 30_000)
}, 5*minute)

test(
'test token duality',
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/celo/tests/withdraw_deposit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var config = {}

beforeAll(async () => {
config = await setup()
}, minute)
}, 5*minute)

test(
'execute a withdraw and a deposit in succession',
Expand Down
2 changes: 1 addition & 1 deletion ops/check-changed/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
certifi==2024.7.4
cffi==1.15.1
cffi==1.17.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, related to the fault registry changes?

charset-normalizer==2.1.1
Deprecated==1.2.13
idna==3.7
Expand Down
147 changes: 99 additions & 48 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,17 @@ 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 +343,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 +376,7 @@ contract Deploy is Deployer {
setupOpAltDA();
}
}
setupOpChain();
setupOpChain(_initializeFaultGames);
console.log("set up op chain!");
}

Expand Down Expand Up @@ -392,7 +410,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,15 +421,25 @@ 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();
}

setAlphabetFaultGameImplementation({ _allowUpgrade: false });
palango marked this conversation as resolved.
Show resolved Hide resolved
setFastFaultGameImplementation({ _allowUpgrade: false });
/// @notice Deploy the fault games and set the implementations. Initialize AnchorStateRegistry.
function setupFaultGames() public {
setCannonFaultGameImplementation({ _allowUpgrade: false });
setPermissionedCannonFaultGameImplementation({ _allowUpgrade: false });

initializeAnchorStateRegistry(false);
transferDisputeGameFactoryOwnership();
transferDelayedWETHOwnership();
}

/// @notice Deploy all of the proxies
Expand Down Expand Up @@ -484,7 +512,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 @@ -511,7 +539,9 @@ contract Deploy is Deployer {
initializeDisputeGameFactory();
initializeDelayedWETH();
initializePermissionedDelayedWETH();
initializeAnchorStateRegistry();
if (_initializeAnchorStateRegistry) {
initializeAnchorStateRegistry(true);
}

ChainAssertions.checkCustomGasTokenOptimismPortal({ _contracts: _proxies(), _cfg: cfg, _isProxy: true });
}
Expand Down Expand Up @@ -1047,48 +1077,69 @@ contract Deploy is Deployer {
});
}

function initializeAnchorStateRegistry() public broadcast {
/// @notice Initialize the AnchorStateRegistry with a known root anchor
/// @param _deployTestingGames Whether to deploy the testing Fualt Game implementations)
function initializeAnchorStateRegistry(bool _deployTestingGames) public broadcast {
console.log("Upgrading and initializing AnchorStateRegistry proxy");
address anchorStateRegistryProxy = mustGetAddress("AnchorStateRegistryProxy");
address anchorStateRegistry = mustGetAddress("AnchorStateRegistry");
ISuperchainConfig superchainConfig = ISuperchainConfig(mustGetAddress("SuperchainConfigProxy"));

IAnchorStateRegistry.StartingAnchorRoot[] memory roots = new IAnchorStateRegistry.StartingAnchorRoot[](5);
roots[0] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.CANNON,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
roots[1] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.PERMISSIONED_CANNON,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
roots[2] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.ALPHABET,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
roots[3] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.ASTERISC,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
roots[4] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.FAST,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
IAnchorStateRegistry.StartingAnchorRoot[] memory roots;
if (_deployTestingGames) {
roots = new IAnchorStateRegistry.StartingAnchorRoot[](5);
roots[0] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.CANNON,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
roots[1] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.PERMISSIONED_CANNON,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
roots[2] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.ALPHABET,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
roots[3] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.ASTERISC,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
roots[4] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.FAST,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
} else {
roots = new IAnchorStateRegistry.StartingAnchorRoot[](2);
roots[0] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.CANNON,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
roots[1] = IAnchorStateRegistry.StartingAnchorRoot({
gameType: GameTypes.PERMISSIONED_CANNON,
outputRoot: OutputRoot({
root: Hash.wrap(cfg.faultGameGenesisOutputRoot()),
l2BlockNumber: cfg.faultGameGenesisBlock()
})
});
}

_upgradeAndCallViaSafe({
_proxy: payable(anchorStateRegistryProxy),
Expand Down
Loading