core: don't overwrite stored chain config with default based on genesis hash

This commit is contained in:
lightclient 2025-09-08 13:41:24 -06:00
parent 2872242045
commit a49766cb23
No known key found for this signature in database
GPG key ID: 657913021EF45A6A

View file

@ -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 {