Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: track closest peers separately from main routing table #2748

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Oct 4, 2024

The routing table is a balance trie where the path to the leaf node storing the contact is derived from the prefix of the kad id of the contact.

This makes it great for starting a query because we can quickly find contacts in the kad-vicinity of the target, but it's less good for knowing peers that are in our kad-vicinity, since the bits that make us kad-close to another peer might not be in the prefix.

Currently we track which leaf-node our peer id would be in and tag all contacts in that bucket with KEEP_ALIVE. This misses many potentially much closer peers as their KadIDs do not share the same prefix.

Instead, use a peer distance list that we update whenever a peer successfully completes a PING operation. Periodically check this list and tag the closes peers with KEEP_ALIVE so we maintain connections to them, which will ensure we propagate changes in our PeerInfo to those peers most likely to answer FIND_PEER queries for our data, and remove the tag from peers that have fallen out of the list due to closer peers having been discovered.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

The routing table is a balance trie where the path to the leaf node
storing the contact is derived from the prefix of the kad id of the
contact.

This makes it great for starting a query because we can quickly find
contacts in the kad-vicinity of the target, but it's less good for
knowing peers that are in our kad-vicinity, since the bits that make
us kad-close to another peer might not be in the prefix.

Instead, use a peer distance list that we update whenever a peer
successfully completes a `PING` operation.  Periodically check this
list and tag the closes peers with `KEEP_ALIVE` so we maintain
connections to them, which will ensure we propagate changes in our
PeerInfo to those peers most likely to answer `FIND_PEER` queries
for our data.
@achingbrain achingbrain requested a review from a team as a code owner October 4, 2024 16:13
@achingbrain achingbrain merged commit 27b2fa6 into main Oct 5, 2024
23 checks passed
@achingbrain achingbrain deleted the fix/track-closest-peers-separately branch October 5, 2024 07:47
@achingbrain achingbrain mentioned this pull request Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant