-
Notifications
You must be signed in to change notification settings - Fork 21.9k
core: don't overwrite stored chain config with default based on genesis hash #32556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 thenUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.