-
Notifications
You must be signed in to change notification settings - Fork 64
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 version 0.53.1 #1977
Conversation
68e4756
to
d13d4aa
Compare
d13d4aa
to
056ffe5
Compare
Depending on libp2p/rust-libp2p#4889 to get rid of our fork, I guess. |
056ffe5
to
6cb3d1e
Compare
Yes, thanks for adding the reference. |
6cb3d1e
to
b2cd13c
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.
Amazing work! :)
I left a couple of comments and questions.
66ae543
to
9dba7b0
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.
rust-libp2p
maintainer here. Upgrade looks clean, well done.
I've left a couple of comments :)
/// Peer is banned | ||
#[error("Peer is banned")] | ||
BannedPeer, |
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.
FYI, there is also a module that supports peer banning: https://docs.rs/libp2p/latest/libp2p/allow_block_list/index.html
@@ -86,7 +86,7 @@ pub enum DiscoveryMessage { | |||
pub struct DiscoveryProtocol; |
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.
You might want to use ReadyUpgrade
here instead.
type Request = IncomingRequest; | ||
type Response = OutgoingResponse; |
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.
Whilst certainly possible, this trait was designed with the idea in mind that you'd use typed messages here and not just (length-prefixed) bytes :)
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.
Sending bytes back and forth over a "generic" request-response protocol kind of negates the idea of using protocols for multiplexing because you need another, nested layer that allows you to differentiate, which message got sent to you.
YMMV but it might be easier to have multiple instances of libp2p-request-response
, all with a different codec and more specific protocols that only sent specific messages back and forth (or perhaps only a single message-type per protocol).
#[cfg(not(target_family = "wasm"))] | ||
let swarm = SwarmBuilder::with_existing_identity(keypair) | ||
.with_tokio() | ||
.with_other_transport(|_| transport) |
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.
A big benefit of the new SwarmBuilder
is that it enforces at compile-time, that you compose transports together correctly. For example, DNS needs to wrap all other transports (except relay).
By using with_other_transport
, you are not leveraging any of this. I would suggest to refactor this into two functions, one of them for wasm
and the other one non-wasm
and use the entire SwarmBuilder
in there, without any further conditionally-compiled code.
"Sent Ping and received response to/from peer", | ||
); | ||
Ok(duration) => { | ||
log::trace!(?event.peer, ?duration, "Successful ping from 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.
FYI: libp2p-ping
already has such a log on debug
level.
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.
Also, version v0.53
is now using tracing
instead of log
so if you are wondering, why you aren't seeing any messages, it is because you need to set up a tracing-subscriber
.
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're also using tracing
, actually, we just renamed it to log
so as to not touch every file.
FYI: libp2p-ping already has such a log on debug level.
Since we cap other crates at the info!
level usually and sometimes increase the logging level for our crates only, this can still make sense.
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're also using
tracing
, actually, we just renamed it tolog
so as to not touch every file.FYI: libp2p-ping already has such a log on debug level.
Since we cap other crates at the
info!
level usually and sometimes increase the logging level for our crates only, this can still make sense.
Of course! I just mentioned it so you know you could achieve the same thing with configuration instead of writing the code yourself :)
Each connection also has a span that adds context such as the remote's PeerId
and address: https://github.com/libp2p/rust-libp2p/blob/0ceb6580941c010edff2a5689ada2e9e33c773cb/swarm/src/connection/pool.rs#L534
Hence, all logs from within the ConnectionHandler
are automatically scoped to this :)
We've only recently transitioned to this and I'd be very curious to learn how helpful it is to users!
|
||
let mut swarm = Swarm::with_threadpool_executor(transport, behaviour, peer_id); | ||
let mut swarm = SwarmBuilder::with_existing_identity(keypair) |
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.
There is also libp2p-swarm-test
which allows for quick, in-memory testing of Swarm
s.
Thanks for taking a look at this PR, @thomaseizinger. |
dca4e37
to
00ac607
Compare
Hey, thank you very much for taking the time to review it and kudos for the recent improvements in |
66d2c9b
to
0868856
Compare
Upgrade libp2p to version 0.53.1 using a forked version for now due to the lack of support of workers in the `websocket-websys` transport. This also modifies most of the network code to use the adopted libp2p naming standard. Co-authored-by: hrxi <[email protected]>
0868856
to
c447dc2
Compare
Upgrade libp2p to version 0.53.1 using a forked version for now due to the lack of support of workers in the
websocket-websys
transport.This also modifies most of the network code to use the adapted libp2p naming standard.
Pull request checklist
clippy
andrustfmt
warnings.