Skip to content
Snippets Groups Projects
Commit aa466a48 authored by Svyatoslav Nikolsky's avatar Svyatoslav Nikolsky Committed by Bastian Köcher
Browse files

Fix benchmarks (#1919)

* fixed benchmarks broken by rejecting storage proofs with excessive trie nodes and justifications with extra prevotes

* update weights

* fmt

* accidental paste

* revert changes to millau runtime (separate PR)

* revert comment change
parent 7be2cb1c
Branches
No related merge requests found
......@@ -25,7 +25,7 @@ use crate::{
AccountIdOf, BridgedChain, HashOf, HasherOf, MessageBridge, ThisChain,
},
messages_generation::{
encode_all_messages, encode_lane_data, grow_trie, prepare_messages_storage_proof,
encode_all_messages, encode_lane_data, grow_trie_leaf_value, prepare_messages_storage_proof,
},
};
......@@ -204,11 +204,12 @@ where
{
let mut trie =
TrieDBMutBuilderV1::<HasherOf<BridgedChain<B>>>::new(&mut mdb, &mut root).build();
trie.insert(&storage_key, &params.inbound_lane_data.encode())
let inbound_lane_data =
grow_trie_leaf_value(params.inbound_lane_data.encode(), params.size);
trie.insert(&storage_key, &inbound_lane_data)
.map_err(|_| "TrieMut::insert has failed")
.expect("TrieMut::insert should not fail in benchmarks");
}
root = grow_trie(root, &mut mdb, params.size);
// generate storage proof to be delivered to This chain
let storage_proof = record_all_trie_keys::<LayoutV1<HasherOf<BridgedChain<B>>>, _>(&mdb, &root)
......
......@@ -25,7 +25,6 @@ use bp_messages::{
};
use bp_runtime::{record_all_trie_keys, RawStorageProof, StorageProofSize};
use codec::Encode;
use sp_core::Hasher;
use sp_std::{ops::RangeInclusive, prelude::*};
use sp_trie::{trie_types::TrieDBMutBuilderV1, LayoutV1, MemoryDB, TrieMut};
......@@ -65,10 +64,15 @@ where
TrieDBMutBuilderV1::<HasherOf<BridgedChain<B>>>::new(&mut mdb, &mut root).build();
// insert messages
for nonce in message_nonces {
for (i, nonce) in message_nonces.into_iter().enumerate() {
let message_key = MessageKey { lane_id: lane, nonce };
let message_payload = match encode_message(nonce, &message_payload) {
Some(message_payload) => message_payload,
Some(message_payload) =>
if i == 0 {
grow_trie_leaf_value(message_payload, size)
} else {
message_payload
},
None => continue,
};
let storage_key = storage_keys::message_key(
......@@ -94,46 +98,22 @@ where
storage_keys.push(storage_key);
}
}
root = grow_trie(root, &mut mdb, size);
// generate storage proof to be delivered to This chain
let storage_proof = record_all_trie_keys::<LayoutV1<HasherOf<BridgedChain<B>>>, _>(&mdb, &root)
.map_err(|_| "record_all_trie_keys has failed")
.expect("record_all_trie_keys should not fail in benchmarks");
(root, storage_proof)
}
/// Populate trie with dummy keys+values until trie has at least given size.
pub fn grow_trie<H: Hasher>(
mut root: H::Out,
mdb: &mut MemoryDB<H>,
trie_size: StorageProofSize,
) -> H::Out {
let (iterations, leaf_size, minimal_trie_size) = match trie_size {
StorageProofSize::Minimal(_) => return root,
StorageProofSize::HasLargeLeaf(size) => (1, size, size),
StorageProofSize::HasExtraNodes(size) => (8, 1, size),
};
let mut key_index = 0;
loop {
// generate storage proof to be delivered to This chain
let storage_proof = record_all_trie_keys::<LayoutV1<H>, _>(mdb, &root)
.map_err(|_| "record_all_trie_keys has failed")
.expect("record_all_trie_keys should not fail in benchmarks");
let size: usize = storage_proof.iter().map(|n| n.len()).sum();
if size > minimal_trie_size as _ {
return root
}
let mut trie = TrieDBMutBuilderV1::<H>::from_existing(mdb, &mut root).build();
for _ in 0..iterations {
trie.insert(&key_index.encode(), &vec![42u8; leaf_size as _])
.map_err(|_| "TrieMut::insert has failed")
.expect("TrieMut::insert should not fail in benchmarks");
key_index += 1;
}
trie.commit();
/// Add extra data to the trie leaf value so that it'll be of given size.
pub fn grow_trie_leaf_value(mut value: Vec<u8>, size: StorageProofSize) -> Vec<u8> {
match size {
StorageProofSize::Minimal(_) => (),
StorageProofSize::HasLargeLeaf(size) if size as usize > value.len() => {
value.extend(sp_std::iter::repeat(42u8).take(size as usize - value.len()));
},
StorageProofSize::HasLargeLeaf(_) => (),
}
value
}
......@@ -19,7 +19,8 @@
#![cfg(feature = "runtime-benchmarks")]
use crate::{
messages_benchmarking::insert_header_to_grandpa_pallet, messages_generation::grow_trie,
messages_benchmarking::insert_header_to_grandpa_pallet,
messages_generation::grow_trie_leaf_value,
};
use bp_parachains::parachain_head_storage_key_at_source;
......@@ -59,17 +60,21 @@ where
TrieDBMutBuilderV1::<RelayBlockHasher>::new(&mut mdb, &mut state_root).build();
// insert parachain heads
for parachain in parachains {
for (i, parachain) in parachains.into_iter().enumerate() {
let storage_key =
parachain_head_storage_key_at_source(R::ParasPalletName::get(), *parachain);
trie.insert(&storage_key.0, &parachain_head.encode())
let leaf_data = if i == 0 {
grow_trie_leaf_value(parachain_head.encode(), size)
} else {
parachain_head.encode()
};
trie.insert(&storage_key.0, &leaf_data)
.map_err(|_| "TrieMut::insert has failed")
.expect("TrieMut::insert should not fail in benchmarks");
storage_keys.push(storage_key);
parachain_heads.push((*parachain, parachain_head.hash()))
}
}
state_root = grow_trie(state_root, &mut mdb, size);
// generate heads storage proof
let proof = record_all_trie_keys::<LayoutV1<RelayBlockHasher>, _>(&mdb, &state_root)
......
......@@ -41,6 +41,7 @@
use crate::*;
use bp_header_chain::justification::required_justification_precommits;
use bp_runtime::BasicOperatingMode;
use bp_test_utils::{
accounts, make_justification_for_header, JustificationGeneratorParams, TEST_GRANDPA_ROUND,
......@@ -66,13 +67,14 @@ const MAX_VOTE_ANCESTRIES_RANGE_END: u32 =
MAX_VOTE_ANCESTRIES_RANGE_BEGIN + MAX_VOTE_ANCESTRIES_RANGE_BEGIN;
// the same with validators - if there are too much validators, let's run benchmarks on subrange
fn validator_set_range_end<T: Config<I>, I: 'static>() -> u32 {
fn precommits_range_end<T: Config<I>, I: 'static>() -> u32 {
let max_bridged_authorities = T::BridgedChain::MAX_AUTHORITIES_COUNT;
if max_bridged_authorities > 128 {
sp_std::cmp::max(128, max_bridged_authorities / 5)
} else {
max_bridged_authorities
}
};
required_justification_precommits(max_bridged_authorities)
}
/// Prepare header and its justification to submit using `submit_finality_proof`.
......@@ -80,7 +82,10 @@ fn prepare_benchmark_data<T: Config<I>, I: 'static>(
precommits: u32,
ancestors: u32,
) -> (BridgedHeader<T, I>, GrandpaJustification<BridgedHeader<T, I>>) {
let authority_list = accounts(precommits as u16)
// going from precommits to total authorities count
let total_authorities_count = (3 * precommits - 1) / 2;
let authority_list = accounts(total_authorities_count as u16)
.iter()
.map(|id| (AuthorityId::from(*id), 1))
.collect::<Vec<_>>();
......@@ -114,7 +119,7 @@ benchmarks_instance_pallet! {
// This is the "gold standard" benchmark for this extrinsic, and it's what should be used to
// annotate the weight in the pallet.
submit_finality_proof {
let p in 1 .. validator_set_range_end::<T, I>();
let p in 1 .. precommits_range_end::<T, I>();
let v in MAX_VOTE_ANCESTRIES_RANGE_BEGIN..MAX_VOTE_ANCESTRIES_RANGE_END;
let caller: T::AccountId = whitelisted_caller();
let (header, justification) = prepare_benchmark_data::<T, I>(p, v);
......
......@@ -17,7 +17,7 @@
//! Autogenerated weights for pallet_bridge_grandpa
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-02-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-03-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
......@@ -93,19 +93,19 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68),
/// added: 2048, mode: MaxEncodedLen)
///
/// The range of component `p` is `[1, 5]`.
/// The range of component `p` is `[1, 4]`.
///
/// The range of component `v` is `[50, 100]`.
fn submit_finality_proof(p: u32, v: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `416 + p * (40 ±0)`
// Measured: `394 + p * (60 ±0)`
// Estimated: `4745`
// Minimum execution time: 221_703 nanoseconds.
Weight::from_parts(39_358_497, 4745)
// Standard Error: 85_573
.saturating_add(Weight::from_ref_time(40_593_280).saturating_mul(p.into()))
// Standard Error: 7_808
.saturating_add(Weight::from_ref_time(1_529_400).saturating_mul(v.into()))
// Minimum execution time: 221_810 nanoseconds.
Weight::from_parts(33_157_392, 4745)
// Standard Error: 109_045
.saturating_add(Weight::from_ref_time(41_100_656).saturating_mul(p.into()))
// Standard Error: 7_754
.saturating_add(Weight::from_ref_time(1_534_466).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
......@@ -148,19 +148,19 @@ impl WeightInfo for () {
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68),
/// added: 2048, mode: MaxEncodedLen)
///
/// The range of component `p` is `[1, 5]`.
/// The range of component `p` is `[1, 4]`.
///
/// The range of component `v` is `[50, 100]`.
fn submit_finality_proof(p: u32, v: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `416 + p * (40 ±0)`
// Measured: `394 + p * (60 ±0)`
// Estimated: `4745`
// Minimum execution time: 221_703 nanoseconds.
Weight::from_parts(39_358_497, 4745)
// Standard Error: 85_573
.saturating_add(Weight::from_ref_time(40_593_280).saturating_mul(p.into()))
// Standard Error: 7_808
.saturating_add(Weight::from_ref_time(1_529_400).saturating_mul(v.into()))
// Minimum execution time: 221_810 nanoseconds.
Weight::from_parts(33_157_392, 4745)
// Standard Error: 109_045
.saturating_add(Weight::from_ref_time(41_100_656).saturating_mul(p.into()))
// Standard Error: 7_754
.saturating_add(Weight::from_ref_time(1_534_466).saturating_mul(v.into()))
.saturating_add(RocksDbWeight::get().reads(6_u64))
.saturating_add(RocksDbWeight::get().writes(6_u64))
}
......
......@@ -238,7 +238,7 @@ benchmarks_instance_pallet! {
lane: T::bench_lane_id(),
message_nonces: 21..=21,
outbound_lane_data: None,
size: StorageProofSize::HasExtraNodes(1024),
size: StorageProofSize::HasLargeLeaf(1024),
});
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
verify {
......@@ -272,7 +272,7 @@ benchmarks_instance_pallet! {
lane: T::bench_lane_id(),
message_nonces: 21..=21,
outbound_lane_data: None,
size: StorageProofSize::HasExtraNodes(16 * 1024),
size: StorageProofSize::HasLargeLeaf(16 * 1024),
});
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
verify {
......
......@@ -17,7 +17,7 @@
//! Autogenerated weights for pallet_bridge_messages
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-02-13, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-03-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
......@@ -88,8 +88,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 50_655 nanoseconds.
Weight::from_parts(60_502_000, 54703)
// Minimum execution time: 48_426 nanoseconds.
Weight::from_parts(50_113_000, 54703)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
......@@ -116,8 +116,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 58_861 nanoseconds.
Weight::from_parts(60_288_000, 54703)
// Minimum execution time: 59_739 nanoseconds.
Weight::from_parts(61_704_000, 54703)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
......@@ -144,8 +144,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 53_459 nanoseconds.
Weight::from_parts(54_577_000, 54703)
// Minimum execution time: 53_760 nanoseconds.
Weight::from_parts(55_645_000, 54703)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
......@@ -167,8 +167,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `618`
// Estimated: `54200`
// Minimum execution time: 54_011 nanoseconds.
Weight::from_parts(55_573_000, 54200)
// Minimum execution time: 49_582 nanoseconds.
Weight::from_parts(51_250_000, 54200)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
......@@ -190,8 +190,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `618`
// Estimated: `54200`
// Minimum execution time: 105_856 nanoseconds.
Weight::from_parts(109_112_000, 54200)
// Minimum execution time: 76_418 nanoseconds.
Weight::from_parts(77_877_000, 54200)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
......@@ -212,14 +212,14 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
///
/// Storage: BridgeRelayers RelayerRewards (r:1 w:1)
///
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(60), added: 2535,
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540,
/// mode: MaxEncodedLen)
fn receive_delivery_proof_for_single_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `579`
// Estimated: `5619`
// Minimum execution time: 40_894 nanoseconds.
Weight::from_parts(41_766_000, 5619)
// Estimated: `5624`
// Minimum execution time: 41_795 nanoseconds.
Weight::from_parts(43_683_000, 5624)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
......@@ -240,14 +240,14 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
///
/// Storage: BridgeRelayers RelayerRewards (r:1 w:1)
///
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(60), added: 2535,
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540,
/// mode: MaxEncodedLen)
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
// Proof Size summary in bytes:
// Measured: `596`
// Estimated: `5619`
// Minimum execution time: 39_996 nanoseconds.
Weight::from_parts(41_452_000, 5619)
// Estimated: `5624`
// Minimum execution time: 39_946 nanoseconds.
Weight::from_parts(41_509_000, 5624)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
......@@ -268,14 +268,14 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
///
/// Storage: BridgeRelayers RelayerRewards (r:2 w:2)
///
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(60), added: 2535,
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540,
/// mode: MaxEncodedLen)
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
// Proof Size summary in bytes:
// Measured: `596`
// Estimated: `8154`
// Minimum execution time: 42_281 nanoseconds.
Weight::from_parts(43_593_000, 8154)
// Estimated: `8164`
// Minimum execution time: 42_882 nanoseconds.
Weight::from_parts(44_367_000, 8164)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
......@@ -306,8 +306,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 50_655 nanoseconds.
Weight::from_parts(60_502_000, 54703)
// Minimum execution time: 48_426 nanoseconds.
Weight::from_parts(50_113_000, 54703)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
......@@ -334,8 +334,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 58_861 nanoseconds.
Weight::from_parts(60_288_000, 54703)
// Minimum execution time: 59_739 nanoseconds.
Weight::from_parts(61_704_000, 54703)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
......@@ -362,8 +362,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 53_459 nanoseconds.
Weight::from_parts(54_577_000, 54703)
// Minimum execution time: 53_760 nanoseconds.
Weight::from_parts(55_645_000, 54703)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
......@@ -385,8 +385,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `618`
// Estimated: `54200`
// Minimum execution time: 54_011 nanoseconds.
Weight::from_parts(55_573_000, 54200)
// Minimum execution time: 49_582 nanoseconds.
Weight::from_parts(51_250_000, 54200)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
......@@ -408,8 +408,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `618`
// Estimated: `54200`
// Minimum execution time: 105_856 nanoseconds.
Weight::from_parts(109_112_000, 54200)
// Minimum execution time: 76_418 nanoseconds.
Weight::from_parts(77_877_000, 54200)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
......@@ -430,14 +430,14 @@ impl WeightInfo for () {
///
/// Storage: BridgeRelayers RelayerRewards (r:1 w:1)
///
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(60), added: 2535,
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540,
/// mode: MaxEncodedLen)
fn receive_delivery_proof_for_single_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `579`
// Estimated: `5619`
// Minimum execution time: 40_894 nanoseconds.
Weight::from_parts(41_766_000, 5619)
// Estimated: `5624`
// Minimum execution time: 41_795 nanoseconds.
Weight::from_parts(43_683_000, 5624)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
......@@ -458,14 +458,14 @@ impl WeightInfo for () {
///
/// Storage: BridgeRelayers RelayerRewards (r:1 w:1)
///
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(60), added: 2535,
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540,
/// mode: MaxEncodedLen)
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
// Proof Size summary in bytes:
// Measured: `596`
// Estimated: `5619`
// Minimum execution time: 39_996 nanoseconds.
Weight::from_parts(41_452_000, 5619)
// Estimated: `5624`
// Minimum execution time: 39_946 nanoseconds.
Weight::from_parts(41_509_000, 5624)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
......@@ -486,14 +486,14 @@ impl WeightInfo for () {
///
/// Storage: BridgeRelayers RelayerRewards (r:2 w:2)
///
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(60), added: 2535,
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540,
/// mode: MaxEncodedLen)
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
// Proof Size summary in bytes:
// Measured: `596`
// Estimated: `8154`
// Minimum execution time: 42_281 nanoseconds.
Weight::from_parts(43_593_000, 8154)
// Estimated: `8164`
// Minimum execution time: 42_882 nanoseconds.
Weight::from_parts(44_367_000, 8164)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
......
......@@ -85,7 +85,7 @@ benchmarks_instance_pallet! {
let (relay_block_number, relay_block_hash, parachain_heads_proof, parachains_heads) = T::prepare_parachain_heads_proof(
&parachains,
DEFAULT_PARACHAIN_HEAD_SIZE,
StorageProofSize::HasExtraNodes(1024),
StorageProofSize::HasLargeLeaf(1024),
);
let at_relay_block = (relay_block_number, relay_block_hash);
}: submit_parachain_heads(RawOrigin::Signed(sender), at_relay_block, parachains_heads, parachain_heads_proof)
......@@ -102,7 +102,7 @@ benchmarks_instance_pallet! {
let (relay_block_number, relay_block_hash, parachain_heads_proof, parachains_heads) = T::prepare_parachain_heads_proof(
&parachains,
DEFAULT_PARACHAIN_HEAD_SIZE,
StorageProofSize::HasExtraNodes(16 * 1024),
StorageProofSize::HasLargeLeaf(16 * 1024),
);
let at_relay_block = (relay_block_number, relay_block_hash);
}: submit_parachain_heads(RawOrigin::Signed(sender), at_relay_block, parachains_heads, parachain_heads_proof)
......
......@@ -17,7 +17,7 @@
//! Autogenerated weights for pallet_bridge_parachains
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-02-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-03-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
......@@ -77,23 +77,21 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
///
/// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(14400), max_size:
/// Some(64), added: 2044, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size:
/// Some(64), added: 1549, mode: MaxEncodedLen)
///
/// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(14400), max_size:
/// Some(196), added: 2176, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size:
/// Some(196), added: 1681, mode: MaxEncodedLen)
///
/// The range of component `p` is `[1, 2]`.
fn submit_parachain_heads_with_n_parachains(p: u32) -> Weight {
fn submit_parachain_heads_with_n_parachains(_p: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `366`
// Estimated: `5143`
// Minimum execution time: 35_160 nanoseconds.
Weight::from_parts(36_951_585, 5143)
// Standard Error: 336_932
.saturating_add(Weight::from_ref_time(407_557).saturating_mul(p.into()))
// Estimated: `4648`
// Minimum execution time: 36_567 nanoseconds.
Weight::from_parts(38_887_022, 4648)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
......@@ -114,19 +112,19 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
///
/// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(14400), max_size:
/// Some(64), added: 2044, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size:
/// Some(64), added: 1549, mode: MaxEncodedLen)
///
/// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(14400), max_size:
/// Some(196), added: 2176, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size:
/// Some(196), added: 1681, mode: MaxEncodedLen)
fn submit_parachain_heads_with_1kb_proof() -> Weight {
// Proof Size summary in bytes:
// Measured: `366`
// Estimated: `5143`
// Minimum execution time: 42_276 nanoseconds.
Weight::from_parts(43_525_000, 5143)
// Estimated: `4648`
// Minimum execution time: 37_910 nanoseconds.
Weight::from_parts(38_967_000, 4648)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
......@@ -147,19 +145,19 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
///
/// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(14400), max_size:
/// Some(64), added: 2044, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size:
/// Some(64), added: 1549, mode: MaxEncodedLen)
///
/// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(14400), max_size:
/// Some(196), added: 2176, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size:
/// Some(196), added: 1681, mode: MaxEncodedLen)
fn submit_parachain_heads_with_16kb_proof() -> Weight {
// Proof Size summary in bytes:
// Measured: `366`
// Estimated: `5143`
// Minimum execution time: 85_824 nanoseconds.
Weight::from_parts(87_335_000, 5143)
// Estimated: `4648`
// Minimum execution time: 62_823 nanoseconds.
Weight::from_parts(64_658_000, 4648)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
......@@ -184,23 +182,21 @@ impl WeightInfo for () {
///
/// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(14400), max_size:
/// Some(64), added: 2044, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size:
/// Some(64), added: 1549, mode: MaxEncodedLen)
///
/// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(14400), max_size:
/// Some(196), added: 2176, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size:
/// Some(196), added: 1681, mode: MaxEncodedLen)
///
/// The range of component `p` is `[1, 2]`.
fn submit_parachain_heads_with_n_parachains(p: u32) -> Weight {
fn submit_parachain_heads_with_n_parachains(_p: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `366`
// Estimated: `5143`
// Minimum execution time: 35_160 nanoseconds.
Weight::from_parts(36_951_585, 5143)
// Standard Error: 336_932
.saturating_add(Weight::from_ref_time(407_557).saturating_mul(p.into()))
// Estimated: `4648`
// Minimum execution time: 36_567 nanoseconds.
Weight::from_parts(38_887_022, 4648)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
......@@ -221,19 +217,19 @@ impl WeightInfo for () {
///
/// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(14400), max_size:
/// Some(64), added: 2044, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size:
/// Some(64), added: 1549, mode: MaxEncodedLen)
///
/// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(14400), max_size:
/// Some(196), added: 2176, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size:
/// Some(196), added: 1681, mode: MaxEncodedLen)
fn submit_parachain_heads_with_1kb_proof() -> Weight {
// Proof Size summary in bytes:
// Measured: `366`
// Estimated: `5143`
// Minimum execution time: 42_276 nanoseconds.
Weight::from_parts(43_525_000, 5143)
// Estimated: `4648`
// Minimum execution time: 37_910 nanoseconds.
Weight::from_parts(38_967_000, 4648)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
......@@ -254,19 +250,19 @@ impl WeightInfo for () {
///
/// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(14400), max_size:
/// Some(64), added: 2044, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size:
/// Some(64), added: 1549, mode: MaxEncodedLen)
///
/// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1)
///
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(14400), max_size:
/// Some(196), added: 2176, mode: MaxEncodedLen)
/// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size:
/// Some(196), added: 1681, mode: MaxEncodedLen)
fn submit_parachain_heads_with_16kb_proof() -> Weight {
// Proof Size summary in bytes:
// Measured: `366`
// Estimated: `5143`
// Minimum execution time: 85_824 nanoseconds.
Weight::from_parts(87_335_000, 5143)
// Estimated: `4648`
// Minimum execution time: 62_823 nanoseconds.
Weight::from_parts(64_658_000, 4648)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
......
......@@ -17,9 +17,9 @@
//! Autogenerated weights for pallet_bridge_relayers
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-02-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-03-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `serban-ROG-Zephyrus`, CPU: `12th Gen Intel(R) Core(TM) i7-12700H`
//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
......@@ -71,8 +71,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `275`
// Estimated: `5111`
// Minimum execution time: 43_031 nanoseconds.
Weight::from_parts(44_527_000, 5111)
// Minimum execution time: 48_688 nanoseconds.
Weight::from_parts(50_457_000, 5111)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
......@@ -93,8 +93,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `275`
// Estimated: `5111`
// Minimum execution time: 43_031 nanoseconds.
Weight::from_parts(44_527_000, 5111)
// Minimum execution time: 48_688 nanoseconds.
Weight::from_parts(50_457_000, 5111)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
......
......@@ -16,7 +16,7 @@
//! Logic for checking Substrate storage proofs.
use codec::{Decode, Encode};
use codec::Decode;
use hash_db::{HashDB, Hasher, EMPTY_PREFIX};
use sp_runtime::RuntimeDebug;
use sp_std::{boxed::Box, collections::btree_set::BTreeSet, vec::Vec};
......@@ -36,9 +36,6 @@ pub enum ProofSize {
/// The proof is expected to be minimal. If value size may be changed, then it is expected to
/// have given size.
Minimal(u32),
/// The proof is expected to have at least given size and grow by increasing number of trie
/// nodes included in the proof.
HasExtraNodes(u32),
/// The proof is expected to have at least given size and grow by increasing value that is
/// stored in the trie.
HasLargeLeaf(u32),
......@@ -46,7 +43,8 @@ pub enum ProofSize {
/// This struct is used to read storage values from a subset of a Merklized database. The "proof"
/// is a subset of the nodes in the Merkle structure of the database, so that it provides
/// authentication against a known Merkle root as well as the values in the database themselves.
/// authentication against a known Merkle root as well as the values in the
/// database themselves.
pub struct StorageProofChecker<H>
where
H: Hasher,
......@@ -157,6 +155,7 @@ impl From<Error> for &'static str {
/// NOTE: This should only be used for **testing**.
#[cfg(feature = "std")]
pub fn craft_valid_storage_proof() -> (sp_core::H256, RawStorageProof) {
use codec::Encode;
use sp_state_machine::{backend::Backend, prove_read, InMemoryBackend};
let state_version = sp_runtime::StateVersion::default();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment