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

Accept pending ingoing substreams in gossip_open #1369

Merged
merged 2 commits into from
Nov 20, 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
57 changes: 57 additions & 0 deletions lib/src/network/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3057,6 +3057,63 @@ where
a
});

for (protocol, in_substream_id) in [
NotificationsProtocol::BlockAnnounces {
chain_index: chain_id.0,
},
NotificationsProtocol::Transactions {
chain_index: chain_id.0,
},
NotificationsProtocol::Grandpa {
chain_index: chain_id.0,
},
]
.into_iter()
.flat_map(|protocol| {
self.notification_substreams_by_peer_id
.range(
(
protocol,
peer_index,
SubstreamDirection::In,
NotificationsSubstreamState::Pending,
SubstreamId::min_value(),
)
..=(
protocol,
peer_index,
SubstreamDirection::In,
NotificationsSubstreamState::Pending,
SubstreamId::max_value(),
),
)
.map(move |&(_, _, _, _, substream_id)| (protocol, substream_id))
})
.collect::<Vec<_>>()
{
let _was_removed = self.notification_substreams_by_peer_id.remove(&(
protocol,
peer_index,
SubstreamDirection::In,
NotificationsSubstreamState::Pending,
in_substream_id,
));
debug_assert!(_was_removed);

let _was_inserted = self.notification_substreams_by_peer_id.insert((
protocol,
peer_index,
SubstreamDirection::In,
NotificationsSubstreamState::Open,
in_substream_id,
));
debug_assert!(_was_inserted);

self.inner
.accept_in_notifications(in_substream_id, handshake.clone(), 1024 * 1024)
// TODO: constant
}

let substream_id = self.inner.open_out_notifications(
connection_id,
protocol_name,
Expand Down
1 change: 1 addition & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Fixed

- Fix panic when the runtime of a chain provides consensus information that is inconsistent with the information found in the finalized block. ([#1317](https://github.com/smol-dot/smoldot/pull/1317))
- Incoming notification substreams are now properly when accepted when a peer doesn't have a slot or gets a slot later on. ([#1369](https://github.com/smol-dot/smoldot/pull/1369))

## 2.0.10 - 2023-11-17

Expand Down
Loading