Runtime State Test + Integration with try-runtime (#10174)

* add missing version to dependencies

* Huh

* add features more

* more fixing

* last touches

* it all finally works

* remove some feature gates

* remove unused

* fix old macro

* make it work again

* fmt

* remove unused import

* ".git/.scripts/fmt.sh" 1

* Cleanup more

* fix and rename everything

* a few clippy fixes

* Add try-runtime feature

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* small fixes

* fmt

* Update bin/node-template/runtime/src/lib.rs

* fix build

* Update utils/frame/try-runtime/cli/src/lib.rs

Co-authored-by: David <dvdplm@gmail.com>

* Update utils/frame/try-runtime/cli/src/commands/execute_block.rs

Co-authored-by: David <dvdplm@gmail.com>

* address all review comments

* fix typos

* revert spec change

* last touches

* update docs

* fmt

* remove some debug_assertions

* fmt

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: command-bot <>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: David <dvdplm@gmail.com>
This commit is contained in:
Kian Paimani
2022-09-01 11:33:22 +01:00
committed by GitHub
parent d8e951758c
commit f67c06ce22
39 changed files with 651 additions and 209 deletions
@@ -335,17 +335,18 @@ pub enum Command {
/// different state transition function.
///
/// To make testing slightly more dynamic, you can disable the state root check by enabling
/// `ExecuteBlockCmd::no_check`. If you get signature verification errors, you should
/// manually tweak your local runtime's spec version to fix this.
/// `ExecuteBlockCmd::no_check`. If you get signature verification errors, you should manually
/// tweak your local runtime's spec version to fix this.
///
/// A subtle detail of execute block is that if you want to execute block 100 of a live chain
/// again, you need to scrape the state of block 99. This is already done automatically if you
/// use [`State::Live`], and the parent hash of the target block is used to scrape the state.
/// If [`State::Snap`] is being used, then this needs to be manually taken into consideration.
///
/// This executes the same runtime api as normal block import, namely `Core_execute_block`. If
/// `ExecuteBlockCmd::no_check` is set, it uses a custom, try-runtime-only runtime
/// api called `TryRuntime_execute_block_no_check`.
/// This does not execute the same runtime api as normal block import do, namely
/// `Core_execute_block`. Instead, it uses `TryRuntime_execute_block`, which can optionally
/// skip state-root check (useful for trying a unreleased runtime), and can execute runtime
/// sanity checks as well.
ExecuteBlock(commands::execute_block::ExecuteBlockCmd),
/// Executes *the offchain worker hooks* of a given block against some state.
@@ -656,21 +657,27 @@ pub(crate) async fn ensure_matching_spec<Block: BlockT + serde::de::DeserializeO
if expected_spec_version == version {
log::info!(target: LOG_TARGET, "found matching spec version: {:?}", version);
} else {
log::warn!(
target: LOG_TARGET,
let msg = format!(
"spec version mismatch (local {} != remote {}). This could cause some issues.",
expected_spec_version,
version
expected_spec_version, version
);
if relaxed {
log::warn!(target: LOG_TARGET, "{}", msg);
} else {
panic!("{}", msg);
}
}
},
Err(why) => {
log::error!(
target: LOG_TARGET,
let msg = format!(
"failed to fetch runtime version from {}: {:?}. Skipping the check",
uri,
why
uri, why
);
if relaxed {
log::error!(target: LOG_TARGET, "{}", msg);
} else {
panic!("{}", msg);
}
},
}
}
@@ -801,15 +808,15 @@ pub(crate) fn state_machine_call_with_proof<Block: BlockT, D: NativeExecutionDis
)
}
};
log::info!(
log::debug!(
target: LOG_TARGET,
"proof: {} / {} nodes",
HexDisplay::from(&proof_nodes.iter().flatten().cloned().collect::<Vec<_>>()),
proof_nodes.len()
);
log::info!(target: LOG_TARGET, "proof size: {}", humanize(proof_size));
log::info!(target: LOG_TARGET, "compact proof size: {}", humanize(compact_proof_size),);
log::info!(
log::debug!(target: LOG_TARGET, "proof size: {}", humanize(proof_size));
log::debug!(target: LOG_TARGET, "compact proof size: {}", humanize(compact_proof_size),);
log::debug!(
target: LOG_TARGET,
"zstd-compressed compact proof {}",
humanize(compressed_proof.len()),