@@ -272,6 +272,15 @@ var (
272
272
TestRules = TestChainConfig .Rules (new (big.Int ), false )
273
273
)
274
274
275
+ // NetworkNames are user friendly names to use in the chain spec banner.
276
+ var NetworkNames = map [string ]string {
277
+ MainnetChainConfig .ChainID .String (): "mainnet" ,
278
+ RopstenChainConfig .ChainID .String (): "ropsten" ,
279
+ RinkebyChainConfig .ChainID .String (): "rinkeby" ,
280
+ GoerliChainConfig .ChainID .String (): "goerli" ,
281
+ SepoliaChainConfig .ChainID .String (): "sepolia" ,
282
+ }
283
+
275
284
// TrustedCheckpoint represents a set of post-processed trie roots (CHT and
276
285
// BloomTrie) associated with the appropriate section index and head hash. It is
277
286
// used to start light syncing from this checkpoint and avoid downloading the
@@ -348,7 +357,7 @@ type ChainConfig struct {
348
357
BerlinBlock * big.Int `json:"berlinBlock,omitempty"` // Berlin switch block (nil = no fork, 0 = already on berlin)
349
358
LondonBlock * big.Int `json:"londonBlock,omitempty"` // London switch block (nil = no fork, 0 = already on london)
350
359
ArrowGlacierBlock * big.Int `json:"arrowGlacierBlock,omitempty"` // Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
351
- MergeForkBlock * big.Int `json:"mergeForkBlock ,omitempty"` // EIP-3675 (TheMerge) switch block (nil = no fork, 0 = already in merge proceedings)
360
+ MergeNetsplitBlock * big.Int `json:"mergeNetsplitBlock ,omitempty"` // Virtual fork after The Merge to use as a network splitter
352
361
353
362
// TerminalTotalDifficulty is the amount of total difficulty reached by
354
363
// the network that triggers the consensus upgrade.
@@ -380,35 +389,68 @@ func (c *CliqueConfig) String() string {
380
389
381
390
// String implements the fmt.Stringer interface.
382
391
func (c * ChainConfig ) String () string {
383
- var engine interface {}
392
+ var banner string
393
+
394
+ // Create some basinc network config output
395
+ network := NetworkNames [c .ChainID .String ()]
396
+ if network == "" {
397
+ network = "unknown"
398
+ }
399
+ banner += fmt .Sprintf ("Chain ID: %v (%s)\n " , c .ChainID , network )
384
400
switch {
385
401
case c .Ethash != nil :
386
- engine = c .Ethash
402
+ if c .TerminalTotalDifficulty == nil {
403
+ banner += "Consensus: Ethash (proof-of-work)\n "
404
+ } else {
405
+ banner += "Consensus: Beacon (proof-of-stake), merged from Ethash (proof-of-work)\n "
406
+ }
387
407
case c .Clique != nil :
388
- engine = c .Clique
408
+ if c .TerminalTotalDifficulty == nil {
409
+ banner += "Consensus: Clique (proof-of-authority)\n "
410
+ } else {
411
+ banner += "Consensus: Beacon (proof-of-stake), merged from Clique (proof-of-authority)\n "
412
+ }
389
413
default :
390
- engine = "unknown"
391
- }
392
- return fmt .Sprintf ("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, MergeFork: %v, Terminal TD: %v, Engine: %v}" ,
393
- c .ChainID ,
394
- c .HomesteadBlock ,
395
- c .DAOForkBlock ,
396
- c .DAOForkSupport ,
397
- c .EIP150Block ,
398
- c .EIP155Block ,
399
- c .EIP158Block ,
400
- c .ByzantiumBlock ,
401
- c .ConstantinopleBlock ,
402
- c .PetersburgBlock ,
403
- c .IstanbulBlock ,
404
- c .MuirGlacierBlock ,
405
- c .BerlinBlock ,
406
- c .LondonBlock ,
407
- c .ArrowGlacierBlock ,
408
- c .MergeForkBlock ,
409
- c .TerminalTotalDifficulty ,
410
- engine ,
411
- )
414
+ banner += "Consensus: unknown\n "
415
+ }
416
+ banner += "\n "
417
+
418
+ // Create a list of forks with a short description of them. Forks that only
419
+ // makes sense for mainnet should be optional at printing to avoid bloating
420
+ // the output for testnets and private networks.
421
+ banner += "Pre-Merge hard forks:\n "
422
+ banner += fmt .Sprintf (" - Homestead: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/homestead.md)\n " , c .HomesteadBlock )
423
+ if c .DAOForkBlock != nil {
424
+ banner += fmt .Sprintf (" - DAO Fork: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/dao-fork.md)\n " , c .DAOForkBlock )
425
+ }
426
+ banner += fmt .Sprintf (" - Tangerine Whistle (EIP 150): %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/tangerine-whistle.md)\n " , c .EIP150Block )
427
+ banner += fmt .Sprintf (" - Spurious Dragon/1 (EIP 155): %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/spurious-dragon.md)\n " , c .EIP155Block )
428
+ banner += fmt .Sprintf (" - Spurious Dragon/2 (EIP 158): %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/spurious-dragon.md)\n " , c .EIP155Block )
429
+ banner += fmt .Sprintf (" - Byzantium: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/byzantium.md)\n " , c .ByzantiumBlock )
430
+ banner += fmt .Sprintf (" - Constantinople: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/constantinople.md)\n " , c .ConstantinopleBlock )
431
+ banner += fmt .Sprintf (" - Petersburg: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/petersburg.md)\n " , c .PetersburgBlock )
432
+ banner += fmt .Sprintf (" - Istanbul: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/istanbul.md)\n " , c .IstanbulBlock )
433
+ if c .MuirGlacierBlock != nil {
434
+ banner += fmt .Sprintf (" - Muir Glacier: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/muir-glacier.md)\n " , c .MuirGlacierBlock )
435
+ }
436
+ banner += fmt .Sprintf (" - Berlin: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/berlin.md)\n " , c .BerlinBlock )
437
+ banner += fmt .Sprintf (" - London: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md)\n " , c .LondonBlock )
438
+ if c .ArrowGlacierBlock != nil {
439
+ banner += fmt .Sprintf (" - Arrow Glacier: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/arrow-glacier.md)\n " , c .ArrowGlacierBlock )
440
+ }
441
+ banner += "\n "
442
+
443
+ // Add a special section for the merge as it's non-obvious
444
+ if c .TerminalTotalDifficulty == nil {
445
+ banner += "Merge not configured!\n "
446
+ banner += " - Hard-fork specification: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md)"
447
+ } else {
448
+ banner += "Merge configured:\n "
449
+ banner += " - Hard-fork specification: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md)\n "
450
+ banner += fmt .Sprintf (" - Total terminal difficulty: %v\n " , c .TerminalTotalDifficulty )
451
+ banner += fmt .Sprintf (" - Merge netsplit block: %-8v" , c .MergeNetsplitBlock )
452
+ }
453
+ return banner
412
454
}
413
455
414
456
// IsHomestead returns whether num is either equal to the homestead block or greater.
@@ -527,7 +569,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
527
569
{name : "berlinBlock" , block : c .BerlinBlock },
528
570
{name : "londonBlock" , block : c .LondonBlock },
529
571
{name : "arrowGlacierBlock" , block : c .ArrowGlacierBlock , optional : true },
530
- {name : "mergeStartBlock " , block : c .MergeForkBlock , optional : true },
572
+ {name : "mergeNetsplitBlock " , block : c .MergeNetsplitBlock , optional : true },
531
573
} {
532
574
if lastFork .name != "" {
533
575
// Next one must be higher number
@@ -600,8 +642,8 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
600
642
if isForkIncompatible (c .ArrowGlacierBlock , newcfg .ArrowGlacierBlock , head ) {
601
643
return newCompatError ("Arrow Glacier fork block" , c .ArrowGlacierBlock , newcfg .ArrowGlacierBlock )
602
644
}
603
- if isForkIncompatible (c .MergeForkBlock , newcfg .MergeForkBlock , head ) {
604
- return newCompatError ("Merge Start fork block" , c .MergeForkBlock , newcfg .MergeForkBlock )
645
+ if isForkIncompatible (c .MergeNetsplitBlock , newcfg .MergeNetsplitBlock , head ) {
646
+ return newCompatError ("Merge netsplit fork block" , c .MergeNetsplitBlock , newcfg .MergeNetsplitBlock )
605
647
}
606
648
return nil
607
649
}
0 commit comments