-
Notifications
You must be signed in to change notification settings - Fork 769
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
upgrade libp2p to v0.53.* #4935
Conversation
@mxinden I'm curious about the bandwidth metrics here. I'm getting for example
What's the difference between
|
Here either a
Here either a Not quite ideal. We could add the peer id to the multiaddr in case it doesn't have one once the dial succeeded, and thus always have a |
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 Diva!
// Creates the TCP transport layer | ||
let (tcp, tcp_bandwidth) = |
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 we can now incorporate Max's changes presented on #4695. If you feel like it's too much work don't worry, I can do it on a subsequent 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.
I looked into this but it looks less clean imo to jam the tcp configuration in a closure when it's already well contained in a function (build_transport
). In that PR Thomas notes as well this. Tbh I don't see the benefit
thanks @jxs. However this is not yet properly tested (thus the draft status). This upgrade also affects the way libp2p handles closing handlers so it would be good if @AgeManning gives a look at the RPC handler changes. I went with a simple approach that I think should work but I'd like his opinion on this |
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.
With the RPC things I'm not sure this will work.
Can we no longer close connections at the handler level?
We designed lighthouse such that it was ultimately the RPC connection handler that closes connections to peers, so that we could send a goodbye message to them before we drop the connection.
Unless libp2p have changed some things, I recall that the connection_keep_alive
is grouped with all other behaviours. So even if the RPC says the keep_alive is false, the connection won't close if gossipsub's keep_alive is true or identify or ping etc.
I think we might need to explicitly inform the behaviour to drop the connection if we can't do it in the handler any more.
There is a chance I'm wrong about this, will have to double check.
yeah, see libp2p/rust-libp2p#4755 |
yeah I mentioned this in the description
Which is a bit annoying and somewhat reverts to the state of things a couple of years back. There is a way to ignore for keep alive, where our problematic contender would be gossipsub. I'll look into that. Otherwise we would need to bubble up a new error kind since right now reporting is done on a substream level and the couple of errors modified do not fit in this model. I'll try to check the first approach before going with modifying the handler errors |
Well, that idea died rather quickly.
@mxinden would it make sense to allow the For this PR tho, I'll go with sending up the errors to the behaviour for it to close the connection. This approach is more resilient to changes in libp2p internals anyway |
HandlerEvent::Close(_) => { | ||
let _ = self.swarm.disconnect_peer_id(peer_id); |
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 for the noise @mxinden
I think the new API does not fully allow the previous behavior.
When emitting an event from the handler, this is received on swarm.poll_next_unpin
without the information of the connection_id
, so that this line could be close_connection
instead.
For LH this is good enough since we allow only one connection per peer, but it seems like a slight regression in connection management in libp2p.
Now, if there is a way to achieve this "the correct way" (closing the specific connection) and this is an oversight on my part, happy to hear and use the alternative in this 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.
I am missing context here. What is HandlerEvent::Close
? I can only find this type alias:
/// Events the handler emits to the behaviour.
pub type HandlerEvent<Id, T> = Result<RPCReceived<Id, T>, HandlerErr<Id>>;
I am assuming that this is std
's Result
which does not have a Close
variant.
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 what you are missing is a pull max. This type is no longer a result
Can you summarize the motivation behind this change? Note that |
pub enum HandlerEvent<Id, T: EthSpec> { | ||
Ok(RPCReceived<Id, T>), | ||
Err(HandlerErr<Id>), | ||
Close(RPCError), | ||
} |
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.
@mxinden are you missing a pull?
Deriving Also, the issue is not to prevent closing, but to trigger it |
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.
Yeah this is a nice soln!
Just a single comment
Issue Addressed
Upgrades libp2p to v0.53. See https://github.com/libp2p/rust-libp2p/releases/tag/libp2p-v0.53.0 and the subsequent
.1
releaseProposed Changes
This adds metrics for the transports directly from libp2p with a better granularity. It also changes the way handlers are closed. We no longer have a way to force closing a handler, instead libp2p relies on checking established substreams. Rest of the changes are not too relevant
Additional Info
na