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.
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(gossipsub): use signed peer records on handle prune #3579
feat(gossipsub): use signed peer records on handle prune #3579
Changes from all commits
2e82b4b
2265a9e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 know this should have been done earlier, probably on line 1617.
I think we probably don't want to try to connect to all the peers, we probably only want to try and get up to
mesh_n_high
. I'd suggest we setn
on line 1617 to be the min ofself.config.prune_peers()
orself.mesh.get(&topic_hash).map(|x| x.len()).unwrap_or(0)
or something. Which may mean calculating this inhandle_prune()
because we don't have the topic hash here.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.
Agree with the needed change in general.
Note that
prune_peers
according to our docs configure the number of peers we send to others, not the number of peers we connect to. Either code or docs need to be adjusted. But using the current docs, this should probably not be used here (or inhandle_prune
)It's also not clear to me if handling the prune is the best place to connect to those peers. We already graft peers in the heartbeat when below
mesh_n_low
. We might want to connect to these peers to accelerate the process, or we might want to prioritize already connected peers since they are somewhat more trusted. In any case, bothmesh_n_high
andmesh_n_low
should probably be used to select the number of peers from this set we want to try.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.
PeerExchange is meant to give you more peers in case you are only connected to a few, right?
Perhaps it would be better to just add those to some kind of list and let the grafting logic upon heartbeats do the connecting?
For the case where we don't have many peers, that would otherwise "fail" in that we can't connect to as many peers as we'd like.
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.
Those are good points, and path forward is opinionated. Maintainers and @divagant-martian @AgeManning could you comment on what makes more sense?
IMO connecting eagerly instead of accumulating keep it simpler + limit only up to mesh needs. For reference Go impl eagerly schedules all peer exchanges to the connect channel (with max cap MaxPendingConnections)
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've not touched gossipsub much so I'll leave it to @mxinden and @AgeManning to make a decision here.
That is an interesting data point.
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.
For the sake of unblocking this PR we can go with eager connection, since as Age mentioned, this needs to be explicitly turned on.
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.
@AgeManning Should
do_px
be used to not consume px by default? Or add a new config param likeuse_px
to split provision and consumption of pxThere 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 think we should have a more explicit config. I think we should opt for
enable_peer_exchange()
which enables both sending and receiving. I dont think users really need granularity over one or the other (we can add it later if its requested).I'd suggest renaming
do_px
toenable_peer_exchange
. Have it off my default.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.
@dapplion to achieve this you technically need to change nothing. This is already the case. Age's suggestion is a nice to have, but would change the public api, so the version should be updated accordingly. I'm fine with doing or not doing this change
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.
We can do it in a non-breaking way by adding
enable_peer_exchange
onConfig
and deprecating thedo_px
function. Internally, the field can be renamed without issues.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.
likely to fail?
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 think it would be good to assert the presence of the addresses too!
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.
Any suggestion on how to retrieve the addresses from DialOpts struct?
rust-libp2p/protocols/gossipsub/src/behaviour/tests.rs
Lines 1896 to 1897 in 3f5dd63
Or should I make this fn public?
rust-libp2p/swarm/src/dial_opts.rs
Lines 130 to 132 in d81f947
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 am not really a fan of the style of the tests in gossipsub anyway. We should only be testing behaviours by running them in a
Swarm
and not call these lifecycle functions manually.We now have a new crate,
libp2p-swarm-test
which makes it easy to set up swarms for testing.How about we do the following:
libp2p-swarm-test
that ends up sending aPrune
to a node which will then contain theSignedPeerRecord
Swarm
establishes a connection to the node specified in the prune messageWhat do you think?
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.
going this way seems reasonable to me
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.
That makes tho if all tests in this package are written with a consistent style, should this PR stick to that style? And then refactor them into using swarm-test in another PR
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.
Eventually yes but that is a massive effort. I don't mind mixing styles in a transition period if we get a better, more feature-oriented test in exchange.