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

feat(kad): New provider record update strategy #5536

Merged
merged 6 commits into from
Aug 13, 2024
Merged

Conversation

Mivik
Copy link
Contributor

@Mivik Mivik commented Aug 7, 2024

Description

In MemoryStore, the number of provider records per key is limited by max_providers_per_key. Former implementations keep provider records sorted by their distance to the key, and only keep those with the smallest distance. This strategy is vulnerable to Sybil attack, in which an attacker can flood the network with false identities in order to eclipse a key.

This commit change the strategy to simply keep old providers and ignore new ones. This new strategy however, can cause load imbalance, but can be mitigated by increasing max_providers_per_key.

In addition, old implementations failed to keep provided and providers in sync, and this commit fixes this issue.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@Mivik Mivik changed the title feat(kad): Keep provided in sync with providers in MemoryStore fix(kad): Keep provided in sync with providers in MemoryStore Aug 7, 2024
Former implementations keep provider records sorted by their distance to
 the key, however this strategy is vulnerable to Sybil attack, in which
 an attacker can flood the network with false identities in order to
 eclipse a key.

This commit change the strategy to simply keep old providers and ignore
new ones. This new strategy however, can cause load imbalance, but can
be mitigated by increasing `max_providers_per_key`.
@Mivik Mivik changed the title fix(kad): Keep provided in sync with providers in MemoryStore refactor(kad): New provider record update strategy Aug 9, 2024
Copy link
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks @Mivik for your contribution!

Can you also add an entry in the changelog and bump the version of kad?

@Mivik
Copy link
Contributor Author

Mivik commented Aug 13, 2024

Sure, should I bump to 0.47.0 or 0.46.1?

@guillaumemichel
Copy link
Contributor

This is a non-breaking change, so you can bump to 0.46.1

@guillaumemichel guillaumemichel changed the title refactor(kad): New provider record update strategy feat(kad): New provider record update strategy Aug 13, 2024
@mergify mergify bot merged commit d9ee266 into libp2p:master Aug 13, 2024
72 checks passed
TimTinkers pushed a commit to unattended-backpack/rust-libp2p that referenced this pull request Sep 14, 2024
In `MemoryStore`, the number of provider records per key is limited by `max_providers_per_key`. Former implementations keep provider records sorted by their distance to the key, and only keep those with the smallest distance. This strategy is vulnerable to Sybil attack, in which an attacker can flood the network with false identities in order to eclipse a key.

This commit change the strategy to simply keep old providers and ignore new ones. This new strategy however, can cause load imbalance, but can be mitigated by increasing `max_providers_per_key`.

In addition, old implementations failed to keep `provided` and `providers` in sync, and this commit fixes this issue.

Pull-Request: libp2p#5536.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants