Skip to content

Commit

Permalink
Merge pull request ethereum#25 from lochjin/v1.11.5-qng
Browse files Browse the repository at this point in the history
BUG:ChainConfig Description error
  • Loading branch information
dindinw authored Apr 1, 2023
2 parents 4fef9c1 + ac3804c commit a7f5f45
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 13 deletions.
24 changes: 12 additions & 12 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,18 @@ func (c *ChainConfig) Description() string {
}
banner += fmt.Sprintf("Chain ID: %v (%s)\n", c.ChainID, network)
switch {
case IsQngNetwork(c.ChainID):
banner += "Consensus: MeerDAG (proof-of-work)\n"
return QngEIPsBanner(banner, c)
case IsAmanaNetwork(c.ChainID):
banner += "Consensus: Amana (proof-of-authority)\n"
return QngEIPsBanner(banner, c)
case IsFlanaNetwork(c.ChainID):
banner += "Consensus: Flana (rollup)\n"
return QngEIPsBanner(banner, c)
case IsMizanaNetwork(c.ChainID):
banner += "Consensus: Mizana (ZK rollup)\n"
return QngEIPsBanner(banner, c)
case c.Ethash != nil:
if c.TerminalTotalDifficulty == nil {
banner += "Consensus: Ethash (proof-of-work)\n"
Expand All @@ -498,18 +510,6 @@ func (c *ChainConfig) Description() string {
} else {
banner += "Consensus: Beacon (proof-of-stake), merged from Clique (proof-of-authority)\n"
}
case IsQngNetwork(c.ChainID):
banner += "Consensus: MeerDAG (proof-of-work)\n"
return banner
case IsAmanaNetwork(c.ChainID):
banner += "Consensus: Amana (proof-of-authority)\n"
return banner
case IsFlanaNetwork(c.ChainID):
banner += "Consensus: Flana (rollup)\n"
return banner
case IsMizanaNetwork(c.ChainID):
banner += "Consensus: Mizana (ZK rollup)\n"
return banner
default:
banner += "Consensus: unknown\n"
}
Expand Down
66 changes: 65 additions & 1 deletion params/qng_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package params

import "math/big"
import (
"fmt"
"math/big"
)

type MeerChainConfig struct {
ChainID *big.Int // chainId identifies the current chain and is used for replay protection
Expand Down Expand Up @@ -121,3 +124,64 @@ func IsMizanaNetwork(chainID *big.Int) bool {
}
return false
}

func QngEIPsBanner(banner string, c *ChainConfig) string {
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 (block based):\n"
banner += fmt.Sprintf(" - Homestead: #%-8v (EIP-606 Requires:EIP-2, EIP-7, EIP-8)\n", c.HomesteadBlock)
if c.DAOForkBlock != nil {
banner += fmt.Sprintf(" - DAO Fork: #%-8v (EIP-779 Requires:EIP-606)\n", c.DAOForkBlock)
}
banner += fmt.Sprintf(" - Tangerine Whistle (EIP 150): #%-8v (EIP-608 Requires:EIP-150, EIP-779)\n", c.EIP150Block)
banner += fmt.Sprintf(" - Spurious Dragon/1 (EIP 155): #%-8v (EIP-607 Requires:EIP-155, EIP-160, EIP-161, EIP-170, EIP-608)\n", c.EIP155Block)
banner += fmt.Sprintf(" - Spurious Dragon/2 (EIP 158): #%-8v (EIP-607 Requires:EIP-155, EIP-160, EIP-161, EIP-170, EIP-608)\n", c.EIP155Block)
banner += fmt.Sprintf(" - Byzantium: #%-8v (EIP-609 Requires:EIP-100, EIP-140, EIP-196, EIP-197, EIP-198, EIP-211, EIP-214, EIP-607, EIP-649, EIP-658)\n", c.ByzantiumBlock)
banner += fmt.Sprintf(" - Constantinople: #%-8v (EIP-1013 Requires:EIP-145, EIP-609, EIP-1014, EIP-1052, EIP-1234, EIP-1283)\n", c.ConstantinopleBlock)
banner += fmt.Sprintf(" - Petersburg: #%-8v (EIP-1716 Requires:EIP-1013, EIP-1283)\n", c.PetersburgBlock)
banner += fmt.Sprintf(" - Istanbul: #%-8v (EIP-1679 Requires:EIP-152, EIP-1108, EIP-1344, EIP-1716, EIP-1884, EIP-2028, EIP-2200)\n", c.IstanbulBlock)
if c.MuirGlacierBlock != nil {
banner += fmt.Sprintf(" - Muir Glacier: #%-8v (EIP-2387 Requires:EIP-1679, EIP-2384)\n", c.MuirGlacierBlock)
}
banner += fmt.Sprintf(" - Berlin: #%-8v (EIP-2565 EIP-2929 EIP-2718 EIP-2930 Requires:EIP-198)\n", c.BerlinBlock)
banner += fmt.Sprintf(" - London: #%-8v (EIP-1559 EIP-3198 EIP-3529 EIP-3541 EIP-3554 Requires:EIP-2718, EIP-2930, EIP-2200, EIP-2929, EIP-2930)\n", c.LondonBlock)
if c.ArrowGlacierBlock != nil {
banner += fmt.Sprintf(" - Arrow Glacier: #%-8v (EIP-4345)\n", c.ArrowGlacierBlock)
}
if c.GrayGlacierBlock != nil {
banner += fmt.Sprintf(" - Gray Glacier: #%-8v (EIP-5133)\n", c.GrayGlacierBlock)
}
banner += "\n"

// Add a special section for the merge as it's non-obvious
if c.TerminalTotalDifficulty == nil {
banner += "The Merge is not yet available for this network!\n"
banner += " - Hard-fork specification: EIP-3675 EIP-4399 Requires:EIP-2124\n"
} else {
banner += "Merge configured:\n"
banner += " - Hard-fork specification: EIP-3675 EIP-4399 Requires:EIP-2124\n"
banner += fmt.Sprintf(" - Network known to be merged: %v\n", c.TerminalTotalDifficultyPassed)
banner += fmt.Sprintf(" - Total terminal difficulty: %v\n", c.TerminalTotalDifficulty)
if c.MergeNetsplitBlock != nil {
banner += fmt.Sprintf(" - Merge netsplit block: #%-8v\n", c.MergeNetsplitBlock)
}
}
banner += "\n"

// Create a list of forks post-merge
banner += "Post-Merge hard forks (timestamp based):\n"
if c.ShanghaiTime != nil {
banner += fmt.Sprintf(" - Shanghai: @%-10v (EIP-3651 EIP-3855 EIP-3860 EIP-4895 EIP-6049 Requires:EIP-2929, EIP-170)\n", *c.ShanghaiTime)
}
if c.CancunTime != nil {
banner += fmt.Sprintf(" - Cancun: @%-10v\n", *c.CancunTime)
}
if c.PragueTime != nil {
banner += fmt.Sprintf(" - Prague: @%-10v\n", *c.PragueTime)
}

return banner
}

0 comments on commit a7f5f45

Please sign in to comment.