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

Assume that all parachain peers know all paraheads #1812

Merged
merged 2 commits into from
May 2, 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
43 changes: 32 additions & 11 deletions light-base/src/sync_service/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,25 +1225,46 @@ impl<TPlat: PlatformRef> ParachainBackgroundTask<TPlat> {
block_number,
block_hash,
}),
_,
runtime_subscription,
) => {
// If `block_number` is over the finalized block, then which source knows which
// block is precisely tracked. Otherwise, it is assumed that all sources are on
// the finalized chain and thus that all sources whose best block is superior
// to `block_number` have it.
let list = if block_number > self.sync_sources.finalized_block_height() {
self.sync_sources
.knows_non_finalized_block(block_number, &block_hash)
.map(|local_id| self.sync_sources[local_id].0.clone())
.collect()
} else {
// If `block_number` is inferior or equal to the finalized block, or that
// it is a parahead of the relay chain, then we assume that all parachain
// nodes know this block.
// Otherwise, which source knows which block is precisely tracked.
let any_source_goes =
if block_number > self.sync_sources.finalized_block_height() {
if let ParachainBackgroundState::Subscribed(runtime_subscription) =
runtime_subscription
{
runtime_subscription
.async_tree
.input_output_iter_unordered()
.filter_map(|item| item.async_op_user_data)
.filter_map(|block| block.as_ref())
.any(|item| {
// TODO: CPU-expensive
header::hash_from_scale_encoded_header(item) == block_hash
})
} else {
false
}
} else {
true
};

let list = if any_source_goes {
self.sync_sources
.keys()
.filter(|local_id| {
self.sync_sources.best_block(*local_id).0 >= block_number
})
.map(|local_id| self.sync_sources[local_id].0.clone())
.collect()
} else {
self.sync_sources
.knows_non_finalized_block(block_number, &block_hash)
.map(|local_id| self.sync_sources[local_id].0.clone())
.collect()
};

let _ = send_back.send(list);
Expand Down
4 changes: 4 additions & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Changed

- When it comes to determining which peers know which block, smoldot now assumes that all parachain nodes know all paraheads found in the relay chain. This solves some issues when. ([#1812](https://github.com/smol-dot/smoldot/pull/1812))

## 2.0.25 - 2024-04-29

### Changed
Expand Down
Loading