forked from cerc-io/plugeth
eth, les, params: log chain config a bit saner (#24904)
Previously on Geth startup we just logged the chain config is a semi-json-y format. Whilst that worked while we had a handful of hard-forks defined, currently it's kind of unwieldy. This PR converts that original data dump and converts it into a user friendly - alas multiline - log output.
This commit is contained in:
parent
450f5da7e1
commit
41e75480df
@ -31,7 +31,7 @@ import (
|
|||||||
// the correct fork ID.
|
// the correct fork ID.
|
||||||
func TestCreation(t *testing.T) {
|
func TestCreation(t *testing.T) {
|
||||||
mergeConfig := *params.MainnetChainConfig
|
mergeConfig := *params.MainnetChainConfig
|
||||||
mergeConfig.MergeForkBlock = big.NewInt(15000000)
|
mergeConfig.MergeNetsplitBlock = big.NewInt(15000000)
|
||||||
type testcase struct {
|
type testcase struct {
|
||||||
head uint64
|
head uint64
|
||||||
want ID
|
want ID
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@ -140,7 +141,13 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||||||
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
|
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
|
||||||
return nil, genesisErr
|
return nil, genesisErr
|
||||||
}
|
}
|
||||||
log.Info("Initialised chain configuration", "config", chainConfig)
|
log.Info("")
|
||||||
|
log.Info(strings.Repeat("-", 153))
|
||||||
|
for _, line := range strings.Split(chainConfig.String(), "\n") {
|
||||||
|
log.Info(line)
|
||||||
|
}
|
||||||
|
log.Info(strings.Repeat("-", 153))
|
||||||
|
log.Info("")
|
||||||
|
|
||||||
if err := pruner.RecoverPruning(stack.ResolvePath(""), chainDb, stack.ResolvePath(config.TrieCleanCacheJournal)); err != nil {
|
if err := pruner.RecoverPruning(stack.ResolvePath(""), chainDb, stack.ResolvePath(config.TrieCleanCacheJournal)); err != nil {
|
||||||
log.Error("Failed to recover state", "error", err)
|
log.Error("Failed to recover state", "error", err)
|
||||||
|
@ -19,6 +19,7 @@ package les
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
@ -96,7 +97,13 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
|
|||||||
if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat {
|
if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat {
|
||||||
return nil, genesisErr
|
return nil, genesisErr
|
||||||
}
|
}
|
||||||
log.Info("Initialised chain configuration", "config", chainConfig)
|
log.Info("")
|
||||||
|
log.Info(strings.Repeat("-", 153))
|
||||||
|
for _, line := range strings.Split(chainConfig.String(), "\n") {
|
||||||
|
log.Info(line)
|
||||||
|
}
|
||||||
|
log.Info(strings.Repeat("-", 153))
|
||||||
|
log.Info("")
|
||||||
|
|
||||||
peers := newServerPeerSet()
|
peers := newServerPeerSet()
|
||||||
merger := consensus.NewMerger(chainDb)
|
merger := consensus.NewMerger(chainDb)
|
||||||
|
102
params/config.go
102
params/config.go
@ -272,6 +272,15 @@ var (
|
|||||||
TestRules = TestChainConfig.Rules(new(big.Int), false)
|
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
|
// TrustedCheckpoint represents a set of post-processed trie roots (CHT and
|
||||||
// BloomTrie) associated with the appropriate section index and head hash. It is
|
// BloomTrie) associated with the appropriate section index and head hash. It is
|
||||||
// used to start light syncing from this checkpoint and avoid downloading the
|
// 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)
|
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)
|
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)
|
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
|
// TerminalTotalDifficulty is the amount of total difficulty reached by
|
||||||
// the network that triggers the consensus upgrade.
|
// the network that triggers the consensus upgrade.
|
||||||
@ -380,35 +389,68 @@ func (c *CliqueConfig) String() string {
|
|||||||
|
|
||||||
// String implements the fmt.Stringer interface.
|
// String implements the fmt.Stringer interface.
|
||||||
func (c *ChainConfig) String() string {
|
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 {
|
switch {
|
||||||
case c.Ethash != nil:
|
case c.Ethash != nil:
|
||||||
engine = c.Ethash
|
if c.TerminalTotalDifficulty == nil {
|
||||||
case c.Clique != nil:
|
banner += "Consensus: Ethash (proof-of-work)\n"
|
||||||
engine = c.Clique
|
} else {
|
||||||
default:
|
banner += "Consensus: Beacon (proof-of-stake), merged from Ethash (proof-of-work)\n"
|
||||||
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}",
|
case c.Clique != nil:
|
||||||
c.ChainID,
|
if c.TerminalTotalDifficulty == nil {
|
||||||
c.HomesteadBlock,
|
banner += "Consensus: Clique (proof-of-authority)\n"
|
||||||
c.DAOForkBlock,
|
} else {
|
||||||
c.DAOForkSupport,
|
banner += "Consensus: Beacon (proof-of-stake), merged from Clique (proof-of-authority)\n"
|
||||||
c.EIP150Block,
|
}
|
||||||
c.EIP155Block,
|
default:
|
||||||
c.EIP158Block,
|
banner += "Consensus: unknown\n"
|
||||||
c.ByzantiumBlock,
|
}
|
||||||
c.ConstantinopleBlock,
|
banner += "\n"
|
||||||
c.PetersburgBlock,
|
|
||||||
c.IstanbulBlock,
|
// Create a list of forks with a short description of them. Forks that only
|
||||||
c.MuirGlacierBlock,
|
// makes sense for mainnet should be optional at printing to avoid bloating
|
||||||
c.BerlinBlock,
|
// the output for testnets and private networks.
|
||||||
c.LondonBlock,
|
banner += "Pre-Merge hard forks:\n"
|
||||||
c.ArrowGlacierBlock,
|
banner += fmt.Sprintf(" - Homestead: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/homestead.md)\n", c.HomesteadBlock)
|
||||||
c.MergeForkBlock,
|
if c.DAOForkBlock != nil {
|
||||||
c.TerminalTotalDifficulty,
|
banner += fmt.Sprintf(" - DAO Fork: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/dao-fork.md)\n", c.DAOForkBlock)
|
||||||
engine,
|
}
|
||||||
)
|
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.
|
// 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: "berlinBlock", block: c.BerlinBlock},
|
||||||
{name: "londonBlock", block: c.LondonBlock},
|
{name: "londonBlock", block: c.LondonBlock},
|
||||||
{name: "arrowGlacierBlock", block: c.ArrowGlacierBlock, optional: true},
|
{name: "arrowGlacierBlock", block: c.ArrowGlacierBlock, optional: true},
|
||||||
{name: "mergeStartBlock", block: c.MergeForkBlock, optional: true},
|
{name: "mergeNetsplitBlock", block: c.MergeNetsplitBlock, optional: true},
|
||||||
} {
|
} {
|
||||||
if lastFork.name != "" {
|
if lastFork.name != "" {
|
||||||
// Next one must be higher number
|
// 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) {
|
if isForkIncompatible(c.ArrowGlacierBlock, newcfg.ArrowGlacierBlock, head) {
|
||||||
return newCompatError("Arrow Glacier fork block", c.ArrowGlacierBlock, newcfg.ArrowGlacierBlock)
|
return newCompatError("Arrow Glacier fork block", c.ArrowGlacierBlock, newcfg.ArrowGlacierBlock)
|
||||||
}
|
}
|
||||||
if isForkIncompatible(c.MergeForkBlock, newcfg.MergeForkBlock, head) {
|
if isForkIncompatible(c.MergeNetsplitBlock, newcfg.MergeNetsplitBlock, head) {
|
||||||
return newCompatError("Merge Start fork block", c.MergeForkBlock, newcfg.MergeForkBlock)
|
return newCompatError("Merge netsplit fork block", c.MergeNetsplitBlock, newcfg.MergeNetsplitBlock)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ var Forks = map[string]*params.ChainConfig{
|
|||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: big.NewInt(0),
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: big.NewInt(0),
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: big.NewInt(0),
|
||||||
MergeForkBlock: big.NewInt(0),
|
MergeNetsplitBlock: big.NewInt(0),
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: big.NewInt(0),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user