go-ethereum/p2p
Felix Lange 1351a54287
p2p/discover: improved node revalidation (#29572)
Node discovery periodically revalidates the nodes in its table by sending PING, checking
if they are still alive. I recently noticed some issues with the implementation of this
process, which can cause strange results such as nodes dropping unexpectedly, certain
nodes not getting revalidated often enough, and bad results being returned to incoming
FINDNODE queries.

In this change, the revalidation process is improved with the following logic:

- We maintain two 'revalidation lists' containing the table nodes, named 'fast' and 'slow'.
- The process chooses random nodes from each list on a randomized interval, the interval being
  faster for the 'fast' list, and performs revalidation for the chosen node.
- Whenever a node is newly inserted into the table, it goes into the 'fast' list.
  Once validation passes, it transfers to the 'slow' list. If a request fails, or the
  node changes endpoint, it transfers back into 'fast'.
- livenessChecks is incremented by one for successful checks. Unlike the old implementation,
  we will not drop the node on the first failing check. We instead quickly decay the
  livenessChecks give it another chance.
- Order of nodes in bucket doesn't matter anymore.

I am also adding a debug API endpoint to dump the node table content.

Co-authored-by: Martin HS <martin@swende.se>
2024-06-11 13:53:35 +05:30
..
discover p2p/discover: improved node revalidation (#29572) 2024-06-11 13:53:35 +05:30
dnsdisc merge geth v1.12.2 into develop 2023-08-18 14:05:34 +05:30
enode merge develop 2023-10-16 23:37:44 +05:30
enr dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
msgrate Revert "Merge upstream_merge branch to develop (#1229)" 2024-05-28 14:10:49 +05:30
nat Revert "Merge upstream_merge branch to develop (#1229)" 2024-05-28 14:10:49 +05:30
netutil merge geth v1.12.2 into develop 2023-08-18 14:05:34 +05:30
nodestate merge geth v1.12.2 into develop 2023-08-18 14:05:34 +05:30
rlpx cherry pick to fix lints 2024-05-05 15:47:42 +05:30
simulations Revert "Merge upstream_merge branch to develop (#1229)" 2024-05-28 14:10:49 +05:30
tracker dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
dial.go merge geth v1.12.2 into develop 2023-08-18 14:05:34 +05:30
dial_test.go merge geth v1.12.2 into develop 2023-08-18 14:05:34 +05:30
message.go merge geth v1.12.2 into develop 2023-08-18 14:05:34 +05:30
message_test.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
metrics.go merge geth v1.12.2 into develop 2023-08-18 14:05:34 +05:30
peer.go fix tests 2023-09-22 15:03:24 +05:30
peer_error.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
peer_test.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
protocol.go fix linters 2023-09-21 10:50:01 +05:30
server.go p2p/discover: improved node revalidation (#29572) 2024-06-11 13:53:35 +05:30
server_nat.go cmd/bootnode, p2p: support for alternate mapped ports (#26359) 2023-07-14 14:58:27 +02:00
server_nat_test.go cmd/bootnode, p2p: support for alternate mapped ports (#26359) 2023-07-14 14:58:27 +02:00
server_test.go merge geth v1.12.2 into develop 2023-08-18 14:05:34 +05:30
transport.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
transport_test.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
util.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
util_test.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00