From 4ee62872a16d47ed516161f7e08c3304672aa568 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 11 Mar 2022 21:44:33 +0100 Subject: [PATCH 1/2] Make CI work (#1079) MR#1076 somehow broke the check-runtime-benchmarks CI. Signed-off-by: Oliver Tale-Yazdi --- parachain-template/runtime/Cargo.toml | 1 + polkadot-parachains/canvas-kusama/Cargo.toml | 1 + polkadot-parachains/statemine/Cargo.toml | 1 + polkadot-parachains/statemint/Cargo.toml | 1 + polkadot-parachains/westmint/Cargo.toml | 1 + 5 files changed, 5 insertions(+) diff --git a/parachain-template/runtime/Cargo.toml b/parachain-template/runtime/Cargo.toml index 2b304a1813..610e5656bd 100644 --- a/parachain-template/runtime/Cargo.toml +++ b/parachain-template/runtime/Cargo.toml @@ -140,6 +140,7 @@ runtime-benchmarks = [ "pallet-template/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", + "polkadot-runtime/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", diff --git a/polkadot-parachains/canvas-kusama/Cargo.toml b/polkadot-parachains/canvas-kusama/Cargo.toml index 6d950cbd2d..da79b9cd61 100644 --- a/polkadot-parachains/canvas-kusama/Cargo.toml +++ b/polkadot-parachains/canvas-kusama/Cargo.toml @@ -156,6 +156,7 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", + "polkadot-runtime/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", diff --git a/polkadot-parachains/statemine/Cargo.toml b/polkadot-parachains/statemine/Cargo.toml index 981f292bf4..fda5b6ff46 100644 --- a/polkadot-parachains/statemine/Cargo.toml +++ b/polkadot-parachains/statemine/Cargo.toml @@ -96,6 +96,7 @@ runtime-benchmarks = [ "pallet-uniques/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", + "polkadot-runtime/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", diff --git a/polkadot-parachains/statemint/Cargo.toml b/polkadot-parachains/statemint/Cargo.toml index 067c181d40..83f0b440d6 100644 --- a/polkadot-parachains/statemint/Cargo.toml +++ b/polkadot-parachains/statemint/Cargo.toml @@ -95,6 +95,7 @@ runtime-benchmarks = [ "pallet-uniques/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", + "polkadot-runtime/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", diff --git a/polkadot-parachains/westmint/Cargo.toml b/polkadot-parachains/westmint/Cargo.toml index 176dafef4d..e138259f98 100644 --- a/polkadot-parachains/westmint/Cargo.toml +++ b/polkadot-parachains/westmint/Cargo.toml @@ -94,6 +94,7 @@ runtime-benchmarks = [ "pallet-uniques/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", + "polkadot-runtime/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", From b496ce8f4c8df10a490989dbc85be5c91c515815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 11 Mar 2022 23:01:17 +0100 Subject: [PATCH 2/2] Directly use the new `to_memory_db` function (#1080) This reduces the amount of code a little bit. --- .../src/validate_block/implementation.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pallets/parachain-system/src/validate_block/implementation.rs b/pallets/parachain-system/src/validate_block/implementation.rs index 4aac6d8778..3dcbf29158 100644 --- a/pallets/parachain-system/src/validate_block/implementation.rs +++ b/pallets/parachain-system/src/validate_block/implementation.rs @@ -66,19 +66,15 @@ where let block = B::new(header, extrinsics); assert!(parent_head.hash() == *block.header().parent_hash(), "Invalid parent hash",); - // Uncompress - let mut db = MemoryDB::default(); - let root = match sp_trie::decode_compact::>, _, _>( - &mut db, - storage_proof.iter_compact_encoded_nodes(), - Some(parent_head.state_root()), - ) { - Ok(root) => root, + // Create the db + let (db, root) = match storage_proof.to_memory_db(Some(parent_head.state_root())) { + Ok((db, root)) => (db, root), Err(_) => panic!("Compact proof decoding failure."), }; + sp_std::mem::drop(storage_proof); - let backend = sp_state_machine::TrieBackend::new(db, root); + let backend = sp_state_machine::TrieBackend::new(db, *parent_head.state_root()); let _guard = ( // Replace storage calls with our own implementations