Use generic hash for runtime wasm in resolve_state_version_from_wasm (#3447)

Changes the runtime hash algorithm used in
`resolve_state_version_from_wasm` from `DefaultHasher` to a
caller-provided one (usually `HashingFor<Block>`), to match the one used
elsewhere.

This fixes an issue where the runtime wasm is compiled 3 times when
starting the `tanssi-node` with `--dev`. With this fix, the runtime wasm
is only compiled 2 times. The other redundant compilation is caused by
the `GenesisConfigBuilderRuntimeCaller` struct, which ignores the
runtime cache.

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
tmpolaczyk
2024-02-24 11:34:05 +01:00
committed by GitHub
parent 2431001ec0
commit de6d02591b
3 changed files with 25 additions and 12 deletions
@@ -675,8 +675,10 @@ where
// This is use by fast sync for runtime version to be resolvable from
// changes.
let state_version =
resolve_state_version_from_wasm(&storage, &self.executor)?;
let state_version = resolve_state_version_from_wasm::<_, HashingFor<Block>>(
&storage,
&self.executor,
)?;
let state_root = operation.op.reset_storage(storage, state_version)?;
if state_root != *import_headers.post().state_root() {
// State root mismatch when importing state. This should not happen in