Commit d28ff52e authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #3921 from ethereum-optimism/fix/more-config-cleanup

fix: more config cleanup
parents 8ddb6997 74e054dd
...@@ -79,8 +79,8 @@ func TestBedrockIndexer(t *testing.T) { ...@@ -79,8 +79,8 @@ func TestBedrockIndexer(t *testing.T) {
RESTPort: 7980, RESTPort: 7980,
DisableIndexer: false, DisableIndexer: false,
Bedrock: true, Bedrock: true,
BedrockL1StandardBridgeAddress: predeploys.DevL1StandardBridgeAddr, BedrockL1StandardBridgeAddress: cfg.DeployConfig.L1StandardBridgeProxy,
BedrockOptimismPortalAddress: predeploys.DevOptimismPortalAddr, BedrockOptimismPortalAddress: cfg.DeployConfig.OptimismPortalProxy,
} }
idxr, err := indexer.NewIndexer(idxrCfg) idxr, err := indexer.NewIndexer(idxrCfg)
require.NoError(t, err) require.NoError(t, err)
......
...@@ -152,18 +152,8 @@ func main() { ...@@ -152,18 +152,8 @@ func main() {
return err return err
} }
l2Addrs := genesis.L2Addresses{
ProxyAdminOwner: config.ProxyAdminOwner,
L1StandardBridgeProxy: config.L1StandardBridgeProxy,
L1CrossDomainMessengerProxy: config.L1CrossDomainMessengerProxy,
L1ERC721BridgeProxy: config.L1ERC721BridgeProxy,
BaseFeeVaultRecipient: config.BaseFeeVaultRecipient,
L1FeeVaultRecipient: config.L1FeeVaultRecipient,
SequencerFeeVaultRecipient: config.SequencerFeeVaultRecipient,
}
dryRun := ctx.Bool("dry-run") dryRun := ctx.Bool("dry-run")
if err := genesis.MigrateDB(ldb, config, block, &l2Addrs, &migrationData, !dryRun); err != nil { if err := genesis.MigrateDB(ldb, config, block, &migrationData, !dryRun); err != nil {
return err return err
} }
......
...@@ -173,19 +173,19 @@ func (d *DeployConfig) Check() error { ...@@ -173,19 +173,19 @@ func (d *DeployConfig) Check() error {
log.Warn("GasPriceOracleScalar is address(0)") log.Warn("GasPriceOracleScalar is address(0)")
} }
if d.L1StandardBridgeProxy == (common.Address{}) { if d.L1StandardBridgeProxy == (common.Address{}) {
log.Warn("L1StandardBridgeProxy is address(0)") return fmt.Errorf("%w: L1StandardBridgeProxy cannot be address(0)", ErrInvalidDeployConfig)
} }
if d.L1CrossDomainMessengerProxy == (common.Address{}) { if d.L1CrossDomainMessengerProxy == (common.Address{}) {
log.Warn("L1CrossDomainMessengerProxy is address(0)") return fmt.Errorf("%w: L1CrossDomainMessengerProxy cannot be address(0)", ErrInvalidDeployConfig)
} }
if d.L1ERC721BridgeProxy == (common.Address{}) { if d.L1ERC721BridgeProxy == (common.Address{}) {
log.Warn("L1ERC721BridgeProxy is address(0)") return fmt.Errorf("%w: L1ERC721BridgeProxy cannot be address(0)", ErrInvalidDeployConfig)
} }
if d.SystemConfigProxy == (common.Address{}) { if d.SystemConfigProxy == (common.Address{}) {
log.Warn("SystemConfigProxy is address(0)") return fmt.Errorf("%w: SystemConfigProxy cannot be address(0)", ErrInvalidDeployConfig)
} }
if d.OptimismPortalProxy == (common.Address{}) { if d.OptimismPortalProxy == (common.Address{}) {
log.Warn("OptimismPortalProxy is address(0)") return fmt.Errorf("%w: OptimismPortalProxy cannot be address(0)", ErrInvalidDeployConfig)
} }
return nil return nil
} }
...@@ -249,6 +249,16 @@ func (d *DeployConfig) GetDeployedAddresses(hh *hardhat.Hardhat) error { ...@@ -249,6 +249,16 @@ func (d *DeployConfig) GetDeployedAddresses(hh *hardhat.Hardhat) error {
return nil return nil
} }
// InitDeveloperDeployedAddresses will set the dev addresses on the DeployConfig
func (d *DeployConfig) InitDeveloperDeployedAddresses() error {
d.L1StandardBridgeProxy = predeploys.DevL1StandardBridgeAddr
d.L1CrossDomainMessengerProxy = predeploys.DevL1CrossDomainMessengerAddr
d.L1ERC721BridgeProxy = predeploys.DevL1ERC721BridgeAddr
d.OptimismPortalProxy = predeploys.DevOptimismPortalAddr
d.SystemConfigProxy = predeploys.DevSystemConfigAddr
return nil
}
// NewDeployConfig reads a config file given a path on the filesystem. // NewDeployConfig reads a config file given a path on the filesystem.
func NewDeployConfig(path string) (*DeployConfig, error) { func NewDeployConfig(path string) (*DeployConfig, error) {
file, err := os.ReadFile(path) file, err := os.ReadFile(path)
...@@ -274,39 +284,35 @@ func NewDeployConfigWithNetwork(network, path string) (*DeployConfig, error) { ...@@ -274,39 +284,35 @@ func NewDeployConfigWithNetwork(network, path string) (*DeployConfig, error) {
// NewL2ImmutableConfig will create an ImmutableConfig given an instance of a // NewL2ImmutableConfig will create an ImmutableConfig given an instance of a
// Hardhat and a DeployConfig. // Hardhat and a DeployConfig.
func NewL2ImmutableConfig(config *DeployConfig, block *types.Block, l2Addrs *L2Addresses) (immutables.ImmutableConfig, error) { func NewL2ImmutableConfig(config *DeployConfig, block *types.Block) (immutables.ImmutableConfig, error) {
immutable := make(immutables.ImmutableConfig) immutable := make(immutables.ImmutableConfig)
if l2Addrs == nil { if config.L1ERC721BridgeProxy == (common.Address{}) {
return immutable, errors.New("must pass L1 contract addresses")
}
if l2Addrs.L1ERC721BridgeProxy == (common.Address{}) {
return immutable, errors.New("L1ERC721BridgeProxy cannot be address(0)") return immutable, errors.New("L1ERC721BridgeProxy cannot be address(0)")
} }
immutable["L2StandardBridge"] = immutables.ImmutableValues{ immutable["L2StandardBridge"] = immutables.ImmutableValues{
"otherBridge": l2Addrs.L1StandardBridgeProxy, "otherBridge": config.L1StandardBridgeProxy,
} }
immutable["L2CrossDomainMessenger"] = immutables.ImmutableValues{ immutable["L2CrossDomainMessenger"] = immutables.ImmutableValues{
"otherMessenger": l2Addrs.L1CrossDomainMessengerProxy, "otherMessenger": config.L1CrossDomainMessengerProxy,
} }
immutable["L2ERC721Bridge"] = immutables.ImmutableValues{ immutable["L2ERC721Bridge"] = immutables.ImmutableValues{
"messenger": predeploys.L2CrossDomainMessengerAddr, "messenger": predeploys.L2CrossDomainMessengerAddr,
"otherBridge": l2Addrs.L1ERC721BridgeProxy, "otherBridge": config.L1ERC721BridgeProxy,
} }
immutable["OptimismMintableERC721Factory"] = immutables.ImmutableValues{ immutable["OptimismMintableERC721Factory"] = immutables.ImmutableValues{
"bridge": predeploys.L2ERC721BridgeAddr, "bridge": predeploys.L2ERC721BridgeAddr,
"remoteChainId": new(big.Int).SetUint64(config.L1ChainID), "remoteChainId": new(big.Int).SetUint64(config.L1ChainID),
} }
immutable["SequencerFeeVault"] = immutables.ImmutableValues{ immutable["SequencerFeeVault"] = immutables.ImmutableValues{
"recipient": l2Addrs.SequencerFeeVaultRecipient, "recipient": config.SequencerFeeVaultRecipient,
} }
immutable["L1FeeVault"] = immutables.ImmutableValues{ immutable["L1FeeVault"] = immutables.ImmutableValues{
"recipient": l2Addrs.L1FeeVaultRecipient, "recipient": config.L1FeeVaultRecipient,
} }
immutable["BaseFeeVault"] = immutables.ImmutableValues{ immutable["BaseFeeVault"] = immutables.ImmutableValues{
"recipient": l2Addrs.BaseFeeVaultRecipient, "recipient": config.BaseFeeVaultRecipient,
} }
return immutable, nil return immutable, nil
...@@ -314,7 +320,7 @@ func NewL2ImmutableConfig(config *DeployConfig, block *types.Block, l2Addrs *L2A ...@@ -314,7 +320,7 @@ func NewL2ImmutableConfig(config *DeployConfig, block *types.Block, l2Addrs *L2A
// NewL2StorageConfig will create a StorageConfig given an instance of a // NewL2StorageConfig will create a StorageConfig given an instance of a
// Hardhat and a DeployConfig. // Hardhat and a DeployConfig.
func NewL2StorageConfig(config *DeployConfig, block *types.Block, l2Addrs *L2Addresses) (state.StorageConfig, error) { func NewL2StorageConfig(config *DeployConfig, block *types.Block) (state.StorageConfig, error) {
storage := make(state.StorageConfig) storage := make(state.StorageConfig)
if block.Number() == nil { if block.Number() == nil {
...@@ -323,9 +329,6 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block, l2Addrs *L2Add ...@@ -323,9 +329,6 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block, l2Addrs *L2Add
if block.BaseFee() == nil { if block.BaseFee() == nil {
return storage, errors.New("block base fee not set") return storage, errors.New("block base fee not set")
} }
if l2Addrs == nil {
return storage, errors.New("must pass L1 address info")
}
storage["L2ToL1MessagePasser"] = state.StorageValues{ storage["L2ToL1MessagePasser"] = state.StorageValues{
"nonce": 0, "nonce": 0,
...@@ -368,7 +371,7 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block, l2Addrs *L2Add ...@@ -368,7 +371,7 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block, l2Addrs *L2Add
"_owner": common.Address{}, "_owner": common.Address{},
} }
storage["ProxyAdmin"] = state.StorageValues{ storage["ProxyAdmin"] = state.StorageValues{
"_owner": l2Addrs.ProxyAdminOwner, "_owner": config.ProxyAdminOwner,
} }
return storage, nil return storage, nil
} }
...@@ -20,7 +20,7 @@ import ( ...@@ -20,7 +20,7 @@ import (
var abiTrue = common.Hash{31: 0x01} var abiTrue = common.Hash{31: 0x01}
// MigrateDB will migrate an old l2geth database to the new bedrock style system // MigrateDB will migrate an old l2geth database to the new bedrock style system
func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, l2Addrs *L2Addresses, migrationData *migration.MigrationData, commit bool) error { func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, migrationData *migration.MigrationData, commit bool) error {
hash := rawdb.ReadHeadHeaderHash(ldb) hash := rawdb.ReadHeadHeaderHash(ldb)
num := rawdb.ReadHeaderNumber(ldb, hash) num := rawdb.ReadHeaderNumber(ldb, hash)
header := rawdb.ReadHeader(ldb, hash, *num) header := rawdb.ReadHeader(ldb, hash, *num)
...@@ -45,12 +45,12 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, l ...@@ -45,12 +45,12 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, l
return fmt.Errorf("cannot set L2Proxies: %w", err) return fmt.Errorf("cannot set L2Proxies: %w", err)
} }
storage, err := NewL2StorageConfig(config, l1Block, l2Addrs) storage, err := NewL2StorageConfig(config, l1Block)
if err != nil { if err != nil {
return fmt.Errorf("cannot create storage config: %w", err) return fmt.Errorf("cannot create storage config: %w", err)
} }
immutable, err := NewL2ImmutableConfig(config, l1Block, l2Addrs) immutable, err := NewL2ImmutableConfig(config, l1Block)
if err != nil { if err != nil {
return fmt.Errorf("cannot create immutable config: %w", err) return fmt.Errorf("cannot create immutable config: %w", err)
} }
...@@ -59,7 +59,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, l ...@@ -59,7 +59,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, l
return fmt.Errorf("cannot set implementations: %w", err) return fmt.Errorf("cannot set implementations: %w", err)
} }
err = crossdomain.MigrateWithdrawals(withdrawals, db, &l2Addrs.L1CrossDomainMessengerProxy, &l2Addrs.L1StandardBridgeProxy) err = crossdomain.MigrateWithdrawals(withdrawals, db, &config.L1CrossDomainMessengerProxy, &config.L1StandardBridgeProxy)
if err != nil { if err != nil {
return fmt.Errorf("cannot migrate withdrawals: %w", err) return fmt.Errorf("cannot migrate withdrawals: %w", err)
} }
......
package genesis package genesis
import ( import (
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/state" "github.com/ethereum-optimism/optimism/op-chain-ops/state"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
) )
// L2Addresses represents L1 contract addresses
// that are required for the construction of an L2 state
type L2Addresses struct {
// ProxyAdminOwner represents the admin of the L2 ProxyAdmin predeploy
ProxyAdminOwner common.Address
// L1StandardBridgeProxy represents the L1 contract address of the L1StandardBridgeProxy
L1StandardBridgeProxy common.Address
// L1CrossDomainMessengerProxy represents the L1 contract address of the L1CrossDomainMessengerProxy
L1CrossDomainMessengerProxy common.Address
// L1ERC721BridgeProxy represents the L1 contract address of the L1ERC721BridgeProxy
L1ERC721BridgeProxy common.Address
// SequencerFeeVaultRecipient represents the L1 address that the SequencerFeeVault can withdraw to
SequencerFeeVaultRecipient common.Address
// L1FeeVaultRecipient represents the L1 address that the L1FeeVault can withdraw to
L1FeeVaultRecipient common.Address
// BaseFeeVaultRecipient represents the L1 address that the BaseFeeVault can withdraw to
BaseFeeVaultRecipient common.Address
// SystemConfigProxy represents the L1 contract address of the SystemConfigProxy
SystemConfigProxy common.Address
}
// BuildL2DeveloperGenesis will build the developer Optimism Genesis // BuildL2DeveloperGenesis will build the developer Optimism Genesis
// Block. Suitable for devnets. // Block. Suitable for devnets.
func BuildL2DeveloperGenesis(config *DeployConfig, l1StartBlock *types.Block, l2Addrs *L2Addresses) (*core.Genesis, error) { func BuildL2DeveloperGenesis(config *DeployConfig, l1StartBlock *types.Block) (*core.Genesis, error) {
genspec, err := NewL2Genesis(config, l1StartBlock) genspec, err := NewL2Genesis(config, l1StartBlock)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -45,36 +22,21 @@ func BuildL2DeveloperGenesis(config *DeployConfig, l1StartBlock *types.Block, l2 ...@@ -45,36 +22,21 @@ func BuildL2DeveloperGenesis(config *DeployConfig, l1StartBlock *types.Block, l2
} }
SetPrecompileBalances(db) SetPrecompileBalances(db)
// Use the known developer addresses if they are not set return BuildL2Genesis(db, config, l1StartBlock)
if l2Addrs == nil {
l2Addrs = &L2Addresses{
L1StandardBridgeProxy: predeploys.DevL1StandardBridgeAddr,
L1CrossDomainMessengerProxy: predeploys.DevL1CrossDomainMessengerAddr,
L1ERC721BridgeProxy: predeploys.DevL1ERC721BridgeAddr,
SystemConfigProxy: predeploys.DevSystemConfigAddr,
// Hardcoded address corresponds to m/44'/60'/0'/0/1 in the 'test test... junk' mnemonic
ProxyAdminOwner: common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8"),
SequencerFeeVaultRecipient: common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8"),
L1FeeVaultRecipient: common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8"),
BaseFeeVaultRecipient: common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8"),
}
}
return BuildL2Genesis(db, config, l1StartBlock, l2Addrs)
} }
// BuildL2Genesis will build the L2 Optimism Genesis Block // BuildL2Genesis will build the L2 Optimism Genesis Block
func BuildL2Genesis(db *state.MemoryStateDB, config *DeployConfig, l1Block *types.Block, l2Addrs *L2Addresses) (*core.Genesis, error) { func BuildL2Genesis(db *state.MemoryStateDB, config *DeployConfig, l1Block *types.Block) (*core.Genesis, error) {
if err := SetL2Proxies(db); err != nil { if err := SetL2Proxies(db); err != nil {
return nil, err return nil, err
} }
storage, err := NewL2StorageConfig(config, l1Block, l2Addrs) storage, err := NewL2StorageConfig(config, l1Block)
if err != nil { if err != nil {
return nil, err return nil, err
} }
immutable, err := NewL2ImmutableConfig(config, l1Block, l2Addrs) immutable, err := NewL2ImmutableConfig(config, l1Block)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -42,7 +42,7 @@ func TestBuildL2DeveloperGenesis(t *testing.T) { ...@@ -42,7 +42,7 @@ func TestBuildL2DeveloperGenesis(t *testing.T) {
block, err := backend.BlockByNumber(context.Background(), common.Big0) block, err := backend.BlockByNumber(context.Background(), common.Big0)
require.NoError(t, err) require.NoError(t, err)
gen, err := genesis.BuildL2DeveloperGenesis(config, block, nil) gen, err := genesis.BuildL2DeveloperGenesis(config, block)
require.Nil(t, err) require.Nil(t, err)
require.NotNil(t, gen) require.NotNil(t, gen)
...@@ -78,6 +78,9 @@ func TestBuildL2DeveloperGenesisDevAccountsFunding(t *testing.T) { ...@@ -78,6 +78,9 @@ func TestBuildL2DeveloperGenesisDevAccountsFunding(t *testing.T) {
require.Nil(t, err) require.Nil(t, err)
config.FundDevAccounts = false config.FundDevAccounts = false
err = config.InitDeveloperDeployedAddresses()
require.NoError(t, err)
backend := backends.NewSimulatedBackend( backend := backends.NewSimulatedBackend(
core.GenesisAlloc{ core.GenesisAlloc{
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)}, crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
...@@ -87,7 +90,7 @@ func TestBuildL2DeveloperGenesisDevAccountsFunding(t *testing.T) { ...@@ -87,7 +90,7 @@ func TestBuildL2DeveloperGenesisDevAccountsFunding(t *testing.T) {
block, err := backend.BlockByNumber(context.Background(), common.Big0) block, err := backend.BlockByNumber(context.Background(), common.Big0)
require.NoError(t, err) require.NoError(t, err)
gen, err := genesis.BuildL2DeveloperGenesis(config, block, nil) gen, err := genesis.BuildL2DeveloperGenesis(config, block)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, 2321, len(gen.Alloc)) require.Equal(t, 2321, len(gen.Alloc))
} }
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"baseFeeVaultRecipient": "0xBcd4042DE499D14e55001CcbB24a551F3b954096", "baseFeeVaultRecipient": "0xBcd4042DE499D14e55001CcbB24a551F3b954096",
"l1FeeVaultRecipient": "0x71bE63f3384f5fb98995898A86B02Fb2426c5788", "l1FeeVaultRecipient": "0x71bE63f3384f5fb98995898A86B02Fb2426c5788",
"sequencerFeeVaultRecipient": "0x71bE63f3384f5fb98995898A86B02Fb2426c5788", "sequencerFeeVaultRecipient": "0x71bE63f3384f5fb98995898A86B02Fb2426c5788",
"l1ERC721BridgeProxy": "0xff000000000000000000000000000000000000ff",
"deploymentWaitConfirmations": 1, "deploymentWaitConfirmations": 1,
"fundDevAccounts": true "fundDevAccounts": true
......
...@@ -106,6 +106,13 @@ func MakeDeployParams(t require.TestingT, tp *TestParams) *DeployParams { ...@@ -106,6 +106,13 @@ func MakeDeployParams(t require.TestingT, tp *TestParams) *DeployParams {
FundDevAccounts: false, FundDevAccounts: false,
} }
// Configure the DeployConfig with the expected developer L1
// addresses.
if err := deployConfig.InitDeveloperDeployedAddresses(); err != nil {
panic(err)
}
return &DeployParams{ return &DeployParams{
DeployConfig: deployConfig, DeployConfig: deployConfig,
MnemonicConfig: mnemonicCfg, MnemonicConfig: mnemonicCfg,
...@@ -167,7 +174,7 @@ func Setup(t require.TestingT, deployParams *DeployParams, alloc *AllocParams) * ...@@ -167,7 +174,7 @@ func Setup(t require.TestingT, deployParams *DeployParams, alloc *AllocParams) *
l1Block := l1Genesis.ToBlock() l1Block := l1Genesis.ToBlock()
l2Genesis, err := genesis.BuildL2DeveloperGenesis(deployConf, l1Block, nil) l2Genesis, err := genesis.BuildL2DeveloperGenesis(deployConf, l1Block)
require.NoError(t, err, "failed to create l2 genesis") require.NoError(t, err, "failed to create l2 genesis")
if alloc.PrefundTestUsers { if alloc.PrefundTestUsers {
for _, addr := range deployParams.Addresses.All() { for _, addr := range deployParams.Addresses.All() {
......
...@@ -39,7 +39,7 @@ func TestMissingGasLimit(t *testing.T) { ...@@ -39,7 +39,7 @@ func TestMissingGasLimit(t *testing.T) {
require.Nil(t, err) require.Nil(t, err)
l1Block := l1Genesis.ToBlock() l1Block := l1Genesis.ToBlock()
l2Genesis, err := genesis.BuildL2DeveloperGenesis(cfg.DeployConfig, l1Block, nil) l2Genesis, err := genesis.BuildL2DeveloperGenesis(cfg.DeployConfig, l1Block)
require.Nil(t, err) require.Nil(t, err)
l2GenesisBlock := l2Genesis.ToBlock() l2GenesisBlock := l2Genesis.ToBlock()
...@@ -109,7 +109,7 @@ func TestInvalidDepositInFCU(t *testing.T) { ...@@ -109,7 +109,7 @@ func TestInvalidDepositInFCU(t *testing.T) {
require.Nil(t, err) require.Nil(t, err)
l1Block := l1Genesis.ToBlock() l1Block := l1Genesis.ToBlock()
l2Genesis, err := genesis.BuildL2DeveloperGenesis(cfg.DeployConfig, l1Block, nil) l2Genesis, err := genesis.BuildL2DeveloperGenesis(cfg.DeployConfig, l1Block)
require.Nil(t, err) require.Nil(t, err)
l2GenesisBlock := l2Genesis.ToBlock() l2GenesisBlock := l2Genesis.ToBlock()
......
...@@ -46,67 +46,73 @@ func DefaultSystemConfig(t *testing.T) SystemConfig { ...@@ -46,67 +46,73 @@ func DefaultSystemConfig(t *testing.T) SystemConfig {
require.NoError(t, err) require.NoError(t, err)
addresses := secrets.Addresses() addresses := secrets.Addresses()
deployConfig := &genesis.DeployConfig{
L1ChainID: 900,
L2ChainID: 901,
L2BlockTime: 2,
FinalizationPeriodSeconds: 60 * 60 * 24,
MaxSequencerDrift: 10,
SequencerWindowSize: 30,
ChannelTimeout: 10,
P2PSequencerAddress: addresses.SequencerP2P,
BatchInboxAddress: common.Address{0: 0x52, 19: 0xff}, // tbd
BatchSenderAddress: addresses.Batcher,
L2OutputOracleSubmissionInterval: 4,
L2OutputOracleStartingTimestamp: -1,
L2OutputOracleProposer: addresses.Proposer,
L2OutputOracleOwner: common.Address{}, // tbd
SystemConfigOwner: addresses.SysCfgOwner,
L1BlockTime: 2,
L1GenesisBlockNonce: 4660,
CliqueSignerAddress: addresses.CliqueSigner,
L1GenesisBlockTimestamp: hexutil.Uint64(time.Now().Unix()),
L1GenesisBlockGasLimit: 8_000_000,
L1GenesisBlockDifficulty: uint642big(1),
L1GenesisBlockMixHash: common.Hash{},
L1GenesisBlockCoinbase: common.Address{},
L1GenesisBlockNumber: 0,
L1GenesisBlockGasUsed: 0,
L1GenesisBlockParentHash: common.Hash{},
L1GenesisBlockBaseFeePerGas: uint642big(7),
L2GenesisBlockNonce: 0,
L2GenesisBlockExtraData: []byte{},
L2GenesisBlockGasLimit: 8_000_000,
L2GenesisBlockDifficulty: uint642big(1),
L2GenesisBlockMixHash: common.Hash{},
L2GenesisBlockCoinbase: common.Address{0: 0x12},
L2GenesisBlockNumber: 0,
L2GenesisBlockGasUsed: 0,
L2GenesisBlockParentHash: common.Hash{},
L2GenesisBlockBaseFeePerGas: uint642big(7),
L2CrossDomainMessengerOwner: common.Address{0: 0x52, 19: 0xf3}, // tbd
GasPriceOracleOverhead: 2100,
GasPriceOracleScalar: 1_000_000,
DeploymentWaitConfirmations: 1,
EIP1559Elasticity: 2,
EIP1559Denominator: 8,
FundDevAccounts: true,
}
if err := deployConfig.InitDeveloperDeployedAddresses(); err != nil {
panic(err)
}
return SystemConfig{ return SystemConfig{
Secrets: secrets, Secrets: secrets,
Premine: make(map[common.Address]*big.Int), Premine: make(map[common.Address]*big.Int),
DeployConfig: &genesis.DeployConfig{ DeployConfig: deployConfig,
L1ChainID: 900,
L2ChainID: 901,
L2BlockTime: 2,
FinalizationPeriodSeconds: 60 * 60 * 24,
MaxSequencerDrift: 10,
SequencerWindowSize: 30,
ChannelTimeout: 10,
P2PSequencerAddress: addresses.SequencerP2P,
BatchInboxAddress: common.Address{0: 0x52, 19: 0xff}, // tbd
BatchSenderAddress: addresses.Batcher,
L2OutputOracleSubmissionInterval: 4,
L2OutputOracleStartingTimestamp: -1,
L2OutputOracleProposer: addresses.Proposer,
L2OutputOracleOwner: common.Address{}, // tbd
SystemConfigOwner: addresses.SysCfgOwner,
L1BlockTime: 2,
L1GenesisBlockNonce: 4660,
CliqueSignerAddress: addresses.CliqueSigner,
L1GenesisBlockTimestamp: hexutil.Uint64(time.Now().Unix()),
L1GenesisBlockGasLimit: 8_000_000,
L1GenesisBlockDifficulty: uint642big(1),
L1GenesisBlockMixHash: common.Hash{},
L1GenesisBlockCoinbase: common.Address{},
L1GenesisBlockNumber: 0,
L1GenesisBlockGasUsed: 0,
L1GenesisBlockParentHash: common.Hash{},
L1GenesisBlockBaseFeePerGas: uint642big(7),
L2GenesisBlockNonce: 0,
L2GenesisBlockExtraData: []byte{},
L2GenesisBlockGasLimit: 8_000_000,
L2GenesisBlockDifficulty: uint642big(1),
L2GenesisBlockMixHash: common.Hash{},
L2GenesisBlockCoinbase: common.Address{0: 0x12},
L2GenesisBlockNumber: 0,
L2GenesisBlockGasUsed: 0,
L2GenesisBlockParentHash: common.Hash{},
L2GenesisBlockBaseFeePerGas: uint642big(7),
L2CrossDomainMessengerOwner: common.Address{0: 0x52, 19: 0xf3}, // tbd
GasPriceOracleOverhead: 2100,
GasPriceOracleScalar: 1_000_000,
DeploymentWaitConfirmations: 1,
EIP1559Elasticity: 2,
EIP1559Denominator: 8,
FundDevAccounts: true,
},
L1InfoPredeployAddress: predeploys.L1BlockAddr, L1InfoPredeployAddress: predeploys.L1BlockAddr,
JWTFilePath: writeDefaultJWT(t), JWTFilePath: writeDefaultJWT(t),
JWTSecret: testingJWTSecret, JWTSecret: testingJWTSecret,
...@@ -262,7 +268,7 @@ func (cfg SystemConfig) Start() (*System, error) { ...@@ -262,7 +268,7 @@ func (cfg SystemConfig) Start() (*System, error) {
} }
l1Block := l1Genesis.ToBlock() l1Block := l1Genesis.ToBlock()
l2Genesis, err := genesis.BuildL2DeveloperGenesis(cfg.DeployConfig, l1Block, nil) l2Genesis, err := genesis.BuildL2DeveloperGenesis(cfg.DeployConfig, l1Block)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -17,7 +17,6 @@ import ( ...@@ -17,7 +17,6 @@ import (
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum-optimism/optimism/op-bindings/hardhat" "github.com/ethereum-optimism/optimism/op-bindings/hardhat"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis" "github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup" "github.com/ethereum-optimism/optimism/op-node/rollup"
...@@ -52,6 +51,11 @@ var Subcommands = cli.Commands{ ...@@ -52,6 +51,11 @@ var Subcommands = cli.Commands{
return err return err
} }
// Add the developer L1 addresses to the config
if err := config.InitDeveloperDeployedAddresses(); err != nil {
return err
}
if err := config.Check(); err != nil { if err := config.Check(); err != nil {
return err return err
} }
...@@ -62,12 +66,15 @@ var Subcommands = cli.Commands{ ...@@ -62,12 +66,15 @@ var Subcommands = cli.Commands{
} }
l1StartBlock := l1Genesis.ToBlock() l1StartBlock := l1Genesis.ToBlock()
l2Genesis, err := genesis.BuildL2DeveloperGenesis(config, l1StartBlock, nil) l2Genesis, err := genesis.BuildL2DeveloperGenesis(config, l1StartBlock)
if err != nil { if err != nil {
return err return err
} }
rollupConfig := makeRollupConfig(config, l1StartBlock, l2Genesis, predeploys.DevOptimismPortalAddr, predeploys.DevSystemConfigAddr) rollupConfig, err := makeRollupConfig(config, l1StartBlock, l2Genesis)
if err != nil {
return err
}
if err := writeGenesisFile(ctx.String("outfile.l1"), l1Genesis); err != nil { if err := writeGenesisFile(ctx.String("outfile.l1"), l1Genesis); err != nil {
return err return err
...@@ -138,31 +145,24 @@ var Subcommands = cli.Commands{ ...@@ -138,31 +145,24 @@ var Subcommands = cli.Commands{
return err return err
} }
// Read the appropriate deployment addresses from disk
if err := config.GetDeployedAddresses(hh); err != nil { if err := config.GetDeployedAddresses(hh); err != nil {
return err return err
} }
// Sanity check the config
if err := config.Check(); err != nil { if err := config.Check(); err != nil {
return err return err
} }
// Build the developer L2 genesis block
// TODO: delete this struct as everything is now in the DeployConfig l2Genesis, err := genesis.BuildL2DeveloperGenesis(config, l1StartBlock)
l2Addrs := &genesis.L2Addresses{
ProxyAdminOwner: config.ProxyAdminOwner,
L1StandardBridgeProxy: config.L1StandardBridgeProxy,
L1CrossDomainMessengerProxy: config.L1CrossDomainMessengerProxy,
L1ERC721BridgeProxy: config.L1ERC721BridgeProxy,
BaseFeeVaultRecipient: config.BaseFeeVaultRecipient,
L1FeeVaultRecipient: config.L1FeeVaultRecipient,
SequencerFeeVaultRecipient: config.SequencerFeeVaultRecipient,
SystemConfigProxy: config.SystemConfigProxy,
}
l2Genesis, err := genesis.BuildL2DeveloperGenesis(config, l1StartBlock, l2Addrs)
if err != nil { if err != nil {
return fmt.Errorf("error creating l2 developer genesis: %w", err) return fmt.Errorf("error creating l2 developer genesis: %w", err)
} }
rollupConfig := makeRollupConfig(config, l1StartBlock, l2Genesis, config.OptimismPortalProxy, config.SystemConfigProxy) rollupConfig, err := makeRollupConfig(config, l1StartBlock, l2Genesis)
if err != nil {
return err
}
if err := rollupConfig.Check(); err != nil { if err := rollupConfig.Check(); err != nil {
return fmt.Errorf("generated rollup config does not pass validation: %w", err) return fmt.Errorf("generated rollup config does not pass validation: %w", err)
} }
...@@ -175,13 +175,14 @@ var Subcommands = cli.Commands{ ...@@ -175,13 +175,14 @@ var Subcommands = cli.Commands{
}, },
} }
func makeRollupConfig( func makeRollupConfig(config *genesis.DeployConfig, l1StartBlock *types.Block, l2Genesis *core.Genesis) (*rollup.Config, error) {
config *genesis.DeployConfig, if config.OptimismPortalProxy == (common.Address{}) {
l1StartBlock *types.Block, return nil, errors.New("OptimismPortalProxy cannot be address(0)")
l2Genesis *core.Genesis, }
portalAddr common.Address, if config.SystemConfigProxy == (common.Address{}) {
sysConfigAddr common.Address, return nil, errors.New("SystemConfigProxy cannot be address(0)")
) *rollup.Config { }
return &rollup.Config{ return &rollup.Config{
Genesis: rollup.Genesis{ Genesis: rollup.Genesis{
L1: eth.BlockID{ L1: eth.BlockID{
...@@ -208,9 +209,9 @@ func makeRollupConfig( ...@@ -208,9 +209,9 @@ func makeRollupConfig(
L2ChainID: new(big.Int).SetUint64(config.L2ChainID), L2ChainID: new(big.Int).SetUint64(config.L2ChainID),
P2PSequencerAddress: config.P2PSequencerAddress, P2PSequencerAddress: config.P2PSequencerAddress,
BatchInboxAddress: config.BatchInboxAddress, BatchInboxAddress: config.BatchInboxAddress,
DepositContractAddress: portalAddr, DepositContractAddress: config.OptimismPortalProxy,
L1SystemConfigAddress: sysConfigAddr, L1SystemConfigAddress: config.SystemConfigProxy,
} }, nil
} }
func writeGenesisFile(outfile string, input interface{}) error { func writeGenesisFile(outfile string, input interface{}) error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment