add check in CreateConensusEngine that TerminalTotalDifficulty is specified. Remove unused parts from HF description generation

This commit is contained in:
Jared Wasinger 2024-10-16 20:32:49 +07:00
parent 1fbde1abaf
commit 739baec2f8
2 changed files with 12 additions and 21 deletions

View file

@ -18,6 +18,7 @@
package ethconfig package ethconfig
import ( import (
"fmt"
"time" "time"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -161,6 +162,9 @@ type Config struct {
// Clique is allowed for now to live standalone, but ethash is forbidden and can // Clique is allowed for now to live standalone, but ethash is forbidden and can
// only exist on already merged networks. // only exist on already merged networks.
func CreateConsensusEngine(config *params.ChainConfig, db ethdb.Database) (consensus.Engine, error) { func CreateConsensusEngine(config *params.ChainConfig, db ethdb.Database) (consensus.Engine, error) {
if config.TerminalTotalDifficulty == nil {
return nil, fmt.Errorf("only PoS networks are supported, please transition old ones with Geth v1.13.x")
}
// Wrap previously supported consensus engines into their post-merge counterpart // Wrap previously supported consensus engines into their post-merge counterpart
if config.Clique != nil { if config.Clique != nil {
return beacon.New(clique.New(config.Clique, db)), nil return beacon.New(clique.New(config.Clique, db)), nil

View file

@ -360,17 +360,9 @@ func (c *ChainConfig) Description() string {
banner += fmt.Sprintf("Chain ID: %v (%s)\n", c.ChainID, network) banner += fmt.Sprintf("Chain ID: %v (%s)\n", c.ChainID, network)
switch { switch {
case c.Ethash != nil: case c.Ethash != nil:
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" banner += "Consensus: Beacon (proof-of-stake), merged from Ethash (proof-of-work)\n"
}
case c.Clique != nil: case c.Clique != nil:
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" banner += "Consensus: Beacon (proof-of-stake), merged from Clique (proof-of-authority)\n"
}
default: default:
banner += "Consensus: unknown\n" banner += "Consensus: unknown\n"
} }
@ -405,10 +397,6 @@ func (c *ChainConfig) Description() string {
banner += "\n" banner += "\n"
// Add a special section for the merge as it's non-obvious // 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: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md\n"
} else {
banner += "Merge configured:\n" banner += "Merge configured:\n"
banner += " - Hard-fork specification: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md\n" banner += " - Hard-fork specification: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md\n"
banner += " - Network known to be merged\n" banner += " - Network known to be merged\n"
@ -416,7 +404,6 @@ func (c *ChainConfig) Description() string {
if c.MergeNetsplitBlock != nil { if c.MergeNetsplitBlock != nil {
banner += fmt.Sprintf(" - Merge netsplit block: #%-8v\n", c.MergeNetsplitBlock) banner += fmt.Sprintf(" - Merge netsplit block: #%-8v\n", c.MergeNetsplitBlock)
} }
}
banner += "\n" banner += "\n"
// Create a list of forks post-merge // Create a list of forks post-merge