Skip to content

Commit 5363a50

Browse files
committed
Use the new best_hash instead of parent_hash when calling intermediate_roots()
Using `parent_hash` is wrong because we need to call the api on top of the newly created best block to get the intermediate roots for this just executed block.
1 parent 445ec9b commit 5363a50

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

cumulus/client/cirrus-executor/src/merkle_tree.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ pub(super) fn construct_trace_merkle_tree(
4848
let mut roots = roots;
4949

5050
let roots_len = roots.len();
51+
// roots contains at least [storage_root_after_initializing_block, state_root].
5152
assert!(roots_len >= 2, "Execution trace should at least contain 2 storage roots");
5253

5354
let ideal_len = merkletree::merkle::next_pow2(roots_len);
5455

5556
if ideal_len > roots_len {
56-
// The last element of trace is state_root.
57+
// Fill in a full tree by replicating the last element.
5758
if let Some(state_root) = roots.last().copied() {
5859
roots.resize(ideal_len, state_root);
5960
}

cumulus/client/cirrus-executor/src/processor.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,7 @@ where
194194
(&*self.client).import_block(block_import_params, Default::default()).await?;
195195

196196
let mut roots =
197-
self.client.runtime_api().intermediate_roots(&BlockId::Hash(parent_hash))?;
198-
199-
if roots.is_empty() {
200-
panic!(
201-
"FIXME: runtime intermediate_roots is empty, uncovered by running the sync node, related: https://github.com/paritytech/substrate/pull/8953"
202-
);
203-
}
197+
self.client.runtime_api().intermediate_roots(&BlockId::Hash(header_hash))?;
204198

205199
let state_root = state_root
206200
.encode()

0 commit comments

Comments
 (0)