From a49766cb23f827dde1eb694c462b4788bf9cc0b6 Mon Sep 17 00:00:00 2001 From: lightclient Date: Mon, 8 Sep 2025 13:41:24 -0600 Subject: [PATCH] core: don't overwrite stored chain config with default based on genesis hash --- core/genesis.go | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/core/genesis.go b/core/genesis.go index 13d4addd7e..9cf56e96cc 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -364,7 +364,12 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g if head == nil { return nil, common.Hash{}, nil, errors.New("missing head header") } - newCfg := genesis.chainConfigOrDefault(ghash, storedCfg) + // The new config is sourced either directly from provided Genesis or by + // applying overrides to the stored config. + newCfg := storedCfg + if genesis != nil { + newCfg = genesis.Config + } if err := overrides.apply(newCfg); err != nil { return nil, common.Hash{}, nil, err } @@ -423,26 +428,6 @@ func LoadChainConfig(db ethdb.Database, genesis *Genesis) (cfg *params.ChainConf return params.MainnetChainConfig, params.MainnetGenesisHash, nil } -// chainConfigOrDefault retrieves the attached chain configuration. If the genesis -// object is null, it returns the default chain configuration based on the given -// genesis hash, or the locally stored config if it's not a pre-defined network. -func (g *Genesis) chainConfigOrDefault(ghash common.Hash, stored *params.ChainConfig) *params.ChainConfig { - switch { - case g != nil: - return g.Config - case ghash == params.MainnetGenesisHash: - return params.MainnetChainConfig - case ghash == params.HoleskyGenesisHash: - return params.HoleskyChainConfig - case ghash == params.SepoliaGenesisHash: - return params.SepoliaChainConfig - case ghash == params.HoodiGenesisHash: - return params.HoodiChainConfig - default: - return stored - } -} - // IsVerkle indicates whether the state is already stored in a verkle // tree at genesis time. func (g *Genesis) IsVerkle() bool {