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>
This commit is contained in:
Shawn Tabrizi
2020-08-19 18:15:50 +02:00
committed by GitHub
parent 8b5ced7fa7
commit 481ad884d6
26 changed files with 421 additions and 205 deletions
+11 -3
View File
@@ -23,7 +23,7 @@ use super::*;
use sp_std::prelude::*;
use frame_system::RawOrigin;
use frame_support::{ensure, traits::OnFinalize};
use frame_benchmarking::benchmarks;
use frame_benchmarking::{benchmarks, TrackedStorageKey};
use crate::Module as Timestamp;
@@ -34,8 +34,14 @@ benchmarks! {
set {
let t in 1 .. MAX_TIME;
// Ignore write to `DidUpdate` since it transient.
let did_update_key = crate::DidUpdate::hashed_key().to_vec();
frame_benchmarking::benchmarking::add_to_whitelist(TrackedStorageKey {
key: did_update_key,
has_been_read: false,
has_been_written: true,
});
}: _(RawOrigin::None, t.into())
verify {
ensure!(Timestamp::<T>::now() == t.into(), "Time was not set.");
}
@@ -44,8 +50,10 @@ benchmarks! {
let t in 1 .. MAX_TIME;
Timestamp::<T>::set(RawOrigin::None.into(), t.into())?;
ensure!(DidUpdate::exists(), "Time was not set.");
// Ignore read/write to `DidUpdate` since it is transient.
let did_update_key = crate::DidUpdate::hashed_key().to_vec();
frame_benchmarking::benchmarking::add_to_whitelist(did_update_key.into());
}: { Timestamp::<T>::on_finalize(t.into()); }
verify {
ensure!(!DidUpdate::exists(), "Time was not removed.");
}