Skip to content

Commit

Permalink
Merge pull request #554 from Manta-Network/jamie/benchmark-cumulus-pa…
Browse files Browse the repository at this point in the history
…llet-xcmp-queue

Benchmark `cumulus-pallet-xcmp-queue` and white list `Treasury Account` in benchmark test
  • Loading branch information
Dengjianping authored Jun 7, 2022
2 parents b4ab435 + a6b9885 commit 7b421ba
Show file tree
Hide file tree
Showing 14 changed files with 285 additions and 103 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/generate_calamari_weights_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ jobs:
id: pallet_asset_manager
name: pallet_asset_manager
iterations: 20
-
extrinsic:
id: '*'
name: cumulus_pallet_xcmp_queue
pallet:
id: cumulus_pallet_xcmp_queue
name: cumulus_pallet_xcmp_queue
iterations: 20
steps:
-
uses: actions/download-artifact@v2
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/generate_dolphin_weights_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ jobs:
id: pallet_manta_pay
name: pallet_manta_pay
iterations: 20
-
extrinsic:
id: '*'
name: cumulus_pallet_xcmp_queue
pallet:
id: cumulus_pallet_xcmp_queue
name: cumulus_pallet_xcmp_queue
iterations: 20
steps:
-
uses: actions/download-artifact@v2
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions runtime/calamari/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ runtime-benchmarks = [
'pallet-preimage/runtime-benchmarks',
'pallet-assets/runtime-benchmarks',
'pallet-asset-manager/runtime-benchmarks',
'cumulus-pallet-xcmp-queue/runtime-benchmarks',
]
# Set timing constants (e.g. session period) to faster versions to speed up testing.
fast-runtime = []
Expand Down
76 changes: 37 additions & 39 deletions runtime/calamari/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,37 @@ pub type Executive = frame_executive::Executive<
crate::migrations::sudo::RemoveSudo<Runtime>,
>;

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
// Substrate pallets
[pallet_balances, Balances]
[pallet_multisig, Multisig]
[frame_system, SystemBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_utility, Utility]
[pallet_democracy, Democracy]
[pallet_collective, Council]
[pallet_membership, CouncilMembership]
[pallet_treasury, Treasury]
[pallet_preimage, Preimage]
[pallet_scheduler, Scheduler]
[pallet_session, SessionBench::<Runtime>]
[pallet_assets, Assets]
// XCM
[cumulus_pallet_xcmp_queue, XcmpQueue]
// Manta pallets
[calamari_vesting, CalamariVesting]
[pallet_tx_pause, TransactionPause]
[manta_collator_selection, CollatorSelection]
[pallet_asset_manager, AssetManager]
);
}

impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
Expand Down Expand Up @@ -867,30 +898,13 @@ impl_runtime_apis! {
Vec<frame_benchmarking::BenchmarkList>,
Vec<frame_support::traits::StorageInfo>,
) {
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
use frame_benchmarking::{Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait;
use frame_system_benchmarking::Pallet as SystemBench;
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;

let mut list = Vec::<BenchmarkList>::new();

list_benchmark!(list, extra, pallet_balances, Balances);
list_benchmark!(list, extra, pallet_multisig, Multisig);
list_benchmark!(list, extra, frame_system, SystemBench::<Runtime>);
list_benchmark!(list, extra, pallet_timestamp, Timestamp);
list_benchmark!(list, extra, pallet_utility, Utility);
list_benchmark!(list, extra, manta_collator_selection, CollatorSelection);
list_benchmark!(list, extra, pallet_democracy, Democracy);
list_benchmark!(list, extra, pallet_collective, Council);
list_benchmark!(list, extra, pallet_membership, CouncilMembership);
list_benchmark!(list, extra, pallet_treasury, Treasury);
list_benchmark!(list, extra, pallet_preimage, Preimage);
list_benchmark!(list, extra, pallet_scheduler, Scheduler);
list_benchmark!(list, extra, calamari_vesting, CalamariVesting);
list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>);
list_benchmark!(list, extra, pallet_tx_pause, TransactionPause);
list_benchmark!(list, extra, pallet_assets, Assets);
list_benchmark!(list, extra, pallet_asset_manager, AssetManager);
list_benchmarks!(list, extra);

let storage_info = AllPalletsReversedWithSystemFirst::storage_info();

Expand All @@ -900,7 +914,7 @@ impl_runtime_apis! {
fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};

use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {}
Expand All @@ -919,29 +933,13 @@ impl_runtime_apis! {
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
// System Events
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
// Treasury Account
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(),
];

let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);

add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_multisig, Multisig);
add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
add_benchmark!(params, batches, pallet_utility, Utility);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, manta_collator_selection, CollatorSelection);
add_benchmark!(params, batches, pallet_democracy, Democracy);
add_benchmark!(params, batches, pallet_collective, Council);
add_benchmark!(params, batches, pallet_membership, CouncilMembership);
add_benchmark!(params, batches, pallet_scheduler, Scheduler);
add_benchmark!(params, batches, pallet_preimage, Preimage);
add_benchmark!(params, batches, pallet_treasury, Treasury);
add_benchmark!(params, batches, calamari_vesting, CalamariVesting);
add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
add_benchmark!(params, batches, pallet_tx_pause, TransactionPause);
add_benchmark!(params, batches, pallet_assets, Assets);
add_benchmark!(params, batches, pallet_asset_manager, AssetManager);
add_benchmarks!(params, batches);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
Expand Down
81 changes: 81 additions & 0 deletions runtime/calamari/src/weights/cumulus_pallet_xcmp_queue.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright 2020-2022 Manta Network.
// This file is part of Manta.

// Manta is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Manta is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Manta. If not, see <http://www.gnu.org/licenses/>.

//! Autogenerated weights for cumulus_pallet_xcmp_queue
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-06-06, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("calamari-dev"), DB CACHE: 1024
// Executed Command:
// manta
// benchmark
// --chain=calamari-dev
// --pallet=cumulus_pallet_xcmp_queue
// --extrinsic=*
// --execution=Wasm
// --wasm-execution=Compiled
// --heap-pages=4096
// --repeat=20
// --steps=50
// --template=.github/resources/frame-weight-template.hbs
// --output=cumulus_pallet_xcmp_queue.rs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;

/// Weight functions needed for cumulus_pallet_xcmp_queue.
pub trait WeightInfo {
fn set_config_with_u32() -> Weight;
fn set_config_with_weight() -> Weight;
}

/// Weights for cumulus_pallet_xcmp_queue using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> cumulus_pallet_xcmp_queue::WeightInfo for SubstrateWeight<T> {
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_u32() -> Weight {
(6_354_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_weight() -> Weight {
(4_226_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
}

// For backwards compatibility and tests
impl WeightInfo for () {
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_u32() -> Weight {
(6_354_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_weight() -> Weight {
(4_226_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
}
1 change: 1 addition & 0 deletions runtime/calamari/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! A list of the different weight modules for our runtime.
pub mod calamari_vesting;
pub mod cumulus_pallet_xcmp_queue;
pub mod frame_system;
pub mod manta_collator_selection;
pub mod pallet_asset_manager;
Expand Down
2 changes: 1 addition & 1 deletion runtime/calamari/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
type ControllerOrigin = EnsureRootOrMoreThanHalfCouncil;
type ControllerOriginConverter = XcmOriginToCallOrigin;
type WeightInfo = ();
type WeightInfo = crate::weights::cumulus_pallet_xcmp_queue::SubstrateWeight<Runtime>;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
Expand Down
1 change: 1 addition & 0 deletions runtime/dolphin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ runtime-benchmarks = [
'pallet-assets/runtime-benchmarks',
'pallet-manta-pay/runtime-benchmarks',
'pallet-asset-manager/runtime-benchmarks',
'cumulus-pallet-xcmp-queue/runtime-benchmarks',
]
# Set timing constants (e.g. session period) to faster versions to speed up testing.
fast-runtime = []
Expand Down
75 changes: 37 additions & 38 deletions runtime/dolphin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,37 @@ pub type Executive = frame_executive::Executive<
AllPalletsReversedWithSystemFirst,
>;

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
// Substrate pallets
[pallet_balances, Balances]
[pallet_multisig, Multisig]
[frame_system, SystemBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_utility, Utility]
[pallet_democracy, Democracy]
[pallet_collective, Council]
[pallet_membership, CouncilMembership]
[pallet_treasury, Treasury]
[pallet_preimage, Preimage]
[pallet_scheduler, Scheduler]
[pallet_session, SessionBench::<Runtime>]
[pallet_assets, Assets]
// XCM
[cumulus_pallet_xcmp_queue, XcmpQueue]
// Manta pallets
[pallet_tx_pause, TransactionPause]
[manta_collator_selection, CollatorSelection]
[pallet_manta_pay, MantaPay]
[pallet_asset_manager, AssetManager]
);
}

impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
Expand Down Expand Up @@ -856,30 +887,13 @@ impl_runtime_apis! {
Vec<frame_benchmarking::BenchmarkList>,
Vec<frame_support::traits::StorageInfo>,
) {
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
use frame_benchmarking::{Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait;
use frame_system_benchmarking::Pallet as SystemBench;
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;

let mut list = Vec::<BenchmarkList>::new();

list_benchmark!(list, extra, pallet_balances, Balances);
list_benchmark!(list, extra, pallet_multisig, Multisig);
list_benchmark!(list, extra, frame_system, SystemBench::<Runtime>);
list_benchmark!(list, extra, pallet_timestamp, Timestamp);
list_benchmark!(list, extra, pallet_utility, Utility);
list_benchmark!(list, extra, manta_collator_selection, CollatorSelection);
list_benchmark!(list, extra, pallet_democracy, Democracy);
list_benchmark!(list, extra, pallet_collective, Council);
list_benchmark!(list, extra, pallet_membership, CouncilMembership);
list_benchmark!(list, extra, pallet_treasury, Treasury);
list_benchmark!(list, extra, pallet_preimage, Preimage);
list_benchmark!(list, extra, pallet_scheduler, Scheduler);
list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>);
list_benchmark!(list, extra, pallet_tx_pause, TransactionPause);
list_benchmark!(list, extra, pallet_assets, Assets);
list_benchmark!(list, extra, pallet_manta_pay, MantaPay);
list_benchmark!(list, extra, pallet_asset_manager, AssetManager);
list_benchmarks!(list, extra);

let storage_info = AllPalletsReversedWithSystemFirst::storage_info();

Expand All @@ -889,7 +903,7 @@ impl_runtime_apis! {
fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};

use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {}
Expand All @@ -908,29 +922,14 @@ impl_runtime_apis! {
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
// System Events
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
// Treasury Account
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(),
];

let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);

add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_multisig, Multisig);
add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
add_benchmark!(params, batches, pallet_utility, Utility);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, manta_collator_selection, CollatorSelection);
add_benchmark!(params, batches, pallet_democracy, Democracy);
add_benchmark!(params, batches, pallet_collective, Council);
add_benchmark!(params, batches, pallet_membership, CouncilMembership);
add_benchmark!(params, batches, pallet_scheduler, Scheduler);
add_benchmark!(params, batches, pallet_preimage, Preimage);
add_benchmark!(params, batches, pallet_treasury, Treasury);
add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
add_benchmark!(params, batches, pallet_tx_pause, TransactionPause);
add_benchmark!(params, batches, pallet_assets, Assets);
add_benchmark!(params, batches, pallet_manta_pay, MantaPay);
add_benchmark!(params, batches, pallet_asset_manager, AssetManager);
add_benchmarks!(params, batches);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
Expand Down
Loading

0 comments on commit 7b421ba

Please sign in to comment.