Skip to content

Commit b45d82e

Browse files
committed
core: set ttd override on all chain variations
1 parent 0fffd3a commit b45d82e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

core/genesis.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override
282282
if overrideArrowGlacier != nil {
283283
newcfg.ArrowGlacierBlock = overrideArrowGlacier
284284
}
285+
if overrideTerminalTotalDifficulty != nil {
286+
newcfg.TerminalTotalDifficulty = overrideTerminalTotalDifficulty
287+
}
285288
if err := newcfg.CheckConfigForkOrder(); err != nil {
286289
return newcfg, common.Hash{}, err
287290
}
@@ -291,15 +294,19 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override
291294
rawdb.WriteChainConfig(db, stored, newcfg)
292295
return newcfg, stored, nil
293296
}
294-
295-
if overrideTerminalTotalDifficulty != nil {
296-
storedcfg.TerminalTotalDifficulty = overrideTerminalTotalDifficulty
297-
}
298-
// Special case: don't change the existing config of a non-mainnet chain if no new
299-
// config is supplied. These chains would get AllProtocolChanges (and a compat error)
300-
// if we just continued here.
297+
// Special case: if a private network is being used (no genesis and also no
298+
// mainnet hash in the database), we must not apply the `configOrDefault`
299+
// chain config as that would be AllProtocolChanges (applying any new fork
300+
// on top of an existing private network genesis block). In that case, only
301+
// apply the overrides.
301302
if genesis == nil && stored != params.MainnetGenesisHash {
302-
return storedcfg, stored, nil
303+
newcfg = storedcfg
304+
if overrideArrowGlacier != nil {
305+
newcfg.ArrowGlacierBlock = overrideArrowGlacier
306+
}
307+
if overrideTerminalTotalDifficulty != nil {
308+
newcfg.TerminalTotalDifficulty = overrideTerminalTotalDifficulty
309+
}
303310
}
304311
// Check config compatibility and write the config. Compatibility errors
305312
// are returned to the caller unless we're already at block zero.

0 commit comments

Comments
 (0)