diff --git a/bindings/deploy_chain.go b/bindings/deploy_chain.go index b3f95c9..6b20bd8 100644 --- a/bindings/deploy_chain.go +++ b/bindings/deploy_chain.go @@ -29,6 +29,13 @@ var ( _ = abi.ConvertType ) +// DeployChainAddressConfiguration is an auto generated low-level Go binding around an user-defined struct. +type DeployChainAddressConfiguration struct { + Batcher common.Address + Proposer common.Address + UnsafeBlockSigner common.Address +} + // DeployChainDeployAddresses is an auto generated low-level Go binding around an user-defined struct. type DeployChainDeployAddresses struct { L2OutputOracle common.Address @@ -48,9 +55,17 @@ type DeployChainGasConfiguration struct { GasToken common.Address } +// DeployChainGenesisConfiguration is an auto generated low-level Go binding around an user-defined struct. +type DeployChainGenesisConfiguration struct { + L1Number uint64 + L2Hash [32]byte + L2StateRoot [32]byte + L2Time uint64 +} + // DeployChainMetaData contains all meta data concerning the DeployChain contract. var DeployChainMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_proxyAdmin\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_optimismPortal\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_systemConfig\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l1StandardBridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l1ERC721Bridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_optimismMintableERC20Factory\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l1CrossDomainMessenger\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l2OutputOracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_superchainConfig\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_protocolVersions\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"MESSAGE_PASSER_STORAGE_HASH\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"calculateBatchInbox\",\"inputs\":[{\"name\":\"chainID\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"deploy\",\"inputs\":[{\"name\":\"chainID\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"genesisL1Number\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"genesisL2Hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"genesisL2StateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"genesisL2Time\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasConfig\",\"type\":\"tuple\",\"internalType\":\"structDeployChain.GasConfiguration\",\"components\":[{\"name\":\"basefeeScalar\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"blobbasefeeScalar\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"gasLimit\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasToken\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"name\":\"batcherAddress\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"unsafeBlockSigner\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"proposer\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"deployAddresses\",\"inputs\":[{\"name\":\"chainID\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structDeployChain.DeployAddresses\",\"components\":[{\"name\":\"l2OutputOracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"systemConfig\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"optimismPortal\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1CrossDomainMessenger\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1StandardBridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1ERC721Bridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"optimismMintableERC20Factory\",\"type\":\"address\",\"internalType\":\"address\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"l1CrossDomainMessenger\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"l1ERC721Bridge\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"l1StandardBridge\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"l2OutputOracle\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"optimismMintableERC20Factory\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"optimismPortal\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"protocolVersions\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"proxyAdmin\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"superchainConfig\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"systemConfig\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"event\",\"name\":\"Deploy\",\"inputs\":[{\"name\":\"chainID\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"},{\"name\":\"configHash\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"outputRoot\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"batchInbox\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"addresses\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structDeployChain.DeployAddresses\",\"components\":[{\"name\":\"l2OutputOracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"systemConfig\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"optimismPortal\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1CrossDomainMessenger\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1StandardBridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1ERC721Bridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"optimismMintableERC20Factory\",\"type\":\"address\",\"internalType\":\"address\"}]}],\"anonymous\":false}]", + ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_proxyAdmin\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_optimismPortal\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_systemConfig\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l1StandardBridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l1ERC721Bridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_optimismMintableERC20Factory\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l1CrossDomainMessenger\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l2OutputOracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_superchainConfig\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_protocolVersions\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"MESSAGE_PASSER_STORAGE_HASH\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"calculateBatchInbox\",\"inputs\":[{\"name\":\"chainID\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"deploy\",\"inputs\":[{\"name\":\"chainID\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"genesisConfig\",\"type\":\"tuple\",\"internalType\":\"structDeployChain.GenesisConfiguration\",\"components\":[{\"name\":\"l1Number\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"l2Hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"l2StateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"l2Time\",\"type\":\"uint64\",\"internalType\":\"uint64\"}]},{\"name\":\"gasConfig\",\"type\":\"tuple\",\"internalType\":\"structDeployChain.GasConfiguration\",\"components\":[{\"name\":\"basefeeScalar\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"blobbasefeeScalar\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"gasLimit\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasToken\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"name\":\"addressConfig\",\"type\":\"tuple\",\"internalType\":\"structDeployChain.AddressConfiguration\",\"components\":[{\"name\":\"batcher\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"proposer\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"unsafeBlockSigner\",\"type\":\"address\",\"internalType\":\"address\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"deployAddresses\",\"inputs\":[{\"name\":\"chainID\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structDeployChain.DeployAddresses\",\"components\":[{\"name\":\"l2OutputOracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"systemConfig\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"optimismPortal\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1CrossDomainMessenger\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1StandardBridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1ERC721Bridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"optimismMintableERC20Factory\",\"type\":\"address\",\"internalType\":\"address\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"l1CrossDomainMessenger\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"l1ERC721Bridge\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"l1StandardBridge\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"l2OutputOracle\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"optimismMintableERC20Factory\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"optimismPortal\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"protocolVersions\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"proxyAdmin\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"superchainConfig\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"systemConfig\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"event\",\"name\":\"Deploy\",\"inputs\":[{\"name\":\"chainID\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"},{\"name\":\"configHash\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"outputRoot\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"batchInbox\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"addresses\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structDeployChain.DeployAddresses\",\"components\":[{\"name\":\"l2OutputOracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"systemConfig\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"optimismPortal\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1CrossDomainMessenger\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1StandardBridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l1ERC721Bridge\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"optimismMintableERC20Factory\",\"type\":\"address\",\"internalType\":\"address\"}]}],\"anonymous\":false}]", } // DeployChainABI is the input ABI used to generate the binding from. @@ -602,25 +617,25 @@ func (_DeployChain *DeployChainCallerSession) SystemConfig() (common.Address, er return _DeployChain.Contract.SystemConfig(&_DeployChain.CallOpts) } -// Deploy is a paid mutator transaction binding the contract method 0x6b74d941. +// Deploy is a paid mutator transaction binding the contract method 0xde57d301. // -// Solidity: function deploy(uint256 chainID, uint64 genesisL1Number, bytes32 genesisL2Hash, bytes32 genesisL2StateRoot, uint64 genesisL2Time, (uint32,uint32,uint64,address) gasConfig, address batcherAddress, address unsafeBlockSigner, address proposer) returns() -func (_DeployChain *DeployChainTransactor) Deploy(opts *bind.TransactOpts, chainID *big.Int, genesisL1Number uint64, genesisL2Hash [32]byte, genesisL2StateRoot [32]byte, genesisL2Time uint64, gasConfig DeployChainGasConfiguration, batcherAddress common.Address, unsafeBlockSigner common.Address, proposer common.Address) (*types.Transaction, error) { - return _DeployChain.contract.Transact(opts, "deploy", chainID, genesisL1Number, genesisL2Hash, genesisL2StateRoot, genesisL2Time, gasConfig, batcherAddress, unsafeBlockSigner, proposer) +// Solidity: function deploy(uint256 chainID, (uint64,bytes32,bytes32,uint64) genesisConfig, (uint32,uint32,uint64,address) gasConfig, (address,address,address) addressConfig) returns() +func (_DeployChain *DeployChainTransactor) Deploy(opts *bind.TransactOpts, chainID *big.Int, genesisConfig DeployChainGenesisConfiguration, gasConfig DeployChainGasConfiguration, addressConfig DeployChainAddressConfiguration) (*types.Transaction, error) { + return _DeployChain.contract.Transact(opts, "deploy", chainID, genesisConfig, gasConfig, addressConfig) } -// Deploy is a paid mutator transaction binding the contract method 0x6b74d941. +// Deploy is a paid mutator transaction binding the contract method 0xde57d301. // -// Solidity: function deploy(uint256 chainID, uint64 genesisL1Number, bytes32 genesisL2Hash, bytes32 genesisL2StateRoot, uint64 genesisL2Time, (uint32,uint32,uint64,address) gasConfig, address batcherAddress, address unsafeBlockSigner, address proposer) returns() -func (_DeployChain *DeployChainSession) Deploy(chainID *big.Int, genesisL1Number uint64, genesisL2Hash [32]byte, genesisL2StateRoot [32]byte, genesisL2Time uint64, gasConfig DeployChainGasConfiguration, batcherAddress common.Address, unsafeBlockSigner common.Address, proposer common.Address) (*types.Transaction, error) { - return _DeployChain.Contract.Deploy(&_DeployChain.TransactOpts, chainID, genesisL1Number, genesisL2Hash, genesisL2StateRoot, genesisL2Time, gasConfig, batcherAddress, unsafeBlockSigner, proposer) +// Solidity: function deploy(uint256 chainID, (uint64,bytes32,bytes32,uint64) genesisConfig, (uint32,uint32,uint64,address) gasConfig, (address,address,address) addressConfig) returns() +func (_DeployChain *DeployChainSession) Deploy(chainID *big.Int, genesisConfig DeployChainGenesisConfiguration, gasConfig DeployChainGasConfiguration, addressConfig DeployChainAddressConfiguration) (*types.Transaction, error) { + return _DeployChain.Contract.Deploy(&_DeployChain.TransactOpts, chainID, genesisConfig, gasConfig, addressConfig) } -// Deploy is a paid mutator transaction binding the contract method 0x6b74d941. +// Deploy is a paid mutator transaction binding the contract method 0xde57d301. // -// Solidity: function deploy(uint256 chainID, uint64 genesisL1Number, bytes32 genesisL2Hash, bytes32 genesisL2StateRoot, uint64 genesisL2Time, (uint32,uint32,uint64,address) gasConfig, address batcherAddress, address unsafeBlockSigner, address proposer) returns() -func (_DeployChain *DeployChainTransactorSession) Deploy(chainID *big.Int, genesisL1Number uint64, genesisL2Hash [32]byte, genesisL2StateRoot [32]byte, genesisL2Time uint64, gasConfig DeployChainGasConfiguration, batcherAddress common.Address, unsafeBlockSigner common.Address, proposer common.Address) (*types.Transaction, error) { - return _DeployChain.Contract.Deploy(&_DeployChain.TransactOpts, chainID, genesisL1Number, genesisL2Hash, genesisL2StateRoot, genesisL2Time, gasConfig, batcherAddress, unsafeBlockSigner, proposer) +// Solidity: function deploy(uint256 chainID, (uint64,bytes32,bytes32,uint64) genesisConfig, (uint32,uint32,uint64,address) gasConfig, (address,address,address) addressConfig) returns() +func (_DeployChain *DeployChainTransactorSession) Deploy(chainID *big.Int, genesisConfig DeployChainGenesisConfiguration, gasConfig DeployChainGasConfiguration, addressConfig DeployChainAddressConfiguration) (*types.Transaction, error) { + return _DeployChain.Contract.Deploy(&_DeployChain.TransactOpts, chainID, genesisConfig, gasConfig, addressConfig) } // DeployChainDeployIterator is returned from FilterDeploy and is used to iterate over the raw logs and unpacked data for Deploy events raised by the DeployChain contract. diff --git a/deployments/84532-deploy.json b/deployments/84532-deploy.json index 921b60f..58e4c7e 100644 --- a/deployments/84532-deploy.json +++ b/deployments/84532-deploy.json @@ -2,7 +2,7 @@ "AddressManager": "0x42dffe88Be465d26a8858701252b7aa203bB242E", "AnchorStateRegistryProxy": "0x0000000000000000000000000000000000000001", "DelayedWETHProxy": "0x0000000000000000000000000000000000000001", - "DeployChain": "0x7caf66E61504FA8E72a261a14b29c815Aa7977D0", + "DeployChain": "0xdC6aC6F65ee3F43E62b68a3f236DdaB6bd73D62A", "DisputeGameFactoryProxy": "0x0000000000000000000000000000000000000001", "L1CrossDomainMessenger": "0x4894Ad99C394cCd9a15fCB883fb46701fE228E52", "L1CrossDomainMessengerProxy": "0x081415893317739FA0BdE509E5C13E54Aef23a0a", diff --git a/script/DeployDeployChain.s.sol b/script/DeployDeployChain.s.sol new file mode 100644 index 0000000..f281ec1 --- /dev/null +++ b/script/DeployDeployChain.s.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.15; + +import {Script} from "forge-std/Script.sol"; +import {console2 as console} from "forge-std/console2.sol"; +import {DeployChain} from "../src/DeployChain.sol"; +import {Artifacts} from "@eth-optimism-bedrock/scripts/Artifacts.s.sol"; +import {Config} from "@eth-optimism-bedrock/scripts/libraries/Config.sol"; + +contract DeployDeployChain is Script, Artifacts { + function run() public { + _loadAddresses(deploymentOutfile); + + console.log("Deploying DeployChain implementation"); + DeployChain deployChain = new DeployChain{salt: _implSalt()}({ + _proxyAdmin: mustGetAddress("ProxyAdmin"), + _optimismPortal: mustGetAddress("OptimismPortalProxy"), + _systemConfig: mustGetAddress("SystemConfigProxy"), + _l1StandardBridge: mustGetAddress("L1StandardBridgeProxy"), + _l1ERC721Bridge: mustGetAddress("L1ERC721BridgeProxy"), + _optimismMintableERC20Factory: mustGetAddress("OptimismMintableERC20FactoryProxy"), + _l1CrossDomainMessenger: mustGetAddress("L1CrossDomainMessengerProxy"), + _l2OutputOracle: mustGetAddress("L2OutputOracleProxy"), + _superchainConfig: mustGetAddress("SuperchainConfigProxy"), + _protocolVersions: mustGetAddress("ProtocolVersionsProxy") + }); + + delete _namedDeployments["DeployChain"]; + save("DeployChain", address(deployChain)); + } + + function _implSalt() internal view returns (bytes32 _env) { + _env = keccak256(bytes(vm.envOr("IMPL_SALT", string("ethers phoenix")))); + } +} diff --git a/src/DeployChain.sol b/src/DeployChain.sol index 51595e8..1c78d12 100644 --- a/src/DeployChain.sol +++ b/src/DeployChain.sol @@ -31,6 +31,13 @@ contract DeployChain { address optimismMintableERC20Factory; } + struct GenesisConfiguration { + uint64 l1Number; + bytes32 l2Hash; + bytes32 l2StateRoot; + uint64 l2Time; + } + struct GasConfiguration { uint32 basefeeScalar; uint32 blobbasefeeScalar; @@ -38,6 +45,12 @@ contract DeployChain { address gasToken; } + struct AddressConfiguration { + address batcher; + address proposer; + address unsafeBlockSigner; + } + struct Hashes { bytes32 configHash; bytes32 genesisOutputRoot; @@ -100,32 +113,17 @@ contract DeployChain { function deploy( uint256 chainID, - uint64 genesisL1Number, - bytes32 genesisL2Hash, - bytes32 genesisL2StateRoot, - uint64 genesisL2Time, + GenesisConfiguration memory genesisConfig, GasConfiguration memory gasConfig, - address batcherAddress, - address unsafeBlockSigner, - address proposer + AddressConfiguration memory addressConfig ) external { DeployAddresses memory addresses = setupProxies(chainID); - bytes32 genesisL1Hash = blockhash(uint256(genesisL1Number)); - - Hashes memory hashes = calculateHashes( - chainID, - genesisL1Hash, - genesisL2Hash, - genesisL2StateRoot, - genesisL2Time, - gasConfig, - batcherAddress, - addresses - ); + + Hashes memory hashes = calculateHashes(chainID, genesisConfig, gasConfig, addressConfig.batcher, addresses); address batchInbox = calculateBatchInbox(chainID); - initializeProxies(gasConfig, batcherAddress, unsafeBlockSigner, batchInbox, proposer, hashes, addresses); + initializeProxies(gasConfig, addressConfig, batchInbox, hashes, addresses); emit Deploy({ chainID: chainID, @@ -163,14 +161,12 @@ contract DeployChain { function calculateHashes( uint256 chainID, - bytes32 genesisL1Hash, - bytes32 genesisL2Hash, - bytes32 genesisL2StateRoot, - uint64 genesisL2Time, + GenesisConfiguration memory genesisConfig, GasConfiguration memory gasConfig, address batcherAddress, DeployAddresses memory addresses - ) internal pure returns (Hashes memory) { + ) internal view returns (Hashes memory) { + bytes32 genesisL1Hash = blockhash(uint256(genesisConfig.l1Number)); bytes32 scalar = bytes32((uint256(0x01) << 248) | (uint256(gasConfig.blobbasefeeScalar) << 32) | gasConfig.basefeeScalar); @@ -179,8 +175,8 @@ contract DeployChain { uint64(0), // version chainID, genesisL1Hash, - genesisL2Hash, - genesisL2Time, + genesisConfig.l2Hash, + genesisConfig.l2Time, batcherAddress, scalar, gasConfig.gasLimit, @@ -192,9 +188,9 @@ contract DeployChain { bytes32 genesisOutputRoot = Hashing.hashOutputRootProof( Types.OutputRootProof({ version: 0, - stateRoot: genesisL2StateRoot, + stateRoot: genesisConfig.l2StateRoot, messagePasserStorageRoot: MESSAGE_PASSER_STORAGE_HASH, - latestBlockhash: genesisL2Hash + latestBlockhash: genesisConfig.l2Hash }) ); @@ -203,19 +199,11 @@ contract DeployChain { function initializeProxies( GasConfiguration memory gasConfig, - address batcherAddress, - address unsafeBlockSigner, + AddressConfiguration memory addressConfig, address batchInbox, - address proposer, Hashes memory hashes, DeployAddresses memory addresses ) internal { - _initializeOracles(addresses, hashes); - _initializeSystemConfig(addresses, gasConfig, batcherAddress, unsafeBlockSigner, batchInbox, proposer); - _initializeBridges(addresses); - } - - function _initializeOracles(DeployAddresses memory addresses, Hashes memory hashes) private { OutputOracle(addresses.l2OutputOracle).initialize( SystemConfigOwnable(addresses.systemConfig), hashes.configHash, hashes.genesisOutputRoot ); @@ -225,48 +213,21 @@ contract DeployChain { ISystemConfig(addresses.systemConfig), ISuperchainConfig(superchainConfig) ); - } - function _initializeSystemConfig( - DeployAddresses memory addresses, - GasConfiguration memory gasConfig, - address batcherAddress, - address unsafeBlockSigner, - address batchInbox, - address proposer - ) private { SystemConfig.Addresses memory systemAddresses = _createSystemAddresses(addresses, gasConfig.gasToken); SystemConfigOwnable(addresses.systemConfig).initialize({ _basefeeScalar: gasConfig.basefeeScalar, _blobbasefeeScalar: gasConfig.blobbasefeeScalar, - _batcherHash: bytes32(uint256(uint160(batcherAddress))), + _batcherHash: bytes32(uint256(uint160(addressConfig.batcher))), _gasLimit: gasConfig.gasLimit, - _unsafeBlockSigner: unsafeBlockSigner, + _unsafeBlockSigner: addressConfig.unsafeBlockSigner, _config: Constants.DEFAULT_RESOURCE_CONFIG(), _batchInbox: batchInbox, - _proposer: proposer, + _proposer: addressConfig.proposer, _addresses: systemAddresses }); - } - function _createSystemAddresses(DeployAddresses memory addresses, address gasToken) - private - pure - returns (SystemConfig.Addresses memory) - { - return SystemConfig.Addresses({ - l1CrossDomainMessenger: addresses.l1CrossDomainMessenger, - l1ERC721Bridge: addresses.l1ERC721Bridge, - l1StandardBridge: addresses.l1StandardBridge, - disputeGameFactory: address(0), - optimismPortal: addresses.optimismPortal, - optimismMintableERC20Factory: addresses.optimismMintableERC20Factory, - gasPayingToken: gasToken - }); - } - - function _initializeBridges(DeployAddresses memory addresses) private { L1CrossDomainMessenger(addresses.l1CrossDomainMessenger).initialize( ISuperchainConfig(superchainConfig), IOptimismPortal(payable(addresses.optimismPortal)), @@ -286,6 +247,22 @@ contract DeployChain { OptimismMintableERC20Factory(addresses.optimismMintableERC20Factory).initialize(addresses.l1StandardBridge); } + function _createSystemAddresses(DeployAddresses memory addresses, address gasToken) + private + pure + returns (SystemConfig.Addresses memory) + { + return SystemConfig.Addresses({ + l1CrossDomainMessenger: addresses.l1CrossDomainMessenger, + l1ERC721Bridge: addresses.l1ERC721Bridge, + l1StandardBridge: addresses.l1StandardBridge, + disputeGameFactory: address(0), + optimismPortal: addresses.optimismPortal, + optimismMintableERC20Factory: addresses.optimismMintableERC20Factory, + gasPayingToken: gasToken + }); + } + function setupProxy(address proxy, bytes32 salt) internal returns (address instance) { address _proxyAdmin = proxyAdmin; /// @solidity memory-safe-assembly diff --git a/testnet/genesis.go b/testnet/genesis.go index 3e4e17e..8744848 100644 --- a/testnet/genesis.go +++ b/testnet/genesis.go @@ -398,24 +398,30 @@ func Main(cliCtx *cli.Context) error { }, } + genesisCfg := bindings.DeployChainGenesisConfiguration{ + L1Number: l1Header.Number.Uint64(), + L2Hash: genesisBlock.Hash(), + L2StateRoot: genesisBlock.Root(), + L2Time: l2Genesis.Timestamp, + } gasConfig := bindings.DeployChainGasConfiguration{ BasefeeScalar: config.GasPriceOracleBaseFeeScalar, BlobbasefeeScalar: config.GasPriceOracleBlobBaseFeeScalar, GasLimit: uint64(config.L2GenesisBlockGasLimit), GasToken: config.CustomGasTokenAddress, } + addressConfig := bindings.DeployChainAddressConfiguration{ + Batcher: config.BatchSenderAddress, + Proposer: config.L2OutputOracleProposer, + UnsafeBlockSigner: config.P2PSequencerAddress, + } tx, err := deployChain.Deploy( opts, l2ChainID, - l1Header.Number.Uint64(), - genesisBlock.Hash(), - genesisBlock.Root(), - l2Genesis.Timestamp, + genesisCfg, gasConfig, - config.BatchSenderAddress, - config.P2PSequencerAddress, - config.L2OutputOracleProposer, + addressConfig, ) if err != nil { return fmt.Errorf("failed to deploy proxies: %w", err)