Skip to content
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

Use libp2p-websocket fork to circumvent Sink panic #2657

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

Eligioo
Copy link
Member

@Eligioo Eligioo commented Jun 20, 2024

What's in this pull request?

Currently we are observing issue libp2p/rust-libp2p#5471 which causes a panic when reading/sending data to a peer where the connection already has errored. This PR forks libp2p with a hotfix that won't panic but rather throw an error.

Until libp2p/rust-libp2p#5471 is properly solved, we can use this fix to more gracefully handle the unexpected error. The changes in the fork compared to libp2p v0.53.2 can be found here: compare. It also includes a new test that mimics the behaviour we are observing (calling poll_ready after an error), and checks that it simply throws an error instead of a panic.

This fixes #732.

Pull request checklist

  • All tests pass. The project builds and runs.
  • I have resolved any merge conflicts.
  • I have resolved all clippy and rustfmt warnings.

@Eligioo Eligioo requested review from jsdanielh and hrxi June 20, 2024 15:20
@hrxi
Copy link
Member

hrxi commented Jun 20, 2024

I think it would be good to only override the libp2p-websocket crate.

You can do that by adding

libp2p-websocket = { git = "https://github.com/Eligioo/rust-libp2p", branch = "stefan/quicksink-no-panic" }

to the [patch.crates-io] section of our main Cargo.toml.

You'll also have to adjust the main Cargo.toml of libp2p though:

diff --git a/Cargo.toml b/Cargo.toml
index 11ac47b0b..f7518e250 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -76,7 +76,7 @@ libp2p = { version = "0.53.2", path = "libp2p" }
 libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" }
 libp2p-autonat = { version = "0.12.0", path = "protocols/autonat" }
 libp2p-connection-limits = { version = "0.3.1", path = "misc/connection-limits" }
-libp2p-core = { version = "0.41.2", path = "core" }
+libp2p-core = { version = "0.41.2" }
 libp2p-dcutr = { version = "0.11.0", path = "protocols/dcutr" }
 libp2p-dns = { version = "0.41.1", path = "transports/dns" }
 libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" }
@@ -119,7 +119,7 @@ multistream-select = { version = "0.13.0", path = "misc/multistream-select" }
 prometheus-client = "0.22.0"
 quick-protobuf-codec = { version = "0.3.1", path = "misc/quick-protobuf-codec" }
 quickcheck = { package = "quickcheck-ext", path = "misc/quickcheck-ext" }
-rw-stream-sink = { version = "0.4.0", path = "misc/rw-stream-sink" }
+rw-stream-sink = { version = "0.4.0" }
 unsigned-varint = { version = "0.8.0" }
 
 [patch.crates-io]

@Eligioo Eligioo changed the title Use libp2p fork to circumvent Sink panic Use libp2p-websocket fork to circumvent Sink panic Jun 20, 2024
Copy link
Member

@hrxi hrxi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@jsdanielh jsdanielh merged commit f015963 into albatross Jun 21, 2024
6 checks passed
@jsdanielh jsdanielh deleted the stefan/libp2p-fork branch June 21, 2024 12:05
@jsdanielh jsdanielh added this to the Nimiq PoS Mainnet milestone Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic | thread 'tokio-runtime-worker' panicked at 'SinkImpl::poll_ready called after error.'
3 participants