From 48a86595288207ead7540217468ca0bf184384ae Mon Sep 17 00:00:00 2001 From: protolambda Date: Tue, 6 Aug 2024 13:29:48 -0600 Subject: [PATCH] interop deploy --- interop-devnet/docker-compose.yml | 4 + .../contracts-bedrock/scripts/L2Genesis.s.sol | 2 +- .../scripts/deploy/InteropDeploy.s.sol | 112 +++++++++++++++--- 3 files changed, 101 insertions(+), 17 deletions(-) diff --git a/interop-devnet/docker-compose.yml b/interop-devnet/docker-compose.yml index b393e840a22b..5c20dfea743a 100644 --- a/interop-devnet/docker-compose.yml +++ b/interop-devnet/docker-compose.yml @@ -255,6 +255,7 @@ services: - "6062:6060" - "7302:7300" - "6546:8545" + # proposer addr: 0x71b4a2d9B91726bdb5849D928967A1654D7F3de7 environment: OP_PROPOSER_L1_ETH_RPC: http://l1:8545 OP_PROPOSER_ROLLUP_RPC: http://op-node-a:8545 @@ -283,6 +284,7 @@ services: - "6062:6060" - "7302:7300" - "6546:8545" + # proposer addr: 0x8c408c9ce6718F4a3AFa7860f2E7B190B25fBDfA environment: OP_PROPOSER_L1_ETH_RPC: http://l1:8545 OP_PROPOSER_ROLLUP_RPC: http://op-node-b:8545 @@ -312,6 +314,7 @@ services: - "6061:6060" - "7301:7300" - "6545:8545" + # batcher addr: 0xCA55aC8514b25C660151a8AE0c90f116DF160daa environment: OP_BATCHER_L1_ETH_RPC: http://l1:8545 OP_BATCHER_L2_ETH_RPC: http://l2-a:8545 @@ -343,6 +346,7 @@ services: - "6061:6060" - "7301:7300" - "6545:8545" + # batcher addr: 0x252a3336Fb2A4352D1bD3b139f4e540AA45236bd environment: OP_BATCHER_L1_ETH_RPC: http://l1:8545 OP_BATCHER_L2_ETH_RPC: http://l2-b:8545 diff --git a/packages/contracts-bedrock/scripts/L2Genesis.s.sol b/packages/contracts-bedrock/scripts/L2Genesis.s.sol index e6397fec3c33..f6a71a3071d9 100644 --- a/packages/contracts-bedrock/scripts/L2Genesis.s.sol +++ b/packages/contracts-bedrock/scripts/L2Genesis.s.sol @@ -495,7 +495,7 @@ contract L2Genesis is Deployer { /// When performing a regular user-initiated contract-creation of a preinstall, /// the creation will fail (but nonce will be bumped and not blocked). /// The preinstalls themselves are all inserted with a nonce of 1, reflecting regular user execution. - function setPreinstalls() internal { + function setPreinstalls() public { _setPreinstallCode(Preinstalls.MultiCall3); _setPreinstallCode(Preinstalls.Create2Deployer); _setPreinstallCode(Preinstalls.Safe_v130); diff --git a/packages/contracts-bedrock/scripts/deploy/InteropDeploy.s.sol b/packages/contracts-bedrock/scripts/deploy/InteropDeploy.s.sol index cc7b4388a0e8..db23268e6775 100644 --- a/packages/contracts-bedrock/scripts/deploy/InteropDeploy.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/InteropDeploy.s.sol @@ -5,37 +5,117 @@ import { Script } from "forge-std/Script.sol"; import { Artifacts } from "scripts/Artifacts.s.sol"; import { Deploy } from "scripts/deploy/Deploy.s.sol"; import { Config } from "scripts/Config.sol"; +import { L2Genesis } from "scripts/L2Genesis.s.sol"; import { console } from "forge-std/console.sol"; /// @title InteropDeployer /// @notice Functions to deploy OP-Stack components in incremental steps, for interop testing usage. -contract InteropDeploy is Deploy { +contract InteropDeploy is Script { + + L2Genesis l2GenesisUtils = L2Genesis(address(uint160(uint256(keccak256(abi.encode("optimism.l2genesis")))))); + + Deploy deployUtils = Deploy(address(uint160(uint256(keccak256(abi.encode("optimism.deploy")))))); + + /// @notice The address of the deployer account. + address internal deployer; + + uint80 internal constant DEV_ACCOUNT_FUND_AMT = 10_000_000 ether; + + function setUp() public virtual override { + deployer = makeAddr("deployer"); + + // Note: we don't init this contract, we just use some helper functions + vm.etch(address(l2GenesisUtils), vm.getDeployedCode("L2Genesis.s.sol:L2Genesis")); + vm.label(address(l2GenesisUtils), "L2Genesis"); + vm.allowCheatcodes(address(l2GenesisUtils)); + + vm.etch(address(deployUtils), vm.getDeployedCode("Deploy.s.sol:Deploy")); + vm.label(address(deployUtils), "Deploy"); + vm.allowCheatcodes(address(deployUtils)); + } + + function loadAllocs() public { + string memory inputAllocsPath = vm.envString("ALLOCS_INPUT_PATH"); + vm.loadAllocs(inputAllocsPath); + } + + function dumpAllocs() public { + /// Reset so its not included state dump + vm.etch(address(l2GenesisUtils), ""); + + vm.etch(msg.sender, ""); + vm.resetNonce(msg.sender); + vm.deal(msg.sender, 0); + + vm.deal(deployer, 0); + vm.resetNonce(deployer); + + string memory outputAllocsPath = vm.envString("ALLOCS_OUTPUT_PATH"); + vm.dumpState(outputAllocsPath); + } function initialL1() public { - // TODO load L1 dev deploy config - // TODO set chain ID to L1 from deploy config - // TODO add all preinstalls - // TODO add 4788 beacon roots contract - // TODO prefund dev accounts - // TODO prefund batcher/proposer accounts of chain A and B - // TODO dump allocs + // TODO set chain ID to L1 from deploy config (set via script for now?) + + // Put all preinstalls into the L1 chain. + // This includes the 4788 beacon roots contract. + // Hack: reuse the L2 genesis flow; + // to be refactored into common util later. + l2GenesisUtils.setPreinstalls(); + + // prefund user dev accounts + l2GenesisUtils.fundDevAccounts(); + + // TODO: loading these addresses from a well encapsulated dev config would be nice. + // operator accounts + vm.deal(address(0xCA55aC8514b25C660151a8AE0c90f116DF160daa), DEV_ACCOUNT_FUND_AMT); // batcher A + vm.deal(address(0x252a3336Fb2A4352D1bD3b139f4e540AA45236bd), DEV_ACCOUNT_FUND_AMT); // batcher B + vm.deal(address(0x71b4a2d9B91726bdb5849D928967A1654D7F3de7), DEV_ACCOUNT_FUND_AMT); // proposer A + vm.deal(address(0x8c408c9ce6718F4a3AFa7860f2E7B190B25fBDfA), DEV_ACCOUNT_FUND_AMT); // proposer B + // TODO proxy admins, sys config owners + + dumpAllocs(); } function deploySuperchain() public { - // TODO load allocs + loadAllocs(); + + // TODO load config + // TODO set chain ID to L1 from deploy config // TODO load superchain deploy config - // TODO deploy proxy admin - // TODO deploy SuperchainConfig - // TODO deploy ProtocolVersions - // TODO dump allocs + + // Deploy superchain components; + // AddressManager, ProxyAdmin, SuperchainConfig, ProtocolVersions + deployUtils.setupSuperchain(); + + // Deploy the implementations; to be reused between L2s (OP-Stack Manager style) + deployUtils.deployImplementations(); + + dumpAllocs(); } function deployL2() public { - // TODO load allocs + loadAllocs(); + // TODO set chain ID to L1 from deploy config // TODO load L2 deploy config - // TODO deploy proxies, attached to superchain implementation contracts - // TODO dump allocs + + deployUtils.deploySafe("SystemOwnerSafe"); + // TODO need to prepare artifacts such that the proxies + // can hook to the superchain implementations + deployUtils.deployProxies(); + deployUtils.initializeImplementations(); + + // For some reason the FP system deployment is separate + // from the above MCP-like proxy/impl setup. + deployUtils.setAlphabetFaultGameImplementation({ _allowUpgrade: false }); + deployUtils.setFastFaultGameImplementation({ _allowUpgrade: false }); + deployUtils.setCannonFaultGameImplementation({ _allowUpgrade: false }); + deployUtils.setPermissionedCannonFaultGameImplementation({ _allowUpgrade: false }); + deployUtils.transferDisputeGameFactoryOwnership(); + deployUtils.transferDelayedWETHOwnership(); + + dumpAllocs(); } }