diff --git a/packages/contracts-bedrock/deploy-config/devnetL1-template.json b/packages/contracts-bedrock/deploy-config/devnetL1-template.json index 11bc3557791..d241c3186a0 100644 --- a/packages/contracts-bedrock/deploy-config/devnetL1-template.json +++ b/packages/contracts-bedrock/deploy-config/devnetL1-template.json @@ -50,8 +50,8 @@ "l2GenesisFjordTimeOffset": "0x0", "l1CancunTimeOffset": "0x0", "systemConfigStartBlock": 0, - "requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000", - "recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000", + "requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001", + "recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001", "faultGameAbsolutePrestate": "0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98", "faultGameMaxDepth": 50, "faultGameClockExtension": 0, diff --git a/packages/contracts-bedrock/deploy-config/hardhat.json b/packages/contracts-bedrock/deploy-config/hardhat.json index e26c10ef78c..6dcbb299d1d 100644 --- a/packages/contracts-bedrock/deploy-config/hardhat.json +++ b/packages/contracts-bedrock/deploy-config/hardhat.json @@ -41,8 +41,8 @@ "eip1559Elasticity": 10, "l2GenesisRegolithTimeOffset": "0x0", "systemConfigStartBlock": 0, - "requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000", - "recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000", + "requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001", + "recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001", "faultGameAbsolutePrestate": "0x0000000000000000000000000000000000000000000000000000000000000000", "faultGameMaxDepth": 8, "faultGameClockExtension": 0, diff --git a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol index 57c5e30c7d8..b625bdc31d5 100644 --- a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol @@ -17,6 +17,7 @@ import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol"; import { Process } from "scripts/libraries/Process.sol"; import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol"; import { DeployUtils } from "scripts/libraries/DeployUtils.sol"; +import { DeploySuperchainInput, DeploySuperchain, DeploySuperchainOutput } from "scripts/DeploySuperchain.s.sol"; // Contracts import { AddressManager } from "src/legacy/AddressManager.sol"; @@ -268,8 +269,12 @@ contract Deploy is Deployer { setupSuperchain(); console.log("set up superchain!"); } - - setupOpChainAdmin(); + if (cfg.useInterop()) { + deployImplementationsInterop(); + } else { + deployImplementations(); + } + setupOpChain(); if (cfg.useAltDA()) { bytes32 typeHash = keccak256(bytes(cfg.daCommitmentType())); bytes32 keccakHash = keccak256(bytes("KeccakCommitment")); @@ -277,8 +282,7 @@ contract Deploy is Deployer { setupOpAltDA(); } } - - setupOpChain(); + transferProxyAdminOwnership({ _isSuperchain: false }); console.log("set up op chain!"); } @@ -286,41 +290,45 @@ contract Deploy is Deployer { // High Level Deployment Functions // //////////////////////////////////////////////////////////////// - /// @notice Deploy the address manager and proxy admin contracts. - function setupOpChainAdmin() public { - deployAddressManager(); - deployProxyAdmin({ _isSuperchain: false }); - } - /// @notice Deploy a full system with a new SuperchainConfig /// The Superchain system has 2 singleton contracts which lie outside of an OP Chain: /// 1. The SuperchainConfig contract /// 2. The ProtocolVersions contract function setupSuperchain() public { console.log("Setting up Superchain"); + DeploySuperchain deploySuperchain = new DeploySuperchain(); + (DeploySuperchainInput dsi, DeploySuperchainOutput dso) = deploySuperchain.etchIOContracts(); - // Deploy the SuperchainConfigProxy - deployERC1967ProxyWithOwner("SuperchainConfigProxy", mustGetAddress("SuperchainProxyAdmin")); - deploySuperchainConfig(); - initializeSuperchainConfig(); + // Set the input values on the input contract. + dsi.set(dsi.superchainProxyAdminOwner.selector, mustGetAddress("SuperchainProxyAdmin")); + // TODO: when DeployAuthSystem is done, finalSystemOwner should be replaced with the Foundation Upgrades Safe + dsi.set(dsi.protocolVersionsOwner.selector, cfg.finalSystemOwner()); + dsi.set(dsi.guardian.selector, cfg.superchainConfigGuardian()); + dsi.set(dsi.paused.selector, false); - // Deploy the ProtocolVersionsProxy - deployERC1967ProxyWithOwner("ProtocolVersionsProxy", mustGetAddress("SuperchainProxyAdmin")); - deployProtocolVersions(); - initializeProtocolVersions(); + dsi.set(dsi.requiredProtocolVersion.selector, ProtocolVersion.wrap(cfg.requiredProtocolVersion())); + dsi.set(dsi.recommendedProtocolVersion.selector, ProtocolVersion.wrap(cfg.recommendedProtocolVersion())); + + // Run the deployment script. + deploySuperchain.run(dsi, dso); + save("superchainProxyAdmin", address(dso.superchainProxyAdmin())); + save("SuperchainConfigProxy", address(dso.superchainConfigProxy())); + save("SuperchainConfig", address(dso.superchainConfigImpl())); + save("ProtocolVersionsProxy", address(dso.protocolVersionsProxy())); + save("ProtocolVersions", address(dso.protocolVersionsImpl())); } /// @notice Deploy a new OP Chain, with an existing SuperchainConfig provided function setupOpChain() public { console.log("Deploying OP Chain"); + deployAddressManager(); + deployProxyAdmin({ _isSuperchain: false }); // Ensure that the requisite contracts are deployed mustGetAddress("SuperchainConfigProxy"); mustGetAddress("AddressManager"); mustGetAddress("ProxyAdmin"); - deployImplementations(); - deployOpChain(); initializeOpChain(); @@ -331,7 +339,6 @@ contract Deploy is Deployer { transferDisputeGameFactoryOwnership(); transferDelayedWETHOwnership(); - transferProxyAdminOwnership({ _isSuperchain: false }); } /// @notice Deploy all of the OP Chain specific contracts @@ -367,8 +374,9 @@ contract Deploy is Deployer { deploySystemConfig(); deployL1StandardBridge(); deployL1ERC721Bridge(); - deployOptimismPortal(); + deployOptimismPortal(); // todo: pull this out into an override option after DeployImplementations runs deployL2OutputOracle(); + // Fault proofs deployOptimismPortal2(); deployDisputeGameFactory(); @@ -377,6 +385,24 @@ contract Deploy is Deployer { deployMips(); } + /// @notice Deploy all of the implementations + function deployImplementationsInterop() public { + console.log("Deploying implementations"); + deployL1CrossDomainMessenger(); + deployOptimismMintableERC20Factory(); + deploySystemConfigInterop(); + deployL1StandardBridge(); + deployL1ERC721Bridge(); + deployL2OutputOracle(); + + // Fault proofs + deployOptimismPortalInterop(); + deployDisputeGameFactory(); + deployDelayedWETH(); + deployPreimageOracle(); + deployMips(); + } + /// @notice Initialize all of the proxies in an OP Chain by upgrading to the correct proxy and calling the /// initialize function function initializeOpChain() public { @@ -622,32 +648,45 @@ contract Deploy is Deployer { uint32(cfg.respectedGameType()) == cfg.respectedGameType(), "Deploy: respectedGameType must fit into uint32" ); - if (cfg.useInterop()) { - addr_ = DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "OptimismPortalInterop", - _args: DeployUtils.encodeConstructor( - abi.encodeCall( - IOptimismPortalInterop.__constructor__, - (cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds()) - ) + addr_ = DeployUtils.create2AndSave({ + _save: this, + _salt: _implSalt(), + _name: "OptimismPortal2", + _args: DeployUtils.encodeConstructor( + abi.encodeCall( + IOptimismPortal2.__constructor__, + (cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds()) ) - }); - save("OptimismPortal2", addr_); - } else { - addr_ = DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "OptimismPortal2", - _args: DeployUtils.encodeConstructor( - abi.encodeCall( - IOptimismPortal2.__constructor__, - (cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds()) - ) + ) + }); + + // Override the `OptimismPortal2` contract to the deployed implementation. This is necessary + // to check the `OptimismPortal2` implementation alongside dependent contracts, which + // are always proxies. + Types.ContractSet memory contracts = _proxiesUnstrict(); + contracts.OptimismPortal2 = addr_; + ChainAssertions.checkOptimismPortal2({ _contracts: contracts, _cfg: cfg, _isProxy: false }); + } + + /// @notice Deploy the OptimismPortalInterop contract + function deployOptimismPortalInterop() public broadcast returns (address addr_) { + // Could also verify this inside DeployConfig but doing it here is a bit more reliable. + require( + uint32(cfg.respectedGameType()) == cfg.respectedGameType(), "Deploy: respectedGameType must fit into uint32" + ); + + addr_ = DeployUtils.create2AndSave({ + _save: this, + _salt: _implSalt(), + _name: "OptimismPortalInterop", + _args: DeployUtils.encodeConstructor( + abi.encodeCall( + IOptimismPortalInterop.__constructor__, + (cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds()) ) - }); - } + ) + }); + save("OptimismPortal2", addr_); // Override the `OptimismPortal2` contract to the deployed implementation. This is necessary // to check the `OptimismPortal2` implementation alongside dependent contracts, which @@ -751,27 +790,6 @@ contract Deploy is Deployer { addr_ = address(weth); } - /// @notice Deploy the ProtocolVersions - function deployProtocolVersions() public broadcast returns (address addr_) { - IProtocolVersions versions = IProtocolVersions( - DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "ProtocolVersions", - _args: DeployUtils.encodeConstructor(abi.encodeCall(IProtocolVersions.__constructor__, ())) - }) - ); - - // Override the `ProtocolVersions` contract to the deployed implementation. This is necessary - // to check the `ProtocolVersions` implementation alongside dependent contracts, which - // are always proxies. - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.ProtocolVersions = address(versions); - ChainAssertions.checkProtocolVersions({ _contracts: contracts, _cfg: cfg, _isProxy: false }); - - addr_ = address(versions); - } - /// @notice Deploy the PreimageOracle function deployPreimageOracle() public broadcast returns (address addr_) { IPreimageOracle preimageOracle = IPreimageOracle( @@ -824,22 +842,23 @@ contract Deploy is Deployer { /// @notice Deploy the SystemConfig function deploySystemConfig() public broadcast returns (address addr_) { - if (cfg.useInterop()) { - addr_ = DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "SystemConfigInterop", - _args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfigInterop.__constructor__, ())) - }); - save("SystemConfig", addr_); - } else { - addr_ = DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "SystemConfig", - _args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfig.__constructor__, ())) - }); - } + addr_ = DeployUtils.create2AndSave({ + _save: this, + _salt: _implSalt(), + _name: "SystemConfig", + _args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfig.__constructor__, ())) + }); + } + + /// @notice Deploy the SystemConfigInterop contract + function deploySystemConfigInterop() public broadcast returns (address addr_) { + addr_ = DeployUtils.create2AndSave({ + _save: this, + _salt: _implSalt(), + _name: "SystemConfigInterop", + _args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfigInterop.__constructor__, ())) + }); + save("SystemConfig", addr_); // Override the `SystemConfig` contract to the deployed implementation. This is necessary // to check the `SystemConfig` implementation alongside dependent contracts, which @@ -923,21 +942,6 @@ contract Deploy is Deployer { // Initialize Functions // //////////////////////////////////////////////////////////////// - /// @notice Initialize the SuperchainConfig - function initializeSuperchainConfig() public broadcast { - address payable superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); - address payable superchainConfig = mustGetAddress("SuperchainConfig"); - - IProxyAdmin proxyAdmin = IProxyAdmin(payable(mustGetAddress("SuperchainProxyAdmin"))); - proxyAdmin.upgradeAndCall({ - _proxy: superchainConfigProxy, - _implementation: superchainConfig, - _data: abi.encodeCall(ISuperchainConfig.initialize, (cfg.superchainConfigGuardian(), false)) - }); - - ChainAssertions.checkSuperchainConfig({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isPaused: false }); - } - /// @notice Initialize the DisputeGameFactory function initializeDisputeGameFactory() public broadcast { console.log("Upgrading and initializing DisputeGameFactory proxy"); @@ -1331,36 +1335,6 @@ contract Deploy is Deployer { ChainAssertions.checkOptimismPortal2({ _contracts: _proxies(), _cfg: cfg, _isProxy: true }); } - function initializeProtocolVersions() public broadcast { - console.log("Upgrading and initializing ProtocolVersions proxy"); - address protocolVersionsProxy = mustGetAddress("ProtocolVersionsProxy"); - address protocolVersions = mustGetAddress("ProtocolVersions"); - - address finalSystemOwner = cfg.finalSystemOwner(); - uint256 requiredProtocolVersion = cfg.requiredProtocolVersion(); - uint256 recommendedProtocolVersion = cfg.recommendedProtocolVersion(); - - IProxyAdmin proxyAdmin = IProxyAdmin(payable(mustGetAddress("SuperchainProxyAdmin"))); - proxyAdmin.upgradeAndCall({ - _proxy: payable(protocolVersionsProxy), - _implementation: protocolVersions, - _data: abi.encodeCall( - IProtocolVersions.initialize, - ( - finalSystemOwner, - ProtocolVersion.wrap(requiredProtocolVersion), - ProtocolVersion.wrap(recommendedProtocolVersion) - ) - ) - }); - - IProtocolVersions versions = IProtocolVersions(protocolVersionsProxy); - string memory version = versions.version(); - console.log("ProtocolVersions version: %s", version); - - ChainAssertions.checkProtocolVersions({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true }); - } - /// @notice Transfer ownership of the DisputeGameFactory contract to the final system owner function transferDisputeGameFactoryOwnership() public broadcast { console.log("Transferring DisputeGameFactory ownership to Safe"); diff --git a/packages/contracts-bedrock/semver-lock.json b/packages/contracts-bedrock/semver-lock.json index 73d8ba52c48..cec1d51d210 100644 --- a/packages/contracts-bedrock/semver-lock.json +++ b/packages/contracts-bedrock/semver-lock.json @@ -48,8 +48,8 @@ "sourceCodeHash": "0x6401b81f04093863557ef46192f56793daa0d412618065383ab353b2ed2929d8" }, "src/L1/ProtocolVersions.sol": { - "initCodeHash": "0x8f033874dd8b36615b2209d553660dcff1ff91ca2bad3ca1de7b441dbfba4842", - "sourceCodeHash": "0x5a7e91e02224e02a5a4bbf0fea7e9bd4a1168e2fe5e787023c9a75bcb6c26204" + "initCodeHash": "0xf7a9ed8c772cfb1234988fd6fd195dc21615b216bb39e728e7699b875040d902", + "sourceCodeHash": "0x92f15d62361bffc305f0db48a5676329f8e5ed2e454f8c8ff83ef7d3667d7f01" }, "src/L1/SuperchainConfig.sol": { "initCodeHash": "0xfca12d9016c746e5c275b186e0ca40cfd65cf45a5665aab7589a669fea3abb47", diff --git a/packages/contracts-bedrock/src/L1/ProtocolVersions.sol b/packages/contracts-bedrock/src/L1/ProtocolVersions.sol index f988d43e169..2be060604c8 100644 --- a/packages/contracts-bedrock/src/L1/ProtocolVersions.sol +++ b/packages/contracts-bedrock/src/L1/ProtocolVersions.sol @@ -37,8 +37,8 @@ contract ProtocolVersions is OwnableUpgradeable, ISemver { event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data); /// @notice Semantic version. - /// @custom:semver 1.0.1-beta.1 - string public constant version = "1.0.1-beta.1"; + /// @custom:semver 1.0.1-beta.2 + string public constant version = "1.0.1-beta.2"; /// @notice Constructs the ProtocolVersion contract. Cannot set /// the owner to `address(0)` due to the Ownable contract's