go-ethereum/node
Felix Lange 6a9158bb1b
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-05-23 14:26:09 +02:00
..
api.go p2p/discover: improved node revalidation (#29572) 2024-05-23 14:26:09 +02:00
api_test.go graphql, node, rpc: improve HTTP write timeout handling (#25457) 2022-12-07 14:02:14 +01:00
config.go node: fix listening on IPv6 address (#27628) (#27635) 2023-07-02 13:21:16 +02:00
config_test.go node: remove noop path.Join (#25475) 2022-08-04 10:42:03 +03:00
defaults.go node, rpc: add configurable HTTP request limit (#28948) 2024-02-07 21:06:38 +01:00
doc.go build: upgrade to go 1.19 (#25726) 2022-09-10 13:25:40 +02:00
endpoints.go node, rpc: add ReadHeaderTimeout config option (#25338) 2022-08-03 16:50:12 +02:00
errors.go node: refactor package node (#21105) 2020-08-03 19:40:46 +02:00
jwt_auth.go node, rpc: add JWT auth support in client (#24911) 2022-09-02 17:40:41 +02:00
jwt_handler.go node: change JWT error status to 401 Unauthorized (#25629) 2022-08-30 15:25:02 +02:00
lifecycle.go node: refactor package node (#21105) 2020-08-03 19:40:46 +02:00
node.go core/rawdb: implement in-memory freezer (#29135) 2024-04-30 11:33:22 +02:00
node_auth_test.go all: replace path.Join with filepath.Join (#29479) 2024-04-08 12:29:49 +03:00
node_example_test.go build: upgrade to go 1.19 (#25726) 2022-09-10 13:25:40 +02:00
node_test.go all: use slices.Contains (#29459) 2024-04-06 12:05:06 +02:00
rpcstack.go all: fix mismatched names in comments (#29348) 2024-03-26 21:01:28 +01:00
rpcstack_test.go rpc: add limit for batch request items and response size (#26681) 2023-06-13 13:38:58 +02:00
utils_test.go all: remove version field from rpc.API 2022-06-27 12:39:46 +02:00