From 9e6f9246713be4401ab1bae41f0632379f208aec Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sun, 23 Feb 2025 17:38:32 +0100 Subject: [PATCH] eth: report error from setupDiscovery at startup (#31233) I ran into this while trying to debug a discv5 thing. I tried to disable DNS discovery using `--discovery.dns=false`, which doesn't work. Annoyingly, geth started anyway and discarded the error silently. I eventually found my mistake, but it took way longer than it should have. Also including a small change to the error message for invalid DNS URLs here. The user actually needs to see the URL to make sense of the error. --- eth/backend.go | 4 +++- p2p/dnsdisc/client.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/eth/backend.go b/eth/backend.go index fea7e4e1fe..f3a8bf3078 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -368,7 +368,9 @@ func (s *Ethereum) Protocols() []p2p.Protocol { // Start implements node.Lifecycle, starting all internal goroutines needed by the // Ethereum protocol implementation. func (s *Ethereum) Start() error { - s.setupDiscovery() + if err := s.setupDiscovery(); err != nil { + return err + } // Start the bloom bits servicing goroutines s.startBloomHandlers(params.BloomBitsBlocks) diff --git a/p2p/dnsdisc/client.go b/p2p/dnsdisc/client.go index 4f14d860e1..ac369ce07d 100644 --- a/p2p/dnsdisc/client.go +++ b/p2p/dnsdisc/client.go @@ -263,7 +263,7 @@ func (it *randomIterator) Next() bool { func (it *randomIterator) addTree(url string) error { le, err := parseLink(url) if err != nil { - return fmt.Errorf("invalid enrtree URL: %v", err) + return fmt.Errorf("invalid DNS discovery URL %q: %v", url, err) } it.lc.addLink("", le.str) return nil