-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
core: fix when db empty on startup overrides for TTD and gray glacier do not work #25146
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,6 +250,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override | |
if err != nil { | ||
return genesis.Config, common.Hash{}, err | ||
} | ||
performConfigOverride(genesis.Config, overrideGrayGlacier, overrideTerminalTotalDifficulty) | ||
return genesis.Config, block.Hash(), nil | ||
} | ||
// We have the genesis block in database(perhaps in ancient database) | ||
|
@@ -279,12 +280,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override | |
} | ||
// Get the existing chain configuration. | ||
newcfg := genesis.configOrDefault(stored) | ||
if overrideGrayGlacier != nil { | ||
newcfg.GrayGlacierBlock = overrideGrayGlacier | ||
} | ||
if overrideTerminalTotalDifficulty != nil { | ||
newcfg.TerminalTotalDifficulty = overrideTerminalTotalDifficulty | ||
} | ||
performConfigOverride(newcfg, overrideGrayGlacier, overrideTerminalTotalDifficulty) | ||
if err := newcfg.CheckConfigForkOrder(); err != nil { | ||
return newcfg, common.Hash{}, err | ||
} | ||
|
@@ -301,12 +297,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override | |
// apply the overrides. | ||
if genesis == nil && stored != params.MainnetGenesisHash { | ||
newcfg = storedcfg | ||
if overrideGrayGlacier != nil { | ||
newcfg.GrayGlacierBlock = overrideGrayGlacier | ||
} | ||
if overrideTerminalTotalDifficulty != nil { | ||
newcfg.TerminalTotalDifficulty = overrideTerminalTotalDifficulty | ||
} | ||
performConfigOverride(newcfg, overrideGrayGlacier, overrideTerminalTotalDifficulty) | ||
} | ||
// Check config compatibility and write the config. Compatibility errors | ||
// are returned to the caller unless we're already at block zero. | ||
|
@@ -322,6 +313,15 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override | |
return newcfg, stored, nil | ||
} | ||
|
||
func performConfigOverride(cfg *params.ChainConfig, overrideGrayGlacier *big.Int, overrideTerminalTotalDifficulty *big.Int) { | ||
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. perhaps there is a better place for this function? should I make it a unexported method of 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. 0x62044d2cab405388891ee6d53747817f34c0f00341cde548c0ce9834e9718f27 |
||
if overrideGrayGlacier != nil { | ||
cfg.GrayGlacierBlock = overrideGrayGlacier | ||
} | ||
if overrideTerminalTotalDifficulty != nil { | ||
cfg.TerminalTotalDifficulty = overrideTerminalTotalDifficulty | ||
} | ||
} | ||
|
||
func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { | ||
switch { | ||
case g != nil: | ||
|
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.
perhaps we should clone genesis.Config before overriding it?
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.
0x62044d2cab405388891ee6d53747817f34c0f00341cde548c0ce9834e9718f27