@ -272,6 +272,15 @@ var (
TestRules = TestChainConfig . Rules ( new ( big . Int ) , false )
)
// NetworkNames are user friendly names to use in the chain spec banner.
var NetworkNames = map [ string ] string {
MainnetChainConfig . ChainID . String ( ) : "mainnet" ,
RopstenChainConfig . ChainID . String ( ) : "ropsten" ,
RinkebyChainConfig . ChainID . String ( ) : "rinkeby" ,
GoerliChainConfig . ChainID . String ( ) : "goerli" ,
SepoliaChainConfig . ChainID . String ( ) : "sepolia" ,
}
// TrustedCheckpoint represents a set of post-processed trie roots (CHT and
// BloomTrie) associated with the appropriate section index and head hash. It is
// used to start light syncing from this checkpoint and avoid downloading the
@ -348,7 +357,7 @@ type ChainConfig struct {
BerlinBlock * big . Int ` json:"berlinBlock,omitempty" ` // Berlin switch block (nil = no fork, 0 = already on berlin)
LondonBlock * big . Int ` json:"londonBlock,omitempty" ` // London switch block (nil = no fork, 0 = already on london)
ArrowGlacierBlock * big . Int ` json:"arrowGlacierBlock,omitempty" ` // Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
MergeForkBlock * big . Int ` json:"mergeForkBlock,omitempty" ` // EIP-3675 (TheMerge) switch block (nil = no fork, 0 = already in merge proceedings)
MergeNetsplitBlock * big . Int ` json:"mergeNetsplitBlock,omitempty" ` // Virtual fork after The Merge to use as a network splitter
// TerminalTotalDifficulty is the amount of total difficulty reached by
// the network that triggers the consensus upgrade.
@ -380,35 +389,68 @@ func (c *CliqueConfig) String() string {
// String implements the fmt.Stringer interface.
func ( c * ChainConfig ) String ( ) string {
var engine interface { }
var banner string
// Create some basinc network config output
network := NetworkNames [ c . ChainID . String ( ) ]
if network == "" {
network = "unknown"
}
banner += fmt . Sprintf ( "Chain ID: %v (%s)\n" , c . ChainID , network )
switch {
case c . Ethash != nil :
engine = c . Ethash
if c . TerminalTotalDifficulty == nil {
banner += "Consensus: Ethash (proof-of-work)\n"
} else {
banner += "Consensus: Beacon (proof-of-stake), merged from Ethash (proof-of-work)\n"
}
case c . Clique != nil :
engine = c . Clique
if c . TerminalTotalDifficulty == nil {
banner += "Consensus: Clique (proof-of-authority)\n"
} else {
banner += "Consensus: Beacon (proof-of-stake), merged from Clique (proof-of-authority)\n"
}
default :
engine = "unknown"
}
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}" ,
c . ChainID ,
c . HomesteadBlock ,
c . DAOForkBlock ,
c . DAOForkSupport ,
c . EIP150Block ,
c . EIP155Block ,
c . EIP158Block ,
c . ByzantiumBlock ,
c . ConstantinopleBlock ,
c . PetersburgBlock ,
c . IstanbulBlock ,
c . MuirGlacierBlock ,
c . BerlinBlock ,
c . LondonBlock ,
c . ArrowGlacierBlock ,
c . MergeForkBlock ,
c . TerminalTotalDifficulty ,
engine ,
)
banner += "Consensus: unknown\n"
}
banner += "\n"
// Create a list of forks with a short description of them. Forks that only
// makes sense for mainnet should be optional at printing to avoid bloating
// the output for testnets and private networks.
banner += "Pre-Merge hard forks:\n"
banner += fmt . Sprintf ( " - Homestead: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/homestead.md)\n" , c . HomesteadBlock )
if c . DAOForkBlock != nil {
banner += fmt . Sprintf ( " - DAO Fork: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/dao-fork.md)\n" , c . DAOForkBlock )
}
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 )
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 )
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 )
banner += fmt . Sprintf ( " - Byzantium: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/byzantium.md)\n" , c . ByzantiumBlock )
banner += fmt . Sprintf ( " - Constantinople: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/constantinople.md)\n" , c . ConstantinopleBlock )
banner += fmt . Sprintf ( " - Petersburg: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/petersburg.md)\n" , c . PetersburgBlock )
banner += fmt . Sprintf ( " - Istanbul: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/istanbul.md)\n" , c . IstanbulBlock )
if c . MuirGlacierBlock != nil {
banner += fmt . Sprintf ( " - Muir Glacier: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/muir-glacier.md)\n" , c . MuirGlacierBlock )
}
banner += fmt . Sprintf ( " - Berlin: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/berlin.md)\n" , c . BerlinBlock )
banner += fmt . Sprintf ( " - London: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md)\n" , c . LondonBlock )
if c . ArrowGlacierBlock != nil {
banner += fmt . Sprintf ( " - Arrow Glacier: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/arrow-glacier.md)\n" , c . ArrowGlacierBlock )
}
banner += "\n"
// Add a special section for the merge as it's non-obvious
if c . TerminalTotalDifficulty == nil {
banner += "Merge not configured!\n"
banner += " - Hard-fork specification: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md)"
} else {
banner += "Merge configured:\n"
banner += " - Hard-fork specification: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md)\n"
banner += fmt . Sprintf ( " - Total terminal difficulty: %v\n" , c . TerminalTotalDifficulty )
banner += fmt . Sprintf ( " - Merge netsplit block: %-8v" , c . MergeNetsplitBlock )
}
return banner
}
// IsHomestead returns whether num is either equal to the homestead block or greater.
@ -527,7 +569,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
{ name : "berlinBlock" , block : c . BerlinBlock } ,
{ name : "londonBlock" , block : c . LondonBlock } ,
{ name : "arrowGlacierBlock" , block : c . ArrowGlacierBlock , optional : true } ,
{ name : "mergeStar tBlock" , block : c . MergeFork Block , optional : true } ,
{ name : "mergeNetspli tBlock" , block : c . MergeNetsplit Block , optional : true } ,
} {
if lastFork . name != "" {
// Next one must be higher number
@ -600,8 +642,8 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
if isForkIncompatible ( c . ArrowGlacierBlock , newcfg . ArrowGlacierBlock , head ) {
return newCompatError ( "Arrow Glacier fork block" , c . ArrowGlacierBlock , newcfg . ArrowGlacierBlock )
}
if isForkIncompatible ( c . MergeFork Block , newcfg . MergeFork Block , head ) {
return newCompatError ( "Merge Star t fork block" , c . MergeFork Block , newcfg . MergeFork Block )
if isForkIncompatible ( c . MergeNetsplit Block , newcfg . MergeNetsplit Block , head ) {
return newCompatError ( "Merge netspli t fork block" , c . MergeNetsplit Block , newcfg . MergeNetsplit Block )
}
return nil
}