-
Notifications
You must be signed in to change notification settings - Fork 1k
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
refactor(kad): make Kademlia::add_address
return Result
#4280
Draft
arsenron
wants to merge
11
commits into
libp2p:master
Choose a base branch
from
arsenron:kad-add-address
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
aef9507
Make `Kademlia::add_address` return Result
arsenron 60c25b7
Expose `RoutingUpdateError`
arsenron 82133f3
Update examples
arsenron fd1b37c
Add expect to network example
arsenron 992cddf
fmt
arsenron a650274
Merge branch 'master' into kad-add-address
thomaseizinger a117e25
Try fix CI and update changelog
arsenron 11f3a17
Merge remote-tracking branch 'upstream/master' into kad-add-address
arsenron c79058b
Merge branch 'master' into kad-add-address
thomaseizinger 5fe3128
Merge branch 'master' into kad-add-address
thomaseizinger 64f3243
Merge branch 'master' into kad-add-address
thomaseizinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name = "libp2p-kad" | |
edition = "2021" | ||
rust-version = { workspace = true } | ||
description = "Kademlia protocol for libp2p" | ||
version = "0.44.5" | ||
version = "0.45.0" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
license = "MIT" | ||
repository = "https://github.com/libp2p/rust-libp2p" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry that this is only coming up now but I just realized that we have a feature coming up that conflicts with this idea. It is here: #4371
This function will likely be deprecated in favor of a general
add_address_of_peer
function onSwarm
. This means, we won't be able to return a specific error there!In fact, we won't be able to return anything at all.
Thus, I think we should actually change this PR into preparing this API for the above change. Here is what I'd suggest but I am interested to hear your and @mxinden's opinion:
RoutingUpdate
as deprecated but retain the current functionality.KademliaEvent::RoutingUpdated
, even for the immediateRoutingUpdate::Success
casedebug_assert
to theSelfEntry
case. If we attempt to add ourselves to the routing table, this is a programmer bug and should not happen. We can ignore that in production (but should probably emit a fatwarn!
), hence thedebug_assert
.This makes this a backwards-compatible change and we can land it right away.
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.
I missed this as well. I am sorry @arsenron.
Suggestion overall sounds good to me.
Panicing on invalid user input seems rather drastic. Wouldn't a
warn!
suffice in all cases? Also, not as part of this pull request, we should handle theSelfEntry
on thelibp2p-swarm
level. We should at least log when aNetworkBehaviour
or user (viaSwarm::add_address_of_peer
) wants to report a an external address of a remote peer where that peer is actually the local peer.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.
The warn will be there in all cases but pancking in debug builds is fine, no? You didn't validate your inputs correctly in that case.
True, as part of #4371, we should probably not forward any of these events! cc @StemCll
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.
@arsenron I fixed the merge conflicts for you. Are you still interested in working on this given the above insight?
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.
@thomaseizinger sorry, little busy now, but I will check it a bit later