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

Try again substreams that have failed in open in the past #240

Merged
merged 4 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/src/libp2p/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,13 @@ where
) -> impl Iterator<Item = (&'_ PeerId, usize)> + '_ {
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,
Expand Down
8 changes: 6 additions & 2 deletions lib/src/network/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
.inner
.unfulfilled_desired_outbound_substream(false)
.unfulfilled_desired_outbound_substream(true)
.next()
{
Some((peer_id, idx)) => (peer_id.clone(), idx),
Expand Down
5 changes: 5 additions & 0 deletions lib/src/network/service/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. ([#240](https://github.com/smol-dot/smoldot/pull/240))

## 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))
Expand Down