Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[contracts] Fix *storage_per_kb benchmarks #11756

Closed
wants to merge 10 commits into from
24 changes: 18 additions & 6 deletions frame/contracts/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,12 +993,14 @@ benchmarks! {
for key in keys {
Storage::<T>::write(
&info.trie_id,
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&VarSizedKey::<T>::try_from(key.clone()).map_err(|e| "Key has wrong length")?,
Some(vec![]),
None,
false,
)
.map_err(|_| "Failed to write to storage during setup.")?;
// Whitelist the key from further DB operations
frame_benchmarking::benchmarking::add_to_whitelist(key.into());
}
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
Expand Down Expand Up @@ -1041,12 +1043,14 @@ benchmarks! {
for key in keys {
Storage::<T>::write(
&info.trie_id,
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&VarSizedKey::<T>::try_from(key.clone()).map_err(|e| "Key has wrong length")?,
Some(vec![42u8; (n * 2048) as usize]), // value_len increments by 2kb up to max payload_len
None,
false,
)
.map_err(|_| "Failed to write to storage during setup.")?;
// Whitelist the key from further DB operations
frame_benchmarking::benchmarking::add_to_whitelist(key.into());
}
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
Expand Down Expand Up @@ -1138,12 +1142,14 @@ benchmarks! {
for key in keys {
Storage::<T>::write(
&info.trie_id,
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&VarSizedKey::<T>::try_from(key.clone()).map_err(|e| "Key has wrong length")?,
Some(vec![42u8; (n * 2048) as usize]), // value_len increments by 2kb up to max payload_len
None,
false,
)
.map_err(|_| "Failed to write to storage during setup.")?;
// Whitelist the key from further DB operations
frame_benchmarking::benchmarking::add_to_whitelist(key.into());
}
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
Expand Down Expand Up @@ -1246,12 +1252,14 @@ benchmarks! {
for key in keys {
Storage::<T>::write(
&info.trie_id,
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&VarSizedKey::<T>::try_from(key.clone()).map_err(|e| "Key has wrong length")?,
Some(vec![42u8; (n * 2048) as usize]), // value_len increments by 2kb up to max payload_len
None,
false,
)
.map_err(|_| "Failed to write to storage during setup.")?;
// Whitelist the key from further DB operations
frame_benchmarking::benchmarking::add_to_whitelist(key.into());
}
<ContractInfoOf<T>>::insert(&instance.account_id, info);
let origin = RawOrigin::Signed(instance.caller.clone());
Expand Down Expand Up @@ -1342,12 +1350,14 @@ benchmarks! {
for key in keys {
Storage::<T>::write(
&info.trie_id,
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&VarSizedKey::<T>::try_from(key.clone()).map_err(|e| "Key has wrong length")?,
Some(vec![42u8; (n * 2048) as usize]), // value_len increments by 2kb up to max payload_len
None,
false,
)
.map_err(|_| "Failed to write to storage during setup.")?;
// Whitelist the key from further DB operations
frame_benchmarking::benchmarking::add_to_whitelist(key.into());
}
<ContractInfoOf<T>>::insert(&instance.account_id, info);
let origin = RawOrigin::Signed(instance.caller.clone());
Expand Down Expand Up @@ -1450,12 +1460,14 @@ benchmarks! {
for key in keys {
Storage::<T>::write(
&info.trie_id,
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&VarSizedKey::<T>::try_from(key.clone()).map_err(|e| "Key has wrong length")?,
Some(vec![42u8; (n * 2048) as usize]), // value_len increments by 2kb up to max payload_len
None,
false,
)
.map_err(|_| "Failed to write to storage during setup.")?;
// Whitelist the key from further DB operations
frame_benchmarking::benchmarking::add_to_whitelist(key.into());
athei marked this conversation as resolved.
Show resolved Hide resolved
}
<ContractInfoOf<T>>::insert(&instance.account_id, info);
let origin = RawOrigin::Signed(instance.caller.clone());
Expand Down
Loading