mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 02:21:04 +00:00
Custom Benchmark Errors and Override (#9517)
* initial idea * update benchmark test to frame v2 * fix some errors * fixes for elec phrag * fix tests * update extrinsic time and docs * fix import * undo extra changes * helper function * wrong way * Update frame/benchmarking/src/utils.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * doesnt need encode/decode * fix benchmark return Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -21,7 +21,9 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelist};
|
||||
use frame_benchmarking::{
|
||||
account, benchmarks, impl_benchmark_test_suite, whitelist, BenchmarkError, BenchmarkResult,
|
||||
};
|
||||
use frame_support::{dispatch::DispatchResultWithPostInfo, traits::OnInitialize};
|
||||
use frame_system::RawOrigin;
|
||||
|
||||
@@ -332,9 +334,16 @@ benchmarks! {
|
||||
}
|
||||
}
|
||||
|
||||
// We use the max block weight for this extrinsic for now. See below.
|
||||
remove_member_without_replacement {}: {
|
||||
Err(BenchmarkError::Override(
|
||||
BenchmarkResult::from_weight(T::BlockWeights::get().max_block)
|
||||
))?;
|
||||
}
|
||||
|
||||
// -- Root ones
|
||||
#[extra] // this calls into phragmen and consumes a full block for now.
|
||||
remove_member_without_replacement {
|
||||
remove_member_without_replacement_extra {
|
||||
// worse case is when we remove a member and we have no runner as a replacement. This
|
||||
// triggers phragmen again. The only parameter is how many candidates will compete for the
|
||||
// new slot.
|
||||
|
||||
@@ -474,7 +474,7 @@ pub mod pallet {
|
||||
#[pallet::weight(if *has_replacement {
|
||||
T::WeightInfo::remove_member_with_replacement()
|
||||
} else {
|
||||
T::BlockWeights::get().max_block
|
||||
T::WeightInfo::remove_member_without_replacement()
|
||||
})]
|
||||
pub fn remove_member(
|
||||
origin: OriginFor<T>,
|
||||
|
||||
@@ -54,6 +54,7 @@ pub trait WeightInfo {
|
||||
fn renounce_candidacy_members() -> Weight;
|
||||
fn renounce_candidacy_runners_up() -> Weight;
|
||||
fn remove_member_with_replacement() -> Weight;
|
||||
fn remove_member_without_replacement() -> Weight;
|
||||
fn remove_member_wrong_refund() -> Weight;
|
||||
fn clean_defunct_voters(v: u32, d: u32, ) -> Weight;
|
||||
fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight;
|
||||
@@ -150,6 +151,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(5 as Weight))
|
||||
}
|
||||
fn remove_member_without_replacement() -> Weight {
|
||||
T::BlockWeights::get().max_block
|
||||
}
|
||||
// Storage: Elections RunnersUp (r:1 w:0)
|
||||
fn remove_member_wrong_refund() -> Weight {
|
||||
(6_697_000 as Weight)
|
||||
@@ -282,6 +286,11 @@ impl WeightInfo for () {
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
|
||||
}
|
||||
fn remove_member_without_replacement() -> Weight {
|
||||
(76_153_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
|
||||
}
|
||||
// Storage: Elections RunnersUp (r:1 w:0)
|
||||
fn remove_member_wrong_refund() -> Weight {
|
||||
(6_697_000 as Weight)
|
||||
|
||||
Reference in New Issue
Block a user