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 async_tree.rs #1798

Merged
merged 2 commits into from
Apr 29, 2024
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
10 changes: 8 additions & 2 deletions lib/src/chain/async_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,10 @@ where
assert!(match (self.input_finalized_index, new_best_block) {
(Some(f), Some(b)) => self.non_finalized_blocks.is_ancestor(f, b),
(Some(_), None) => false,
(None, Some(_)) => true,
(None, Some(b)) => {
assert!(self.non_finalized_blocks.contains(b));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This newly-added asset is not strictly related to the bug, but it might catch similar problems earlier on.

true
}
(None, None) => true,
});

Expand Down Expand Up @@ -898,10 +901,13 @@ where
};

if let Some(new_finalized) = new_finalized {
// Update `input_finalized_index`.
// Update `input_finalized_index` and `input_best_block_index`.
if self.input_finalized_index == Some(new_finalized) {
self.input_finalized_index = None;
}
if self.input_best_block_index == Some(new_finalized) {
self.input_best_block_index = None;
}

let mut pruned_blocks = Vec::new();
let mut pruned_finalized = None;
Expand Down
5 changes: 5 additions & 0 deletions lib/src/chain/fork_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ impl<T> ForkTree<T> {
return_value.map(NodeIndex)
}

/// Returns `true` if the given [`NodeIndex`] is valid.
pub fn contains(&self, index: NodeIndex) -> bool {
self.nodes.contains(index.0)
}

/// Returns the value of the node with the given index.
pub fn get(&self, index: NodeIndex) -> Option<&T> {
self.nodes.get(index.0).map(|n| &n.data)
Expand Down
1 change: 1 addition & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Fix the wrong `parentBlockHash` value being sent in `chainHead_v1_followEvent` notifications. ([#1791](https://github.com/smol-dot/smoldot/pull/1791))
- Fix the `forbidWs` option being ignored when connecting to non-localhost addresses. Smoldot erroneously only took the value of `forbidNonLocalWs` in that situation. Connecting to a non-localhost address is now only done if both `forbidWs` and `forbidNonLocalWs` are `false`. ([#1790](https://github.com/smol-dot/smoldot/pull/1790))
- The `finalizedBlockHash` field of the `initialized` event of `chainHead_v1_followEvent` notifications is now properly named `finalizedBlockHashes` and is now properly an array. ([#1792](https://github.com/smol-dot/smoldot/pull/1792))
- Fix panic when calling the `system_health` JSON-RPC function when the finalized block is equal to the best block. ([#1798](https://github.com/smol-dot/smoldot/pull/1798))

## 2.0.24 - 2024-04-16

Expand Down
Loading