-
Couldn't load subscription status.
- Fork 254
Add a timeout to inbound libp2p-kad substreams #3492
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
Conversation
3f7942c to
26d98fa
Compare
26d98fa to
7e3d618
Compare
| [patch."https://github.com/autonomys/rust-libp2p.git"] | ||
| # Patch away `libp2p` in our dependency tree with the git version. | ||
| # This brings the fixes in our `libp2p` fork into substrate's dependencies. | ||
| # | ||
| # This is a hack: patches to the same repository are rejected by `cargo`. But it considers | ||
| # "subspace/rust-libp2p" and "autonomys/rust-libp2p" to be different repositories, even though | ||
| # they're redirected to the same place by GitHub, so it allows this patch. | ||
| libp2p = { git = "https://github.com/subspace/rust-libp2p", rev = "399c4c7fcba821a7bac2663e090a7b155b08ebe1" } | ||
| libp2p-identity = { git = "https://github.com/subspace/rust-libp2p", rev = "399c4c7fcba821a7bac2663e090a7b155b08ebe1" } | ||
| multistream-select = { git = "https://github.com/subspace/rust-libp2p", rev = "399c4c7fcba821a7bac2663e090a7b155b08ebe1" } |
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.
This looks really awkward. I understand why it works, but is it really not possible to patch autonomys with a different autonomys revision? Or wouldn't it converge on the same revision automatically on its own?
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.
No, patches can only come from different sources, because [patch] is a source-to-source replacement, filtered by crate name:
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
It's not super clear in the documentation, but cargo returns the error:
patch for
libp2pinhttps://github.com/autonomys/subspacepoints to the same source, but patches must point to different sources
And it does canonicalisation, which means we can't just use subspace.git and subspace.
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 also can't convince it to converge on the same revision, because that only works for crates.io and similar registries. Git versions are fixed to the specific commit hash.
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.
Very unfortunate 😕
| [patch."https://github.com/autonomys/rust-libp2p.git"] | ||
| # Patch away `libp2p` in our dependency tree with the git version. | ||
| # This brings the fixes in our `libp2p` fork into substrate's dependencies. | ||
| # | ||
| # This is a hack: patches to the same repository are rejected by `cargo`. But it considers | ||
| # "subspace/rust-libp2p" and "autonomys/rust-libp2p" to be different repositories, even though | ||
| # they're redirected to the same place by GitHub, so it allows this patch. | ||
| libp2p = { git = "https://github.com/subspace/rust-libp2p", rev = "399c4c7fcba821a7bac2663e090a7b155b08ebe1" } | ||
| libp2p-identity = { git = "https://github.com/subspace/rust-libp2p", rev = "399c4c7fcba821a7bac2663e090a7b155b08ebe1" } | ||
| multistream-select = { git = "https://github.com/subspace/rust-libp2p", rev = "399c4c7fcba821a7bac2663e090a7b155b08ebe1" } |
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.
Very unfortunate 😕
This PR upgrades:
thepolkadot-sdkversion in our fork to Add a timeout to inbound libp2p-kad substreams polkadot-sdk#29libp2pversion in our fork to Add a timeout to inboundkadsubstreams rust-libp2p#2It adds an inbound substream timeout to the kad protocol, which matches the outbound substream timeout. This prevents "substream limit exceeded" errors under load, caused by the outbound side timing out, but the inbound side keeping on waiting.
See PR autonomys/rust-libp2p#2 for full details.
Close #3450.
This code has been tested on multiple operator nodes, and it prevents the substream limit exceeded errors.
Note about patching
You usually can't patch one crate version with another version, you have to change the crate fork/source as well:
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
The patch only works because
cargoconsidershttps://github.com/subspace/rust-libp2pandhttps://github.com/autonomys/rust-libp2pto be different repositories. Because ourpolkadot-sdkfork depends on the autonomys URL, we can patch using the subspace URL.Code contributor checklist: