Skip to content

Commit 0ad3362

Browse files
committed
core: don't overwrite stored chain config with default based on genesis hash
1 parent b381804 commit 0ad3362

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

core/genesis.go

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,12 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
364364
if head == nil {
365365
return nil, common.Hash{}, nil, errors.New("missing head header")
366366
}
367-
newCfg := genesis.chainConfigOrDefault(ghash, storedCfg)
367+
// The new config is sourced either directly from provided Genesis or by
368+
// applying overrides to the stored config.
369+
newCfg := storedCfg
370+
if genesis != nil {
371+
newCfg = genesis.Config
372+
}
368373
if err := overrides.apply(newCfg); err != nil {
369374
return nil, common.Hash{}, nil, err
370375
}
@@ -423,26 +428,6 @@ func LoadChainConfig(db ethdb.Database, genesis *Genesis) (cfg *params.ChainConf
423428
return params.MainnetChainConfig, params.MainnetGenesisHash, nil
424429
}
425430

426-
// chainConfigOrDefault retrieves the attached chain configuration. If the genesis
427-
// object is null, it returns the default chain configuration based on the given
428-
// genesis hash, or the locally stored config if it's not a pre-defined network.
429-
func (g *Genesis) chainConfigOrDefault(ghash common.Hash, stored *params.ChainConfig) *params.ChainConfig {
430-
switch {
431-
case g != nil:
432-
return g.Config
433-
case ghash == params.MainnetGenesisHash:
434-
return params.MainnetChainConfig
435-
case ghash == params.HoleskyGenesisHash:
436-
return params.HoleskyChainConfig
437-
case ghash == params.SepoliaGenesisHash:
438-
return params.SepoliaChainConfig
439-
case ghash == params.HoodiGenesisHash:
440-
return params.HoodiChainConfig
441-
default:
442-
return stored
443-
}
444-
}
445-
446431
// IsVerkle indicates whether the state is already stored in a verkle
447432
// tree at genesis time.
448433
func (g *Genesis) IsVerkle() bool {

0 commit comments

Comments
 (0)