Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
cfg.Miner.GasPrice = big.NewInt(1)
}
default:
cfg.Genesis = core.DefaultGenesisBlock()
if cfg.NetworkId == 1 {
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
}
Expand Down
27 changes: 6 additions & 21 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It breaks the auto-upgrade for mainnet.

(a) the chain config was persisted with old geth version, e.g., osaka at time-x;
(b) a new geth is release then with osaka at time-y;
(c) the node is launched without network == mainnet, the genesis object here is nil, the chain config won't be overridden then

Copy link
Copy Markdown
Member Author

@lightclient lightclient Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I fixed it in cbff538.

newCfg = genesis.Config
}
if err := overrides.apply(newCfg); err != nil {
return nil, common.Hash{}, nil, err
}
Expand Down Expand Up @@ -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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we check the stored config before all the default configs?

e.g.,

diff --git a/core/genesis.go b/core/genesis.go
index 2673334e9e..95c31c6279 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -430,6 +430,8 @@ func (g *Genesis) chainConfigOrDefault(ghash common.Hash, stored *params.ChainCo
 	switch {
 	case g != nil:
 		return g.Config
+	case stored != nil:
+		return stored
 	case ghash == params.MainnetGenesisHash:
 		return params.MainnetChainConfig
 	case ghash == params.HoleskyGenesisHash:
@@ -439,7 +441,7 @@ func (g *Genesis) chainConfigOrDefault(ghash common.Hash, stored *params.ChainCo
 	case ghash == params.HoodiGenesisHash:
 		return params.HoodiChainConfig
 	default:
-		return stored
+		return nil
 	}
 }
 

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 {
Expand Down
Loading