-
Notifications
You must be signed in to change notification settings - Fork 959
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): expose a kad query facility allowing dynamic num_results #5555
feat(kad): expose a kad query facility allowing dynamic num_results #5555
Conversation
7b9904a
to
769f893
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maqi for your contribution, this change is indeed needed! I left a few remarks.
This pull request has merge conflicts. Could you please resolve them @maqi? 🙏 |
769f893
to
c0a8cc0
Compare
@guillaumemichel PR updated with using your suggested approach of adding also replied to your another comment regarding the btw. any idea why there is a failing CI https://github.com/libp2p/rust-libp2p/actions/runs/10390288352/job/28770402300?pr=5555 complaining |
c0a8cc0
to
4180ee8
Compare
seems the failing CI requires a major version up on libp2p-kad, as a new variant added into the struct. Though I think it is not necessary, I have to increase the libp2p-kad version to 0.47.0, to get an ALL green CI. |
4180ee8
to
76a05d4
Compare
Hi, @guillaumemichel thx for the review. |
Thanks @maqi, it looks good. It would be great to add a test for the cases where |
Hi, @guillaumemichel I have updated the PR to add a test covering the num_results range of K_VALUE / 2 .. K_VALUE * 2 However, it shows the returned result is capped after exceeds K_VALUE . However, for us, a capped result is acceptable, hence I only put the test according to the current impl. I think to support |
@maqi thanks for adding the tests!
What is your use case? If you need to pass a |
Hi, @guillaumemichel For our case, we need to set the Or, you mean the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I see! A high replication_factor
or num_results
is never expected to return more than K_VALUE
results anyway.
IMO it is fine, because it was never possible to have more than K_VALUE
closest peers in response, this change simply allows users to define a number of expected closest peers between 1
and K_VALUE
. Previously, the number of returned closest peers was set to replication_factor
.
Removing the cap might be tricky, since it would involve forging a new key and additional requests. It can be left to a follow up PR 👍🏻
d4b2a3e
to
b0538af
Compare
Hi, @guillaumemichel , thx for the summary comment. |
b0538af
to
7b5b952
Compare
Sorry for the back-and-forth, but it would be good to have different values of |
150c8e1
to
4acdf2c
Compare
Hi, @guillaumemichel , updated the test according to your suggestion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request has merge conflicts. Could you please resolve them @maqi? 🙏 |
4acdf2c
to
6fbda80
Compare
Hi, @guillaumemichel , may I know the schedule of when the PR will get the second approval to be merged pls? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, and thanks for the interest! Left some comments
6fbda80
to
c540da9
Compare
c540da9
to
1bf218b
Compare
Hi, @jxs , Thx for the review. Replied to one comment, as I'm leading toward |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
…ibp2p#5555) ## Description This PR is to expose a kad query facility that allowing specify num_results dynamically. It is related to the [Sybil Defence issue](libp2p#4769), that during the attempt of implementation on higher level code, it is find will be useful if libp2p-kad can expose such facility. The PR try not to cause any interference to the existing work flow, only introduce an `extra exposal`. ## Change checklist <!-- Please add a Changelog entry in the appropriate crates and bump the crate versions if needed. See <https://github.com/libp2p/rust-libp2p/blob/master/docs/release.md#development-between-releases>--> - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Description
This PR is to expose a kad query facility that allowing specify num_results dynamically.
It is related to the Sybil Defence issue,
that during the attempt of implementation on higher level code, it is find will be useful if libp2p-kad can expose such facility.
The PR try not to cause any interference to the existing work flow, only introduce an
extra exposal
.Change checklist