go-ethereum/p2p/discover
rayoo c80681ca73
p2p/discover: return errNoUDPEndpoint in RequestENR (#34933)
Mirror the guard applied to (*UDPv4).Dial in #34916: when the target
node has no usable UDP endpoint, return errNoUDPEndpoint instead of
silently sending the ENRRequest to an invalid AddrPort and waiting for a
timeout.

The other UDPEndpoint-using request paths in this file already do this:

  ping        v4_udp.go:215   errNoUDPEndpoint
  Ping        v4_udp.go:228   errNoUDPEndpoint
  newLookup   v4_udp.go:309   errNoUDPEndpoint
  RequestENR  v4_udp.go:358   addr, _ := n.UDPEndpoint()  <-- outlier

RequestENR is reachable from external callers like cmd/devp2p/crawl.go,
which feeds in arbitrary nodes that may not have a UDP port set. Before
this change, such nodes burn one full RPC timeout; after it, the caller
gets a clean error immediately.

The added test fails on master with "RPC timeout" and the trace logs
"PING/v4 addr=invalid AddrPort", confirming packets are being written to
an unspecified address; with the fix it returns errNoUDPEndpoint without
doing any I/O.
2026-06-22 10:48:03 +02:00
..
v4wire p2p/discover: refactor node and endpoint representation (#29844) 2024-05-29 15:02:26 +02:00
v5wire p2p/discover/v5wire: use Whoareyou.ChallengeData instead of storing encoded packet (#31547) 2026-02-22 21:58:47 +01:00
common.go p2p/discover: fix timeout loop early exit when removing expired matchers (#34743) 2026-04-28 10:57:58 +02:00
lookup.go p2p/discover: fix waiting wrong duration (#35002) 2026-06-21 01:15:26 +02:00
metrics.go metrics, cmd/geth: change init-process of metrics (#30814) 2024-12-10 13:27:29 +01:00
node.go p2p/discover: remove type encPubkey (#30172) 2024-07-18 11:09:02 +02:00
ntp.go all: remove dependency on golang.org/exp (#29314) 2024-03-25 07:50:18 +01:00
table.go p2p/discover: optimize findnodeByID (#33348) 2026-06-12 09:10:34 +02:00
table_reval.go p2p/discover: remove unused parameter in revalidationList.get (#31155) 2025-02-11 13:45:44 +01:00
table_reval_test.go p2p/discover: refactor node and endpoint representation (#29844) 2024-05-29 15:02:26 +02:00
table_test.go p2p/discover: optimize findnodeByID (#33348) 2026-06-12 09:10:34 +02:00
table_util_test.go p2p/discover: remove type encPubkey (#30172) 2024-07-18 11:09:02 +02:00
v4_lookup_test.go Revert "p2p/discover: add test for lookup returning immediately" 2025-09-12 11:29:43 +02:00
v4_udp.go p2p/discover: return errNoUDPEndpoint in RequestENR (#34933) 2026-06-22 10:48:03 +02:00
v4_udp_test.go p2p/discover: return errNoUDPEndpoint in RequestENR (#34933) 2026-06-22 10:48:03 +02:00
v5_talk.go p2p/discover: pass node instead of node ID to TALKREQ handler (#31075) 2025-04-02 14:56:21 +02:00
v5_udp.go p2p/discover: waitForNodes hangs on RespCount=0 from peer (#35043) 2026-05-26 14:18:47 +02:00
v5_udp_test.go p2p/discover: fix flaky TestUDPv5_findnodeHandling (#34109) 2026-04-14 09:43:44 +02:00