From 661c3e04bc872724a9b3eb275917401c82eef893 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 23 Jun 2022 11:23:02 +0200 Subject: [PATCH 1/3] cmd/geth: eth/catalyst: enable authrpc by default --- cmd/geth/consolecmd_test.go | 2 +- cmd/geth/genesis_test.go | 2 +- cmd/geth/les_test.go | 2 +- cmd/utils/flags.go | 12 ++++-------- eth/catalyst/api.go | 4 ++-- les/catalyst/api.go | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/cmd/geth/consolecmd_test.go b/cmd/geth/consolecmd_test.go index f4e8bf490a32..d5ebd74aedf4 100644 --- a/cmd/geth/consolecmd_test.go +++ b/cmd/geth/consolecmd_test.go @@ -41,7 +41,7 @@ func runMinimalGeth(t *testing.T, args ...string) *testgeth { // --ropsten to make the 'writing genesis to disk' faster (no accounts) // --networkid=1337 to avoid cache bump // --syncmode=full to avoid allocating fast sync bloom - allArgs := []string{"--ropsten", "--networkid", "1337", "--syncmode=full", "--port", "0", + allArgs := []string{"--ropsten", "--networkid", "1337", "--authrpc.port", "0", "--syncmode=full", "--port", "0", "--nat", "none", "--nodiscover", "--maxpeers", "0", "--cache", "64", "--datadir.minfreedisk", "0"} return runGeth(t, append(allArgs, args...)...) diff --git a/cmd/geth/genesis_test.go b/cmd/geth/genesis_test.go index c95755f2d919..7667a8581158 100644 --- a/cmd/geth/genesis_test.go +++ b/cmd/geth/genesis_test.go @@ -83,7 +83,7 @@ func TestCustomGenesis(t *testing.T) { // Query the custom genesis block geth := runGeth(t, "--networkid", "1337", "--syncmode=full", "--cache", "16", - "--datadir", datadir, "--maxpeers", "0", "--port", "0", + "--datadir", datadir, "--maxpeers", "0", "--port", "0", "--authrpc.port", "0", "--nodiscover", "--nat", "none", "--ipcdisable", "--exec", tt.query, "console") geth.ExpectRegexp(tt.result) diff --git a/cmd/geth/les_test.go b/cmd/geth/les_test.go index d86f41054dd8..d06c3b91d8a5 100644 --- a/cmd/geth/les_test.go +++ b/cmd/geth/les_test.go @@ -111,7 +111,7 @@ var nextIPC = uint32(0) func startGethWithIpc(t *testing.T, name string, args ...string) *gethrpc { ipcName := fmt.Sprintf("geth-%d.ipc", atomic.AddUint32(&nextIPC, 1)) - args = append([]string{"--networkid=42", "--port=0", "--ipcpath", ipcName}, args...) + args = append([]string{"--networkid=42", "--port=0", "--authrpc.port", "0", "--ipcpath", ipcName}, args...) t.Logf("Starting %v with rpc: %v", name, args) g := &gethrpc{ diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 47637a9dd255..ea21dbed577b 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1993,10 +1993,8 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend Fatalf("Failed to register the Ethereum service: %v", err) } stack.RegisterAPIs(tracers.APIs(backend.ApiBackend)) - if backend.BlockChain().Config().TerminalTotalDifficulty != nil { - if err := lescatalyst.Register(stack, backend); err != nil { - Fatalf("Failed to register the catalyst service: %v", err) - } + if err := lescatalyst.Register(stack, backend); err != nil { + Fatalf("Failed to register the catalyst service: %v", err) } return backend.ApiBackend, nil } @@ -2010,10 +2008,8 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend Fatalf("Failed to create the LES server: %v", err) } } - if backend.BlockChain().Config().TerminalTotalDifficulty != nil { - if err := ethcatalyst.Register(stack, backend); err != nil { - Fatalf("Failed to register the catalyst service: %v", err) - } + if err := ethcatalyst.Register(stack, backend); err != nil { + Fatalf("Failed to register the catalyst service: %v", err) } stack.RegisterAPIs(tracers.APIs(backend.APIBackend)) return backend.APIBackend, backend diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index feccff881e31..d1bd2c2102a5 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -62,7 +62,7 @@ type ConsensusAPI struct { // The underlying blockchain needs to have a valid terminal total difficulty set. func NewConsensusAPI(eth *eth.Ethereum) *ConsensusAPI { if eth.BlockChain().Config().TerminalTotalDifficulty == nil { - panic("Catalyst started without valid total difficulty") + log.Warn("Catalyst started without valid total difficulty") } return &ConsensusAPI{ eth: eth, @@ -223,7 +223,7 @@ func (api *ConsensusAPI) ExchangeTransitionConfigurationV1(config beacon.Transit return nil, errors.New("invalid terminal total difficulty") } ttd := api.eth.BlockChain().Config().TerminalTotalDifficulty - if ttd.Cmp(config.TerminalTotalDifficulty.ToInt()) != 0 { + if ttd == nil || ttd.Cmp(config.TerminalTotalDifficulty.ToInt()) != 0 { log.Warn("Invalid TTD configured", "geth", ttd, "beacon", config.TerminalTotalDifficulty) return nil, fmt.Errorf("invalid ttd: execution %v consensus %v", ttd, config.TerminalTotalDifficulty) } diff --git a/les/catalyst/api.go b/les/catalyst/api.go index 9c2d17c79b1a..983fc7bff0bc 100644 --- a/les/catalyst/api.go +++ b/les/catalyst/api.go @@ -50,7 +50,7 @@ type ConsensusAPI struct { // The underlying blockchain needs to have a valid terminal total difficulty set. func NewConsensusAPI(les *les.LightEthereum) *ConsensusAPI { if les.BlockChain().Config().TerminalTotalDifficulty == nil { - panic("Catalyst started without valid total difficulty") + log.Warn("Catalyst started without valid total difficulty") } return &ConsensusAPI{les: les} } From 6c5f9ba96358190db6b579bcec51bf4bbf56a705 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Fri, 15 Jul 2022 17:47:24 +0200 Subject: [PATCH 2/3] eth/catalyst: rename catalyst -> Engine API in logs --- cmd/utils/flags.go | 4 ++-- eth/catalyst/api.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index ea21dbed577b..68ef05fa2024 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1994,7 +1994,7 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend } stack.RegisterAPIs(tracers.APIs(backend.ApiBackend)) if err := lescatalyst.Register(stack, backend); err != nil { - Fatalf("Failed to register the catalyst service: %v", err) + Fatalf("Failed to register the Engine API service: %v", err) } return backend.ApiBackend, nil } @@ -2009,7 +2009,7 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend } } if err := ethcatalyst.Register(stack, backend); err != nil { - Fatalf("Failed to register the catalyst service: %v", err) + Fatalf("Failed to register the Engine API service: %v", err) } stack.RegisterAPIs(tracers.APIs(backend.APIBackend)) return backend.APIBackend, backend diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index d1bd2c2102a5..fc4195082cc1 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -37,9 +37,9 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) -// Register adds catalyst APIs to the full node. +// Register adds the engine API to the full node. func Register(stack *node.Node, backend *eth.Ethereum) error { - log.Warn("Catalyst mode enabled", "protocol", "eth") + log.Warn("Engine API enabled", "protocol", "eth") stack.RegisterAPIs([]rpc.API{ { Namespace: "engine", @@ -62,7 +62,7 @@ type ConsensusAPI struct { // The underlying blockchain needs to have a valid terminal total difficulty set. func NewConsensusAPI(eth *eth.Ethereum) *ConsensusAPI { if eth.BlockChain().Config().TerminalTotalDifficulty == nil { - log.Warn("Catalyst started without valid total difficulty") + panic("Engine API started without valid total difficulty") } return &ConsensusAPI{ eth: eth, @@ -73,7 +73,7 @@ func NewConsensusAPI(eth *eth.Ethereum) *ConsensusAPI { // ForkchoiceUpdatedV1 has several responsibilities: // If the method is called with an empty head block: -// we return success, which can be used to check if the catalyst mode is enabled +// we return success, which can be used to check if the engine API is enabled // If the total difficulty was not reached: // we return INVALID // If the finalizedBlockHash is set: From 48ac0d40f0204dddeb3b4d8c2e95ff07eb3ea502 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 21 Jul 2022 18:15:28 +0200 Subject: [PATCH 3/3] eth/catalyst: don't panic --- eth/catalyst/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index fc4195082cc1..a72e1c41e973 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -62,7 +62,7 @@ type ConsensusAPI struct { // The underlying blockchain needs to have a valid terminal total difficulty set. func NewConsensusAPI(eth *eth.Ethereum) *ConsensusAPI { if eth.BlockChain().Config().TerminalTotalDifficulty == nil { - panic("Engine API started without valid total difficulty") + log.Warn("Engine API started without valid total difficulty") } return &ConsensusAPI{ eth: eth,