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

Fix panic in networking state machine #1395

Merged
merged 2 commits into from
Nov 23, 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
69 changes: 47 additions & 22 deletions lib/src/network/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ where
)
.any(|(_, connection_id)| {
let state = self.inner.connection_state(*connection_id);
!state.shutting_down
state.established && !state.shutting_down
})
{
if self
Expand Down Expand Up @@ -745,7 +745,18 @@ where
.insert((peer_index, chain_id, kind));
debug_assert!(_was_inserted);
}
} else {
}

if !self
.connections_by_peer_id
.range(
(peer_index, ConnectionId::min_value())..=(peer_index, ConnectionId::max_value()),
)
.any(|(_, connection_id)| {
let state = self.inner.connection_state(*connection_id);
!state.shutting_down
})
{
// Note that that `PeerId` might already be desired towards a different chain, in
// which case it is already present in `unconnected_desired`.
self.unconnected_desired.insert(peer_index);
Expand Down Expand Up @@ -1265,7 +1276,8 @@ where
)
.count()
!= 0
&& !self
{
if !self
.connections_by_peer_id
.range(
(peer_index, ConnectionId::min_value())
Expand All @@ -1275,25 +1287,38 @@ where
let state = self.inner.connection_state(*connection_id);
!state.shutting_down
})
{
self.unconnected_desired.insert(peer_index);
for (_, _, chain_index) in self.gossip_desired_peers.range(
(
peer_index,
GossipKind::ConsensusTransactions,
usize::min_value(),
{
self.unconnected_desired.insert(peer_index);
}
if !self
.connections_by_peer_id
.range(
(peer_index, ConnectionId::min_value())
..=(peer_index, ConnectionId::max_value()),
)
..=(
.any(|(_, connection_id)| {
let state = self.inner.connection_state(*connection_id);
state.established && !state.shutting_down
})
{
for (_, _, chain_index) in self.gossip_desired_peers.range(
(
peer_index,
GossipKind::ConsensusTransactions,
usize::max_value(),
),
) {
self.connected_unopened_gossip_desired.remove(&(
peer_index,
ChainId(*chain_index),
GossipKind::ConsensusTransactions,
));
usize::min_value(),
)
..=(
peer_index,
GossipKind::ConsensusTransactions,
usize::max_value(),
),
) {
self.connected_unopened_gossip_desired.remove(&(
peer_index,
ChainId(*chain_index),
GossipKind::ConsensusTransactions,
));
}
}
}
}
Expand Down Expand Up @@ -2141,15 +2166,15 @@ where
chain_index,
GossipKind::ConsensusTransactions,
peer_index,
)) && !self
)) && self
.connections_by_peer_id
.range(
(peer_index, ConnectionId::min_value())
..=(peer_index, ConnectionId::max_value()),
)
.any(|(_, connection_id)| {
let state = self.inner.connection_state(*connection_id);
!state.shutting_down
state.established && !state.shutting_down
})
{
debug_assert!(self
Expand All @@ -2159,7 +2184,7 @@ where
NotificationsProtocol::BlockAnnounces { chain_index },
peer_index,
SubstreamDirection::Out,
NotificationsSubstreamState::Open,
NotificationsSubstreamState::Pending,
SubstreamId::min_value(),
)
..=(
Expand Down
1 change: 1 addition & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- 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))
- Fix panic when `chainHead_unstable_follow` is called too many times. ([#1392](https://github.com/smol-dot/smoldot/pull/1392))
- Fix panic when opening a gossiping link to a peer that we were previously connected to. ([#1395](https://github.com/smol-dot/smoldot/pull/1395))

## 2.0.10 - 2023-11-17

Expand Down
Loading