go-ethereum/internal
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
..
blocktest internal/blocktest: add package for shared test code (#27270) 2023-07-11 14:57:02 +02:00
build 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
cli remove additional bootnodes (#1255) 2024-06-06 23:13:43 +05:30
cmdtest 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
debug Revert "Merge upstream_merge branch to develop (#1229)" 2024-05-28 14:10:49 +05:30
ethapi Merge branch 'develop' of https://github.com/maticnetwork/bor into upstream_merge 2024-05-28 22:24:54 +05:30
flags Revert "Merge upstream_merge branch to develop (#1229)" 2024-05-28 14:10:49 +05:30
guide dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
jsre Merge branch 'develop' of https://github.com/maticnetwork/bor into upstream_merge 2024-05-28 17:20:23 +05:30
reexec all: make vendored copy of reexec (#28382) 2023-10-28 00:14:43 +02:00
shutdowncheck dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
syncx dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
testlog p2p/discover: improved node revalidation (#29572) 2024-06-11 13:53:35 +05:30
utesting dev: fix: most of wsl lint issues 2023-06-15 15:48:26 +02:00
version dev: fix: more wsl lint issues 2023-06-15 13:06:10 +02:00
web3ext eth/internal: add debug.peerStats for stats related to all connected peers (#1252) 2024-05-28 17:51:00 +05:30