mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 23:57:56 +00:00
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:
@@ -19,7 +19,10 @@
|
||||
|
||||
use hash_db::Hasher;
|
||||
use codec::{Decode, Encode};
|
||||
use sp_core::{traits::RuntimeCode, storage::{ChildInfo, well_known_keys}};
|
||||
use sp_core::{
|
||||
traits::RuntimeCode,
|
||||
storage::{ChildInfo, well_known_keys, TrackedStorageKey}
|
||||
};
|
||||
use crate::{
|
||||
trie_backend::TrieBackend,
|
||||
trie_backend_essence::TrieBackendStorage,
|
||||
@@ -226,10 +229,13 @@ pub trait Backend<H: Hasher>: std::fmt::Debug {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
/// Update the whitelist for tracking db reads/writes
|
||||
fn set_whitelist(&self, _: Vec<Vec<u8>>) {
|
||||
unimplemented!()
|
||||
/// Get the whitelist for tracking db reads/writes
|
||||
fn get_whitelist(&self) -> Vec<TrackedStorageKey> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
/// Update the whitelist for tracking db reads/writes
|
||||
fn set_whitelist(&self, _: Vec<TrackedStorageKey>) {}
|
||||
}
|
||||
|
||||
impl<'a, T: Backend<H>, H: Hasher> Backend<H> for &'a T {
|
||||
|
||||
@@ -27,7 +27,7 @@ use sp_trie::trie_types::Layout;
|
||||
use sp_core::{
|
||||
storage::{
|
||||
well_known_keys::is_child_storage_key, Storage,
|
||||
ChildInfo, StorageChild,
|
||||
ChildInfo, StorageChild, TrackedStorageKey,
|
||||
},
|
||||
traits::Externalities, Blake2Hasher,
|
||||
};
|
||||
@@ -325,7 +325,11 @@ impl Externalities for BasicExternalities {
|
||||
unimplemented!("reset_read_write_count is not supported in Basic")
|
||||
}
|
||||
|
||||
fn set_whitelist(&mut self, _: Vec<Vec<u8>>) {
|
||||
fn get_whitelist(&self) -> Vec<TrackedStorageKey> {
|
||||
unimplemented!("get_whitelist is not supported in Basic")
|
||||
}
|
||||
|
||||
fn set_whitelist(&mut self, _: Vec<TrackedStorageKey>) {
|
||||
unimplemented!("set_whitelist is not supported in Basic")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::{
|
||||
use hash_db::Hasher;
|
||||
use sp_core::{
|
||||
offchain::storage::OffchainOverlayedChanges,
|
||||
storage::{well_known_keys::is_child_storage_key, ChildInfo},
|
||||
storage::{well_known_keys::is_child_storage_key, ChildInfo, TrackedStorageKey},
|
||||
traits::Externalities, hexdisplay::HexDisplay,
|
||||
};
|
||||
use sp_trie::{trie_types::Layout, empty_child_trie_root};
|
||||
@@ -609,7 +609,11 @@ where
|
||||
self.backend.reset_read_write_count()
|
||||
}
|
||||
|
||||
fn set_whitelist(&mut self, new: Vec<Vec<u8>>) {
|
||||
fn get_whitelist(&self) -> Vec<TrackedStorageKey> {
|
||||
self.backend.get_whitelist()
|
||||
}
|
||||
|
||||
fn set_whitelist(&mut self, new: Vec<TrackedStorageKey>) {
|
||||
self.backend.set_whitelist(new)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ use std::{
|
||||
use crate::{Backend, StorageKey, StorageValue};
|
||||
use hash_db::Hasher;
|
||||
use sp_core::{
|
||||
storage::ChildInfo,
|
||||
storage::{ChildInfo, TrackedStorageKey},
|
||||
traits::Externalities, Blake2Hasher,
|
||||
};
|
||||
use codec::Encode;
|
||||
@@ -194,7 +194,11 @@ impl<'a, H: Hasher, B: 'a + Backend<H>> Externalities for ReadOnlyExternalities<
|
||||
unimplemented!("reset_read_write_count is not supported in ReadOnlyExternalities")
|
||||
}
|
||||
|
||||
fn set_whitelist(&mut self, _: Vec<Vec<u8>>) {
|
||||
fn get_whitelist(&self) -> Vec<TrackedStorageKey> {
|
||||
unimplemented!("get_whitelist is not supported in ReadOnlyExternalities")
|
||||
}
|
||||
|
||||
fn set_whitelist(&mut self, _: Vec<TrackedStorageKey>) {
|
||||
unimplemented!("set_whitelist is not supported in ReadOnlyExternalities")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user