From 065f58b07040bf13244f240c313ecac691841b19 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 28 Feb 2023 14:41:14 +0100 Subject: [PATCH 1/4] Try again substreams that have failed in open in the past --- lib/src/network/service.rs | 8 ++++++-- lib/src/network/service/notifications.rs | 5 +++++ wasm-node/CHANGELOG.md | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/src/network/service.rs b/lib/src/network/service.rs index bef307df75..f301c71da0 100644 --- a/lib/src/network/service.rs +++ b/lib/src/network/service.rs @@ -929,11 +929,15 @@ where // Before returning the event, we check whether there is any desired outbound substream // to open. + // Note: we can't use a `while let` due to borrow checker errors. loop { - // Note: we can't use a `while let` due to borrow checker errors. + // Query the list of substreams that need to be opened. + // When a substream is refused by the remote, we make sure to not mark as "not desired" + // unless that substream really is supposed to be open. For this reason, substreams + // that have been tried in the past are also included in the list. let (peer_id, notifications_protocol_index) = match self .inner - .unfulfilled_desired_outbound_substream(false) + .unfulfilled_desired_outbound_substream(true) .next() { Some((peer_id, idx)) => (peer_id.clone(), idx), diff --git a/lib/src/network/service/notifications.rs b/lib/src/network/service/notifications.rs index 405e3c0887..a3769f70d5 100644 --- a/lib/src/network/service/notifications.rs +++ b/lib/src/network/service/notifications.rs @@ -275,6 +275,11 @@ where } // Other protocol. + // These substreams are supposed to be openable but have been refused for some reason. + // As of the writing of this comment, a Substrate issue causes it to refuse + // transactions and GrandPa substreams if they are opened too quickly after the block + // announces substream. + // Do nothing, as the opening will be attempted again in the future. Err(_) => None, // Unrecognized protocol. diff --git a/wasm-node/CHANGELOG.md b/wasm-node/CHANGELOG.md index 2c24a17df7..cb4da27bb1 100644 --- a/wasm-node/CHANGELOG.md +++ b/wasm-node/CHANGELOG.md @@ -6,6 +6,10 @@ - Add support for the `ext_hashing_keccak_512_version_1` host function. ([#231](https://github.com/smol-dot/smoldot/pull/231)) +## Changed + +- When a full node refuses an outbound transactions or GrandPa substream even though a block announces substream has been established, smoldot now tries to reopen the failed substream. This bypasses a Substrate issue. () + ## Fixed - Fix panic when the input data of a Wasm function call is larger than a Wasm page. ([#218](https://github.com/smol-dot/smoldot/pull/218)) From cdafbf560f4f75369d2fdaa50ac837741d6a8cd2 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 28 Feb 2023 14:41:54 +0100 Subject: [PATCH 2/4] PR link --- wasm-node/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wasm-node/CHANGELOG.md b/wasm-node/CHANGELOG.md index cb4da27bb1..e04d512b1d 100644 --- a/wasm-node/CHANGELOG.md +++ b/wasm-node/CHANGELOG.md @@ -8,7 +8,7 @@ ## Changed -- When a full node refuses an outbound transactions or GrandPa substream even though a block announces substream has been established, smoldot now tries to reopen the failed substream. This bypasses a Substrate issue. () +- When a full node refuses an outbound transactions or GrandPa substream even though a block announces substream has been established, smoldot now tries to reopen the failed substream. This bypasses a Substrate issue. ([#240](https://github.com/smol-dot/smoldot/pull/240)) ## Fixed From 3cf774ee278992fd762a5dff2943273a08eb637f Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 28 Feb 2023 14:45:10 +0100 Subject: [PATCH 3/4] Fix include_already_tried incorrect check --- lib/src/libp2p/peers.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/libp2p/peers.rs b/lib/src/libp2p/peers.rs index 59b0272dc1..8f6f56e572 100644 --- a/lib/src/libp2p/peers.rs +++ b/lib/src/libp2p/peers.rs @@ -1403,7 +1403,13 @@ where ) -> impl Iterator + '_ { self.unfulfilled_desired_outbound_substreams .iter() - .filter(move |((_, _), already_tried)| **already_tried == include_already_tried) + .filter( + move |((_, _), already_tried)| match (**already_tried, include_already_tried) { + (false, _) => true, + (true, true) => true, + (true, false) => false, + }, + ) .map(|((peer_index, notifications_protocol_index), _)| { ( &self.peers[*peer_index].peer_id, From c91be2b8e5d0985122eaa93e194d2de4e3f61d1c Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 28 Feb 2023 14:50:03 +0100 Subject: [PATCH 4/4] Fix comment --- lib/src/network/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/network/service.rs b/lib/src/network/service.rs index f301c71da0..fde0ed043b 100644 --- a/lib/src/network/service.rs +++ b/lib/src/network/service.rs @@ -932,7 +932,7 @@ where // Note: we can't use a `while let` due to borrow checker errors. loop { // Query the list of substreams that need to be opened. - // When a substream is refused by the remote, we make sure to not mark as "not desired" + // When a substream is refused by the remote, we make sure to mark it as "not desired" // unless that substream really is supposed to be open. For this reason, substreams // that have been tried in the past are also included in the list. let (peer_id, notifications_protocol_index) = match self