Skip to content

Commit

Permalink
Fix TrieError(InvalidStateRoot(...)) error log when runtime upgrade…
Browse files Browse the repository at this point in the history
… PoV is empty (#77)

Closes #76
  • Loading branch information
liamaharon authored Jan 29, 2024
1 parent 6a126fe commit 7abe31b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolver = "2"
members = ["cli", "core"]

[workspace.package]
version = "0.5.3"
version = "0.5.4"
authors = ["Parity Technologies <[email protected]>"]
description = "Substrate's programmatic testing framework."
edition = "2021"
Expand Down
7 changes: 6 additions & 1 deletion core/src/commands/on_runtime_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out, no_weight_warnings: boo
where
H: Hasher,
{
if proof.is_empty() {
log::info!(target: LOG_TARGET, "Empty PoV detected");
return WeightSafety::ProbablySafe;
}

let encoded_proof_size = proof.encoded_size();
let compact_proof = proof
.clone()
Expand All @@ -304,7 +309,7 @@ where
);
e
})
.unwrap_or_default();
.expect("generating compressed proof should never fail if proof is valid");

let proof_nodes = proof.into_nodes();
log::debug!(
Expand Down
21 changes: 21 additions & 0 deletions core/tests/on_runtime_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,25 @@ mod on_runtime_upgrade {
})
.await;
}

#[tokio::test]
async fn no_migrations_works() {
common::run_with_timeout(Duration::from_secs(300), async move {
let project_root = env!("CARGO_MANIFEST_DIR");
let snap_path = format!("{}/tests/snaps/kusama-asset-hub.snap", project_root);
let runtime_path = format!(
"{}/tests/runtimes/asset_hub_kusama_runtime_no_migrations.compact.compressed.wasm",
project_root
);
let child = on_runtime_upgrade(
snap_path.as_str(),
runtime_path.as_str(),
&[],
&["--disable-spec-version-check"],
);
let out = child.wait_with_output().await.unwrap();
assert!(out.status.success());
})
.await;
}
}
Binary file not shown.
Binary file added core/tests/snaps/kusama-asset-hub.snap
Binary file not shown.

0 comments on commit 7abe31b

Please sign in to comment.