Only apply overrides to stored config of a private chain (#4521)

This commit is contained in:
Andrew Ashikhmin 2022-06-23 10:41:15 +02:00 committed by GitHub
parent 1c4584b438
commit 70bd93c5c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -271,10 +271,17 @@ func WriteGenesisBlock(db kv.RwTx, genesis *Genesis, overrideMergeNetsplitBlock,
} }
return newCfg, storedBlock, nil return newCfg, storedBlock, nil
} }
// Special case: don't change the existing config of an unknown chain if no new // Special case: don't change the existing config of a private chain if no new
// config is supplied. This is useful, for example, to preserve DB config created by erigon init. // config is supplied. This is useful, for example, to preserve DB config created by erigon init.
if genesis == nil && params.ChainConfigByGenesisHash(storedHash) == nil && overrideMergeNetsplitBlock == nil && overrideTerminalTotalDifficulty == nil { // In that case, only apply the overrides.
return storedCfg, storedBlock, nil if genesis == nil && params.ChainConfigByGenesisHash(storedHash) == nil {
newCfg = storedCfg
if overrideMergeNetsplitBlock != nil {
newCfg.MergeNetsplitBlock = overrideMergeNetsplitBlock
}
if overrideTerminalTotalDifficulty != nil {
newCfg.TerminalTotalDifficulty = overrideTerminalTotalDifficulty
}
} }
// Check config compatibility and write the config. Compatibility errors // Check config compatibility and write the config. Compatibility errors
// are returned to the caller unless we're already at block zero. // are returned to the caller unless we're already at block zero.