From 8713d3e49fb8bbc1f5182e83e634a8ef1052ae07 Mon Sep 17 00:00:00 2001 From: Gemma Date: Wed, 27 Nov 2024 18:37:03 +0800 Subject: [PATCH] Migrated benchmarking of flexible-fee from v1 to v2. --- pallets/flexible-fee/src/benchmarking.rs | 31 ++++++++++++++++-------- pallets/flexible-fee/src/mock.rs | 13 ++++++++++ pallets/flexible-fee/src/weights.rs | 24 +++++++++--------- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/pallets/flexible-fee/src/benchmarking.rs b/pallets/flexible-fee/src/benchmarking.rs index cf1a94714..89c18c3e8 100644 --- a/pallets/flexible-fee/src/benchmarking.rs +++ b/pallets/flexible-fee/src/benchmarking.rs @@ -18,7 +18,7 @@ #![cfg(feature = "runtime-benchmarks")] -use frame_benchmarking::v1::{benchmarks, whitelisted_caller}; +use frame_benchmarking::v2::*; use frame_support::BoundedVec; use bifrost_primitives::{CurrencyId, TokenSymbol}; @@ -27,17 +27,28 @@ use sp_std::vec; use crate::{Call, Config, Pallet}; -benchmarks! { - set_user_default_fee_currency { +#[benchmarks] +mod benchmarks { + use super::*; + + #[benchmark] + fn set_user_default_fee_currency() -> Result<(), BenchmarkError> { let caller = whitelisted_caller(); - }: _(RawOrigin::Signed(caller),Some(CurrencyId::Token(TokenSymbol::DOT))) - set_default_fee_currency_list { + #[extrinsic_call] + _(RawOrigin::Signed(caller), Some(CurrencyId::Token(TokenSymbol::DOT))); + + Ok(()) + } + + #[benchmark] + fn set_default_fee_currency_list() -> Result<(), BenchmarkError> { let default_list = BoundedVec::try_from(vec![CurrencyId::Token(TokenSymbol::DOT)]).unwrap(); - }: _(RawOrigin::Root,default_list) - impl_benchmark_test_suite!( - Pallet, - crate::mock::new_test_ext(), - crate::mock::Test) + #[extrinsic_call] + _(RawOrigin::Root, default_list); + + Ok(()) + } + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext_benchmark(), crate::mock::Test); } diff --git a/pallets/flexible-fee/src/mock.rs b/pallets/flexible-fee/src/mock.rs index 7e061dcb0..bc14b08b6 100644 --- a/pallets/flexible-fee/src/mock.rs +++ b/pallets/flexible-fee/src/mock.rs @@ -310,3 +310,16 @@ impl BalanceCmp for Test { Pallet::::cmp_with_precision(account, currency, amount, amount_precision) } } + +pub struct ExtBuilder; + +impl ExtBuilder { + pub fn build(self) -> sp_io::TestExternalities { + new_test_ext() + } +} + +#[cfg(feature = "runtime-benchmarks")] +pub fn new_test_ext_benchmark() -> sp_io::TestExternalities { + ExtBuilder.build() +} diff --git a/pallets/flexible-fee/src/weights.rs b/pallets/flexible-fee/src/weights.rs index bcc1c4b98..aa4f85257 100644 --- a/pallets/flexible-fee/src/weights.rs +++ b/pallets/flexible-fee/src/weights.rs @@ -24,9 +24,9 @@ //! Autogenerated weights for bifrost_flexible_fee //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-09-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bifrost-jenkins`, CPU: `Intel(R) Xeon(R) CPU E5-26xx v4` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-11-27, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `mjl-legion`, CPU: `12th Gen Intel(R) Core(TM) i9-12900H` //! WASM-EXECUTION: Compiled, CHAIN: Some("bifrost-kusama-local"), DB CACHE: 1024 // Executed Command: @@ -36,7 +36,7 @@ // --chain=bifrost-kusama-local // --steps=50 // --repeat=20 -// --pallet=bifrost_flexible_fee +// --pallet=bifrost_flexible-fee // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -59,24 +59,24 @@ pub trait WeightInfo { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: FlexibleFee UserDefaultFeeCurrency (r:0 w:1) - /// Proof Skipped: FlexibleFee UserDefaultFeeCurrency (max_values: None, max_size: None, mode: Measured) + /// Storage: `FlexibleFee::UserDefaultFeeCurrency` (r:0 w:1) + /// Proof: `FlexibleFee::UserDefaultFeeCurrency` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) fn set_user_default_fee_currency() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_322_000 picoseconds. - Weight::from_parts(11_925_000, 0) + // Minimum execution time: 3_734_000 picoseconds. + Weight::from_parts(3_996_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: FlexibleFee UniversalFeeCurrencyOrderList (r:0 w:1) - /// Proof Skipped: FlexibleFee UniversalFeeCurrencyOrderList (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `FlexibleFee::UniversalFeeCurrencyOrderList` (r:0 w:1) + /// Proof: `FlexibleFee::UniversalFeeCurrencyOrderList` (`max_values`: Some(1), `max_size`: Some(701), added: 1196, mode: `MaxEncodedLen`) fn set_default_fee_currency_list() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_424_000 picoseconds. - Weight::from_parts(10_846_000, 0) + // Minimum execution time: 3_257_000 picoseconds. + Weight::from_parts(3_404_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } }