go-ethereum/node
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
..
api.go p2p/discover: improved node revalidation (#29572) 2024-06-11 13:53:35 +05:30
api_test.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
config.go merge geth v1.12.2 into develop 2023-08-18 14:05:34 +05:30
config_test.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
defaults.go Merge tag 'v1.13.5' of https://github.com/ethereum/go-ethereum into shivam/upstream-geth-1.13.5 2023-12-15 13:55:57 +05:30
doc.go build: upgrade to go 1.19 (#25726) 2022-09-10 13:25:40 +02:00
endpoints.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
errors.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
jwt_auth.go fix testcases 2023-09-21 21:07:50 +05:30
jwt_handler.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
lifecycle.go node: refactor package node (#21105) 2020-08-03 19:40:46 +02:00
node.go Enable ancient block pruning (#1216) 2024-05-09 11:19:34 +05:30
node_auth_test.go fix test-integration 2023-09-20 21:44:07 +05:30
node_example_test.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
node_test.go fix : resolve static problems 2023-12-15 13:57:19 +05:30
rpcstack.go fix tests 2023-09-22 15:03:24 +05:30
rpcstack_test.go fix test-integration 2023-09-20 21:44:07 +05:30
utils_test.go dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00