@@ -282,6 +282,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override
282
282
if overrideArrowGlacier != nil {
283
283
newcfg .ArrowGlacierBlock = overrideArrowGlacier
284
284
}
285
+ if overrideTerminalTotalDifficulty != nil {
286
+ newcfg .TerminalTotalDifficulty = overrideTerminalTotalDifficulty
287
+ }
285
288
if err := newcfg .CheckConfigForkOrder (); err != nil {
286
289
return newcfg , common.Hash {}, err
287
290
}
@@ -291,15 +294,19 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override
291
294
rawdb .WriteChainConfig (db , stored , newcfg )
292
295
return newcfg , stored , nil
293
296
}
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.
301
302
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
+ }
303
310
}
304
311
// Check config compatibility and write the config. Compatibility errors
305
312
// are returned to the caller unless we're already at block zero.
0 commit comments