diff --git a/core/genesis.go b/core/genesis.go index 65b9aa8aad..db52a157d7 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -183,21 +183,6 @@ func SetupGenesisBlock( if genesis.Config == nil { return nil, common.Hash{}, errGenesisNoConfig } - // Make sure genesis gas limit is consistent in SubnetEVM fork - if genesis.Config.IsSubnetEVM(genesis.Timestamp) { - gasLimitConfig := genesis.Config.FeeConfig.GasLimit.Uint64() - if gasLimitConfig != genesis.GasLimit { - return nil, common.Hash{}, fmt.Errorf( - "gas limit in fee config (%d) does not match gas limit in header (%d)", - gasLimitConfig, - genesis.GasLimit, - ) - } - // Verify config - if err := genesis.Config.Verify(); err != nil { - return nil, common.Hash{}, err - } - } // Just commit the new block if there is no stored genesis block. stored := rawdb.ReadCanonicalHash(db, 0) @@ -396,6 +381,23 @@ func (g *Genesis) MustCommit(db ethdb.Database) *types.Block { return block } +func (g *Genesis) Verify() error { + // Make sure genesis gas limit is consistent + gasLimitConfig := g.Config.FeeConfig.GasLimit.Uint64() + if gasLimitConfig != g.GasLimit { + return fmt.Errorf( + "gas limit in fee config (%d) does not match gas limit in header (%d)", + gasLimitConfig, + g.GasLimit, + ) + } + // Verify config + if err := g.Config.Verify(); err != nil { + return err + } + return nil +} + // GenesisBlockForTesting creates and writes a block in which addr has the given wei balance. func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big.Int) *types.Block { g := Genesis{ diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index b55907f594..f5afc1f13f 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -314,6 +314,10 @@ func (vm *VM) Initialize( g.Config.FeeConfig = params.DefaultFeeConfig } + if err := g.Verify(); err != nil { + return fmt.Errorf("failed to verify genesis: %w", err) + } + vm.ethConfig = ethconfig.NewDefaultConfig() vm.ethConfig.Genesis = g // NetworkID here is different than Avalanche's NetworkID.