-
Notifications
You must be signed in to change notification settings - Fork 739
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 from 0.52.4 to 0.54.1 #6248
Conversation
Looks like something called |
1d112cd
to
7903b11
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.
Nothing scary indeed. Thanks a lot for upgrading libp2p for us!
// Populate kad with both the legacy and the new protocol names. | ||
// Remove the legacy protocol: | ||
// https://github.com/paritytech/polkadot-sdk/issues/504 | ||
let kademlia_protocols = if let Some(legacy_protocol) = kademlia_legacy_protocol { | ||
vec![kademlia_protocol.clone(), legacy_protocol] | ||
} else { | ||
vec![kademlia_protocol.clone()] | ||
}; |
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.
Looks good! We should finally do this)
substrate/client/network/src/protocol/notifications/behaviour.rs
Outdated
Show resolved
Hide resolved
/tip small |
Only members of paritytech/tip-bot-approvers have permission to request the creation of the tip referendum from the bot. However, you can create the tip referendum yourself using Polkassembly or PolkadotJS Apps. |
Looks like in your CI |
Looking at the test, it doesn't seem to do anything time consuming. And a longer timeout was not needed with old libp2p? |
It runs quickly on its own, but when running all network tests at once it suddenly takes much longer and always seems to finish later than most tests. Didn't debug why very deeply though, primarily because as comment states it is not really applicable to how it is actually used in Substrate, just test-specific behavior. Pumping to 5 minutes fixed the test and shouldn't be particularly flaky. Not sure about older version, didn't run tests in a loop to try and reproduce, but keep-alive behavior has certainly changed. |
# Conflicts: # Cargo.lock
I remember with previous |
Yes, that was the plan — I was going to do a versi burn-in once it is available after syncing refactoring testing. Last time the issues with libp2p upgrade popped a week after running the nodes, so we need to run a burn-in for at least a week or so. Unfortunately, the branch-off for |
/cmd prdoc --help |
Command help:
|
Any remaining blockers I can help with here? |
Kindly ping, can this be merged? |
We are still running this version in our testnet. If everything is fine by the end of this week, we will merge it. |
@nazar-pc do you have the capacity to look into it? |
I'll try to take a closer look at this soon. Any timeouts like that eventually bite and need to be dealt with, looks like it just happened sooner in this case. Anyone else feel free to beat me to it. |
The test was always flaky, I think it just took longer to tear down connection in the past and now it happens quicker and makes it more likely to spontaneously fail. Simply wait for connection to close on the sender side making sure the message gets delivered to the other side should make it much more deterministic (timeouts are still involved, but extremely unlikely to be triggered). |
# Conflicts: # substrate/client/network/src/discovery.rs
There was a minor conflict in imports, should be good now |
@@ -32203,7 +32089,7 @@ dependencies = [ | |||
"futures", | |||
"glob-match", | |||
"hex", | |||
"libp2p", | |||
"libp2p 0.52.4", |
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.
Just notice that zombienet-orchestrator
still requires libp2p 0.52.4
. However, it won't affect downstream.
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 made a PR for zombienet-sdk
Thanks again @nazar-pc for doing this! |
/tip medium |
The referendum has appeared on Polkassembly. |
# Description Fixes paritytech#5996 https://github.com/libp2p/rust-libp2p/releases/tag/libp2p-v0.53.0 https://github.com/libp2p/rust-libp2p/blob/master/CHANGELOG.md ## Integration Nothing special is needed, just note that `yamux_window_size` is no longer applicable to libp2p (litep2p seems to still have it though). ## Review Notes There are a few simplifications and improvements done in libp2p 0.53 regarding swarm interface, I'll list a few key/applicable here. libp2p/rust-libp2p#4788 removed `write_length_prefixed` function, so I inlined its code instead. libp2p/rust-libp2p#4120 introduced new `libp2p::SwarmBuilder` instead of now deprecated `libp2p::swarm::SwarmBuilder`, the transition is straightforward and quite ergonomic (can be seen in tests). libp2p/rust-libp2p#4581 is the most annoying change I have seen that basically makes many enums `#[non_exhaustive]`. I mapped some, but those that couldn't be mapped I dealt with by printing log messages once they are hit (the best solution I could come up with, at least with stable Rust). libp2p/rust-libp2p#4306 makes connection close as soon as there are no handler using it, so I had to replace `KeepAlive::Until` with an explicit future that flips internal boolean after timeout, achieving the old behavior, though it should ideally be removed completely at some point. `yamux_window_size` is no longer used by libp2p thanks to libp2p/rust-libp2p#4970 and generally Yamux should have a higher performance now. I have resolved and cleaned up all deprecations related to libp2p except `BandwidthSinks`. Libp2p deprecated it (though it is still present in 0.54.1, which is why I didn't handle it just yet). Ideally Substrate would finally [switch to the official Prometheus client](paritytech/substrate#12699), in which case we'd get metrics for free. Otherwise a bit of code will need to be copy-pasted to maintain current behavior with `BandwidthSinks` gone, which I left a TODO about. The biggest change in 0.54.0 is libp2p/rust-libp2p#4568 that changed transport APIs and enabled unconditional potential port reuse, which can lead to very confusing errors if running two Substrate nodes on the same machine without changing listening port explicitly. Overall nothing scary here, but testing is always appreciated. # Checklist * [x] My PR includes a detailed description as outlined in the "Description" and its two subsections above. * [x] My PR follows the [labeling requirements]( https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md#Process ) of this project (at minimum one label for `T` required) * External contributors: ask maintainers to put the right label on your PR. --- Polkadot Address: 1vSxzbyz2cJREAuVWjhXUT1ds8vBzoxn2w4asNpusQKwjJd --------- Co-authored-by: Dmitry Markin <[email protected]> (cherry picked from commit c881288)
Description
Fixes #5996
https://github.com/libp2p/rust-libp2p/releases/tag/libp2p-v0.53.0
https://github.com/libp2p/rust-libp2p/blob/master/CHANGELOG.md
Integration
Nothing special is needed, just note that
yamux_window_size
is no longer applicable to libp2p (litep2p seems to still have it though).Review Notes
There are a few simplifications and improvements done in libp2p 0.53 regarding swarm interface, I'll list a few key/applicable here.
libp2p/rust-libp2p#4788 removed
write_length_prefixed
function, so I inlined its code instead.libp2p/rust-libp2p#4120 introduced new
libp2p::SwarmBuilder
instead of now deprecatedlibp2p::swarm::SwarmBuilder
, the transition is straightforward and quite ergonomic (can be seen in tests).libp2p/rust-libp2p#4581 is the most annoying change I have seen that basically makes many enums
#[non_exhaustive]
. I mapped some, but those that couldn't be mapped I dealt with by printing log messages once they are hit (the best solution I could come up with, at least with stable Rust).libp2p/rust-libp2p#4306 makes connection close as soon as there are no handler using it, so I had to replace
KeepAlive::Until
with an explicit future that flips internal boolean after timeout, achieving the old behavior, though it should ideally be removed completely at some point.yamux_window_size
is no longer used by libp2p thanks to libp2p/rust-libp2p#4970 and generally Yamux should have a higher performance now.I have resolved and cleaned up all deprecations related to libp2p except
BandwidthSinks
. Libp2p deprecated it (though it is still present in 0.54.1, which is why I didn't handle it just yet). Ideally Substrate would finally switch to the official Prometheus client, in which case we'd get metrics for free. Otherwise a bit of code will need to be copy-pasted to maintain current behavior withBandwidthSinks
gone, which I left a TODO about.The biggest change in 0.54.0 is libp2p/rust-libp2p#4568 that changed transport APIs and enabled unconditional potential port reuse, which can lead to very confusing errors if running two Substrate nodes on the same machine without changing listening port explicitly.
Overall nothing scary here, but testing is always appreciated.
Checklist
T
required)Polkadot Address: 1vSxzbyz2cJREAuVWjhXUT1ds8vBzoxn2w4asNpusQKwjJd