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

P2P: Periodically eject unreachable peers from AddressBook + Replace Peer list IndexMap by BucketMap #339

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SyntheticBird45
Copy link
Member

What

Fixes parts of: #178

  • Implements PeerPinger in cuprate-p2p. This background task will periodically fetch a random white and gray peers and try to ping them. Replace them in the list if successful, drop it otherwise.
  • Added a new AddWhitePeer request to AddressBookRequest. Needed for the PeerPinger to replace white peers.
  • Renamed Bucket as BucketMap.
  • Completed BucketMap API for usage within peer_list.rs in cuprate-address-book.
  • Added Bucketable trait as a dependency for NetZoneAddress and implemented discrimination to SocketAddr.

Why

As described in #178, Cuprate will at the moment keep indefinitely any peer contained in its list, even ones that may not be reachable anymore in the long/mid-term.

The use of BucketMap instead of IndexMap will ensure that we store at most N amount of IP addresses from the same subnet. This ensure a form of diversity and could potentially help at mitigating monero-project/research-lab#126

@github-actions github-actions bot added A-p2p Related to P2P. A-test-utils Related to test-utils. A-dependency Related to dependencies, or changes to a Cargo.{toml,lock} file. A-workspace Changes to a root workspace file or general repo file. labels Nov 10, 2024
@SyntheticBird45
Copy link
Member Author

SyntheticBird45 commented Nov 10, 2024

@Boog900 I would appreciate an ahead of time review of the API changes before I pass to test coverage and documentation fixes.
Also I defined N at 8. So the bucket is storing up to 8 IP addresses of the same subnet. Do you wanna change it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependency Related to dependencies, or changes to a Cargo.{toml,lock} file. A-p2p Related to P2P. A-test-utils Related to test-utils. A-workspace Changes to a root workspace file or general repo file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant