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

kad: Implement put_record_to and try_put_record_to (#77) #82

Merged
merged 3 commits into from
Apr 19, 2024

Conversation

lexnv
Copy link
Collaborator

@lexnv lexnv commented Apr 19, 2024

This PR implements the put_record_to and try_put_record_to to selectively pick peers to update their records.

The main use-case from substrate would be the following:

This PR provided peers to the engine if the peers are part of the kBucket. The first step of the discovery in substrate motivates this assumption. We can probably do things a bit more optimally since we know the peers part of the kBucket were discovered previously (or currently connected):

  • The query starts with a FindNodeContext, which in this case will do a peer discovery as well
  • We could implement a PutNodeContext which circumvents the need to discover the peers and just forwards a kad PUT_VALUE to those peers We'd have to double check that with libp2p as well (my brief looking over code points to this direction).

To unblock paritytech/polkadot-sdk#3786 we can merge this and then come back with a better / optimal solution for this

Builds on top of: #76

cc @paritytech/networking


lexnv added 2 commits April 19, 2024 16:58
This PR implements the `put_record_to` and `try_put_record_to` to
selectively pick peers to update their records.

The main use-case from substrate would be the following:
- A peer is discovered to have an outdated authority record (needs
#76)
- Update the record with the latest authority record available (part of
this PR)

This PR provided peers to the engine if the peers are part of the
kBucket. The first step of the discovery in substrate motivates this
assumption. We can probably do things a bit more optimally since we know
the peers part of the kBucket were discovered previously (or currently
connected):
- The query starts with a
[FindNodeContext](https://github.com/paritytech/litep2p/blob/96e827b54f9f937c6d0489bef6a438b48cf50e58/src/protocol/libp2p/kademlia/query/find_node.rs#L37),
which in this case will do a peer discovery as well
- We could implement a `PutNodeContext` which circumvents the need to
discover the peers and just forwards a kad `PUT_VALUE` to those peers
We'd have to double check that with libp2p as well (my brief looking
over code points to this direction).

To unblock paritytech/polkadot-sdk#3786 we can
merge this and then come back with a better / optimal solution for this

Builds on top of: #76

cc @paritytech/networking

---------

Signed-off-by: Alexandru Vasile <[email protected]>
@lexnv
Copy link
Collaborator Author

lexnv commented Apr 19, 2024

Forgot to change branch of #77 to master 🙈

@lexnv lexnv merged commit 84267ad into master Apr 19, 2024
7 checks passed
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