fixed benchmarks of relayers pallet (#1700)

This commit is contained in:
Svyatoslav Nikolsky
2022-12-05 13:36:11 +03:00
committed by Bastian Köcher
parent 66dfd2dcae
commit b94bd8d46b
4 changed files with 39 additions and 7 deletions
+13 -1
View File
@@ -26,12 +26,24 @@ use frame_system::RawOrigin;
/// Reward amount that is (hopefully) is larger than existential deposit across all chains.
const REWARD_AMOUNT: u32 = u32::MAX;
/// Pallet we're benchmarking here.
pub struct Pallet<T: Config>(crate::Pallet<T>);
/// Trait that must be implemented by runtime.
pub trait Config: crate::Config {
/// Prepare environment for paying given reward for serving given lane.
fn prepare_environment(lane: LaneId, reward: Self::Reward);
}
benchmarks! {
// Benchmark `claim_rewards` call.
claim_rewards {
let lane = [0, 0, 0, 0];
let relayer: T::AccountId = whitelisted_caller();
RelayerRewards::<T>::insert(&relayer, lane, T::Reward::from(REWARD_AMOUNT));
let reward = T::Reward::from(REWARD_AMOUNT);
T::prepare_environment(lane, reward);
RelayerRewards::<T>::insert(&relayer, lane, reward);
}: _(RawOrigin::Signed(relayer), lane)
verify {
// we can't check anything here, because `PaymentProcedure` is responsible for
+2 -1
View File
@@ -30,7 +30,8 @@ use weights::WeightInfo;
pub use pallet::*;
pub use payment_adapter::MessageDeliveryAndDispatchPaymentAdapter;
mod benchmarking;
pub mod benchmarking;
mod mock;
mod payment_adapter;
+3 -3
View File
@@ -17,7 +17,7 @@
//! Autogenerated weights for `pallet_bridge_relayers`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-11-17, STEPS: 50, REPEAT: 20
//! DATE: 2022-12-05, STEPS: 50, REPEAT: 20
//! LOW RANGE: [], HIGH RANGE: []
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
//! CHAIN: Some("dev"), DB CACHE: 1024
@@ -59,7 +59,7 @@ pub trait WeightInfo {
pub struct BridgeWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
fn claim_rewards() -> Weight {
Weight::from_ref_time(59_334_000 as u64)
Weight::from_ref_time(64_065_000 as u64)
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
@@ -68,7 +68,7 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// For backwards compatibility and tests
impl WeightInfo for () {
fn claim_rewards() -> Weight {
Weight::from_ref_time(59_334_000 as u64)
Weight::from_ref_time(64_065_000 as u64)
.saturating_add(RocksDbWeight::get().reads(2 as u64))
.saturating_add(RocksDbWeight::get().writes(2 as u64))
}