Use generic hash for runtime wasm in resolve_state_version_from_wasm#3447
Conversation
| wasm.hash(&mut state); | ||
| state.finish().to_le_bytes().to_vec() | ||
| }, | ||
| hash: sp_core::blake2_256(wasm).to_vec(), |
There was a problem hiding this comment.
This is not correct, you need to get the hasher used by the Block type. For most chains this is blake256, but not for all.
There was a problem hiding this comment.
I mean "not correct" not being really the right term here, but if we want to fix this, we should fix it properly.
There was a problem hiding this comment.
polkadot-sdk/substrate/primitives/state-machine/src/backend.rs
Lines 427 to 433 in 36b7037
There was a problem hiding this comment.
I don't know how to do that, and there are many places where this hash is already hardcoded to be blake2_256. How about we merge this and create an issue to make the hasher depend on the Block?
There was a problem hiding this comment.
Change the function to take H: Hash and then you can pass HashingOf<Block> on the calling side of this function.
There was a problem hiding this comment.
Thanks, it was easier than I expected.
|
@tmpolaczyk could you add some prdoc? Then accept my changes and we can merge it. |
Co-authored-by: Bastian Köcher <[email protected]>
…head-data * origin/master: (51 commits) Runtime Upgrade ref docs and Single Block Migration example pallet (#1554) Collator overseer builder unification (#3335) Introduce storage attr macro `#[disable_try_decode_storage]` and set it on `System::Events` and `ParachainSystem::HostConfiguration` (#3454) Add Polkadotters bootnoders per IBP application (#3423) Add documentation around FRAME Origin (#3362) Bridge zombienet tests: Check amount received at destination (#3490) Snowbridge benchmark tests fix (#3424) fix(zombienet): increase timeout in download artifacts (#3376) Cleanup String::from_utf8 (#3446) [prdoc] Validate crate names (#3467) Limit max execution time for `test-linux-stable` CI jobs (#3483) Introduce Notification block pinning limit (#2935) frame-support: Improve error reporting when having too many pallets (#3478) add Encointer as trusted teleporter for Westend (#3411) [pallet-xcm] Adjust benchmarks (teleport_assets/reserve_transfer_assets) not relying on ED (#3464) Add more debug logs to understand if statement-distribution misbehaving (#3419) Remove redundant parachains assigner pallet. (#3457) Use generic hash for runtime wasm in resolve_state_version_from_wasm (#3447) Runtime: allow backing multiple candidates of same parachain on different cores (#3231) Bridge zombienet tests: move all "framework" files under one folder (#3462) ...
…aritytech#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 <[email protected]>
…aritytech#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 <[email protected]>
Changes the runtime hash algorithm used in
resolve_state_version_from_wasmfromDefaultHasherto a caller-provided one (usuallyHashingFor<Block>), to match the one used elsewhere.This fixes an issue where the runtime wasm is compiled 3 times when starting the
tanssi-nodewith--dev. With this fix, the runtime wasm is only compiled 2 times. The other redundant compilation is caused by theGenesisConfigBuilderRuntimeCallerstruct, which ignores the runtime cache.