Skip to content

feat: discovery protocol peers revalidation#402

Merged
MarcosNicolau merged 16 commits into
mainfrom
feat/peers-revalidation
Sep 17, 2024
Merged

feat: discovery protocol peers revalidation#402
MarcosNicolau merged 16 commits into
mainfrom
feat/peers-revalidation

Conversation

@MarcosNicolau

@MarcosNicolau MarcosNicolau commented Sep 16, 2024

Copy link
Copy Markdown
Contributor

Motivation

This pr implements peers revalidation loop.

Description

In the discovery protocol, every 10min (this could be any number actually), we need to ping back those peers whose last ping was 24hs ago to re-validate the endpoint proof, if they don't ping back, we replace them with one from the replacements list.

Changes:

  • Discovery main function now spawns two tokio tasks: discover_peers_server (the one we already had) and peers_revalidation.
  • UdpSocket and KademliaTable were modified to be thread/concurrent safe.
  • peers_revalidation implements a tokio interval that lasts 10min and works in the following way:
    1. First we get the peers to revalidate: those that haven't pinged for 24hs.
    2. We check if each peer has been already pinged in the last iteration. If not, jump to step 3, otherwise to step 4.
    3. We invalidate the endpoint proof and ping it so that we can revalidate the proof. Finally, we pushed the peer to a list so that we can validate it in the next iteration.
    4. We check if the peer is proven. If not, it means it hasn't ping back, so we replace it with the latest pushed peer from the replacement list. If there isn't a replacement, we simply remove the peer from the bucket.

This implementation is supported by some custom unit tests and e2e tests.

Advances on issue #154.

@MarcosNicolau MarcosNicolau requested a review from a team as a code owner September 16, 2024 13:22
Comment thread crates/net/kademlia.rs Outdated
Comment thread crates/net/net.rs Outdated

@mpaulucci mpaulucci left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments, great work 🚀

@MarcosNicolau MarcosNicolau added this pull request to the merge queue Sep 17, 2024
Merged via the queue into main with commit eeed7b4 Sep 17, 2024
@MarcosNicolau MarcosNicolau deleted the feat/peers-revalidation branch September 17, 2024 16:29
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.

2 participants