Skip to content

Commit 74362ee

Browse files
shawntabrizigui1117apopiak
authored
Dynamic Benchmarking DB Whitelist (#6815)
* Add `get_whitelist` api * add whitelisted caller * Whitelist caller * remove caller 0 * initial piping of origin (not actual value yet) * remove attempt to pass origin around * Add whitelist for `DidUpdate` storage on `pallet_timestamp` * fix traits * only add to whitelist if !contains * PassBy not implemented error * Whitelist read/writes explicitly per key * update docs * reduce trait constraint * copy pasta * Apply suggestions from code review Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * rename functions @apopiak * missed some renaming * enable doc tests * Update docs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
1 parent fb80afd commit 74362ee

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/benchmarking.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::*;
2323
use sp_std::prelude::*;
2424
use frame_system::RawOrigin;
2525
use frame_support::{ensure, traits::OnFinalize};
26-
use frame_benchmarking::benchmarks;
26+
use frame_benchmarking::{benchmarks, TrackedStorageKey};
2727

2828
use crate::Module as Timestamp;
2929

@@ -34,8 +34,14 @@ benchmarks! {
3434

3535
set {
3636
let t in 1 .. MAX_TIME;
37+
// Ignore write to `DidUpdate` since it transient.
38+
let did_update_key = crate::DidUpdate::hashed_key().to_vec();
39+
frame_benchmarking::benchmarking::add_to_whitelist(TrackedStorageKey {
40+
key: did_update_key,
41+
has_been_read: false,
42+
has_been_written: true,
43+
});
3744
}: _(RawOrigin::None, t.into())
38-
3945
verify {
4046
ensure!(Timestamp::<T>::now() == t.into(), "Time was not set.");
4147
}
@@ -44,8 +50,10 @@ benchmarks! {
4450
let t in 1 .. MAX_TIME;
4551
Timestamp::<T>::set(RawOrigin::None.into(), t.into())?;
4652
ensure!(DidUpdate::exists(), "Time was not set.");
53+
// Ignore read/write to `DidUpdate` since it is transient.
54+
let did_update_key = crate::DidUpdate::hashed_key().to_vec();
55+
frame_benchmarking::benchmarking::add_to_whitelist(did_update_key.into());
4756
}: { Timestamp::<T>::on_finalize(t.into()); }
48-
4957
verify {
5058
ensure!(!DidUpdate::exists(), "Time was not removed.");
5159
}

0 commit comments

Comments
 (0)