go-ethereum/p2p
rayoo c944ff3d54 p2p/discover: restore nextTimeout update in UDPv4 resetTimeout loop
The refactor from `for el := plist.Front(); ...; el = el.Next()` to the
new `iterList` iterator in #34743 silently dropped two things needed by
resetTimeout:

  1. `nextTimeout = el.Value.(*replyMatcher)` at the top of the loop.
     This assignment is what gives `nextTimeout` its documented meaning
     ("head of plist when timeout was last reset"), and what makes the
     early-return optimization at the top of resetTimeout work. Without
     it, nextTimeout is only ever written to nil, so
     `nextTimeout == plist.Front().Value` is always false and the
     optimization is dead.

  2. `nextTimeout.errc <- errClockWarp` in the clock-warp branch now
     reads a stale or nil pointer. Prior to the refactor, the inner
     assignment kept nextTimeout pointing at the current matcher so its
     errc was the right channel to receive the errClockWarp signal.
     After the refactor, on first entry into the clock-warp branch
     nextTimeout is nil, which panics the UDPv4 loop goroutine with a
     nil pointer deref and takes discv4 down.

Re-assign `nextTimeout = p` at the head of the loop (restoring the
documented invariant) and send the clock-warp error on `p.errc` rather
than the now-stale `nextTimeout.errc`.

The clock-warp branch triggers only when the system clock jumps
backward after a deadline is assigned (deadline - time.Now() >=
2*respTimeout, i.e. at least ~500ms backward jump), which is why this
regression slipped past CI - it is not exercised by any existing unit
test, and writing one would require plumbing a clock through the loop.
2026-05-05 15:53:58 +08:00
..
discover p2p/discover: restore nextTimeout update in UDPv4 resetTimeout loop 2026-05-05 15:53:58 +08:00
dnsdisc crypto/keccak: vendor in golang.org/x/crypto/sha3 (#33323) 2026-02-03 14:55:27 -07:00
enode crypto/keccak: vendor in golang.org/x/crypto/sha3 (#33323) 2026-02-03 14:55:27 -07:00
enr p2p/enode: add quic ENR entry (#30283) 2024-09-13 23:47:18 +02:00
msgrate p2p: using math.MaxInt32 from go std lib (#32357) 2025-08-20 16:22:21 -06:00
nat p2p/nat: fix err shadowing in UPnP addAnyPortMapping (#33355) 2025-12-08 15:02:24 +01:00
netutil p2p: using testing.B.Loop (#32664) 2025-09-19 16:38:36 -06:00
pipes all: update license comments and AUTHORS (#31133) 2025-02-05 23:01:17 +01:00
rlpx crypto/keccak: vendor in golang.org/x/crypto/sha3 (#33323) 2026-02-03 14:55:27 -07:00
tracker p2p/tracker: fix crash in clean when tracker is stopped (#33940) 2026-03-03 12:54:24 +01:00
config.go p2p: update MaxPeers comment (#32414) 2025-08-19 20:14:11 +08:00
config_toml.go p2p: support configuring NAT in TOML file (#31041) 2025-01-22 09:29:34 +01:00
dial.go p2p: track in-progress inbound node IDs (#33198) 2026-03-20 05:52:15 +01:00
dial_test.go p2p: track in-progress inbound node IDs (#33198) 2026-03-20 05:52:15 +01:00
message.go p2p: use atomic types (#27764) 2023-08-01 23:20:52 +02:00
message_test.go p2p: move rlpx into separate package (#21464) 2020-09-22 10:17:39 +02:00
metrics.go p2p: add metrics for inbound connection errors (#31652) 2025-05-07 15:34:52 +02:00
peer.go p2p: remove todo comment, as it's unnecessary (#32397) 2025-08-21 15:48:46 -06:00
peer_error.go p2p: fix DiscReason encoding/decoding (#30855) 2024-12-12 12:33:42 +01:00
peer_test.go p2p: DNS resolution for static nodes (#30822) 2024-12-13 12:46:12 +01:00
protocol.go all: use cmp.Compare (#30958) 2025-01-02 14:06:47 +01:00
server.go p2p: track in-progress inbound node IDs (#33198) 2026-03-20 05:52:15 +01:00
server_nat.go p2p/nat: fix UPnP port reset (#31566) 2025-04-09 11:28:29 +02:00
server_nat_test.go p2p: fix flaky test TestServerPortMapping (#30241) 2024-07-30 07:31:27 -06:00
server_test.go p2p: cleanup v4 if v5 failed (#33005) 2025-10-29 10:34:19 +01:00
transport.go p2p: fix DiscReason encoding/decoding (#30855) 2024-12-12 12:33:42 +01:00
transport_test.go p2p: fix DiscReason encoding/decoding (#30855) 2024-12-12 12:33:42 +01:00
util.go all: assign zero after resize in implementations of heap.Interface (#26296) 2022-12-05 13:49:54 +01:00
util_test.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00