go-ethereum/p2p/enode
Lucas 804d45cc2e
p2p: DNS resolution for static nodes (#30822)
Closes #23210 

# Context 
When deploying Geth in Kubernetes with ReplicaSets, we encountered two
DNS-related issues affecting node connectivity. First, during startup,
Geth tries to resolve DNS names for static nodes too early in the config
unmarshaling phase. If peer nodes aren't ready yet (which is common in
Kubernetes rolling deployments), this causes an immediate failure:


```
INFO [11-26|10:03:42.816] Starting Geth on Ethereum mainnet...
INFO [11-26|10:03:42.817] Bumping default cache on mainnet         provided=1024 updated=4096
Fatal: config.toml, line 81: (p2p.Config.StaticNodes) lookup idontexist.geth.node: no such host
``` 

The second issue comes up when pods get rescheduled to different nodes -
their IPs change but peers keep using the initially resolved IP, never
updating the DNS mapping.

This PR adds proper DNS support for enode:// URLs by deferring resolution
to connection time. It also handles DNS failures gracefully instead of failing
fatally during startup, making it work better in container environments where
IPs are dynamic and peers come and go during rollouts.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2024-12-13 12:46:12 +01:00
..
idscheme.go p2p/enode: fix endpoint determination for IPv6 (#29801) 2024-05-23 14:27:03 +02:00
idscheme_test.go all: new p2p node representation (#17643) 2018-09-25 00:59:00 +02:00
iter.go p2p/enode: implement per-source timeout in FairMix (#25962) 2022-11-08 12:12:36 +01:00
iter_test.go p2p: initialize maps with known size (#27229) 2023-05-10 10:52:26 +02:00
localnode.go p2p: use netip.Addr where possible (#29891) 2024-06-05 19:31:04 +02:00
localnode_test.go p2p: use netip.Addr where possible (#29891) 2024-06-05 19:31:04 +02:00
node.go p2p: DNS resolution for static nodes (#30822) 2024-12-13 12:46:12 +01:00
node_test.go p2p: DNS resolution for static nodes (#30822) 2024-12-13 12:46:12 +01:00
nodedb.go p2p/discover: fix flaky tests writing to test.log after completion (#30506) 2024-09-26 08:12:12 +02:00
nodedb_test.go p2p: use netip.Addr where possible (#29891) 2024-06-05 19:31:04 +02:00
urlv4.go p2p: DNS resolution for static nodes (#30822) 2024-12-13 12:46:12 +01:00
urlv4_test.go p2p: DNS resolution for static nodes (#30822) 2024-12-13 12:46:12 +01:00