mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 23:01:01 +00:00
Exchange pallet benchmarks (#158)
* exchange benchmarks: framework * updated comment about tx size Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
ebdfffc4b1
commit
00bd13f8cd
@@ -48,7 +48,6 @@ benchmarks! {
|
||||
header
|
||||
},
|
||||
);
|
||||
|
||||
}: import_unsigned_header(RawOrigin::None, header, None)
|
||||
verify {
|
||||
let storage = BridgeStorage::<T>::new();
|
||||
|
||||
@@ -44,7 +44,7 @@ mod benchmarking;
|
||||
mod mock;
|
||||
|
||||
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||
mod test_utils;
|
||||
pub mod test_utils;
|
||||
|
||||
/// Maximal number of blocks we're pruning in single import call.
|
||||
const MAX_BLOCKS_TO_PRUNE_IN_SINGLE_IMPORT: u64 = 8;
|
||||
@@ -547,7 +547,7 @@ impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
|
||||
|
||||
/// Runtime bridge storage.
|
||||
#[derive(Default)]
|
||||
struct BridgeStorage<T>(sp_std::marker::PhantomData<T>);
|
||||
pub struct BridgeStorage<T>(sp_std::marker::PhantomData<T>);
|
||||
|
||||
impl<T: Trait> BridgeStorage<T> {
|
||||
/// Create new BridgeStorage.
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
use crate::finality::FinalityVotes;
|
||||
use crate::validators::CHANGE_EVENT_HASH;
|
||||
use crate::verification::calculate_score;
|
||||
use crate::{HeaderToImport, Storage};
|
||||
use crate::{HeaderToImport, Storage, Trait};
|
||||
|
||||
use primitives::{
|
||||
rlp_encode,
|
||||
@@ -60,25 +60,34 @@ impl HeaderBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates default header on top of parent with given hash.
|
||||
/// Creates default header on top of test parent with given hash.
|
||||
#[cfg(test)]
|
||||
pub fn with_parent_hash(parent_hash: H256) -> Self {
|
||||
use crate::mock::TestRuntime;
|
||||
Self::with_parent_hash_on_runtime::<crate::mock::TestRuntime>(parent_hash)
|
||||
}
|
||||
|
||||
/// Creates default header on top of test parent with given number. First parent is selected.
|
||||
#[cfg(test)]
|
||||
pub fn with_parent_number(parent_number: u64) -> Self {
|
||||
Self::with_parent_number_on_runtime::<crate::mock::TestRuntime>(parent_number)
|
||||
}
|
||||
|
||||
/// Creates default header on top of parent with given hash.
|
||||
pub fn with_parent_hash_on_runtime<T: Trait>(parent_hash: H256) -> Self {
|
||||
use crate::Headers;
|
||||
use frame_support::StorageMap;
|
||||
|
||||
let parent_header = Headers::<TestRuntime>::get(&parent_hash).unwrap().header;
|
||||
let parent_header = Headers::<T>::get(&parent_hash).unwrap().header;
|
||||
Self::with_parent(&parent_header)
|
||||
}
|
||||
|
||||
/// Creates default header on top of parent with given number. First parent is selected.
|
||||
#[cfg(test)]
|
||||
pub fn with_parent_number(parent_number: u64) -> Self {
|
||||
pub fn with_parent_number_on_runtime<T: Trait>(parent_number: u64) -> Self {
|
||||
use crate::HeadersByNumber;
|
||||
use frame_support::StorageMap;
|
||||
|
||||
let parent_hash = HeadersByNumber::get(parent_number).unwrap()[0].clone();
|
||||
Self::with_parent_hash(parent_hash)
|
||||
Self::with_parent_hash_on_runtime::<T>(parent_hash)
|
||||
}
|
||||
|
||||
/// Creates default header on top of non-existent parent.
|
||||
@@ -185,6 +194,12 @@ impl HeaderBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Update transactions root field of this header.
|
||||
pub fn with_transactions_root(mut self, transactions_root: H256) -> Self {
|
||||
self.header.transactions_root = transactions_root;
|
||||
self
|
||||
}
|
||||
|
||||
/// Signs header by given author.
|
||||
pub fn sign_by(self, author: &SecretKey) -> Header {
|
||||
self.header.sign_by(author)
|
||||
|
||||
Reference in New Issue
Block a user