diff --git a/cumulus/parachain-template/runtime/src/lib.rs b/cumulus/parachain-template/runtime/src/lib.rs index 5686054f55bad20c1863ea51e01571b4de47a454..944933f42cd4086dbaf09ec0dacf514f43292903 100644 --- a/cumulus/parachain-template/runtime/src/lib.rs +++ b/cumulus/parachain-template/runtime/src/lib.rs @@ -629,6 +629,21 @@ construct_runtime!( } ); +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + [frame_system, SystemBench::<Runtime>] + [pallet_balances, Balances] + [pallet_session, SessionBench::<Runtime>] + [pallet_timestamp, Timestamp] + [pallet_collator_selection, CollatorSelection] + ); +} + impl_runtime_apis! { impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { fn slot_duration() -> sp_consensus_aura::SlotDuration { @@ -755,28 +770,22 @@ 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, frame_system, SystemBench::<Runtime>); - list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>); - list_benchmark!(list, extra, pallet_timestamp, Timestamp); - list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } 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 {} @@ -799,12 +808,7 @@ impl_runtime_apis! { 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_session, SessionBench::<Runtime>); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection); + add_benchmarks!(params, batches); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/cumulus/polkadot-parachains/statemine/src/lib.rs b/cumulus/polkadot-parachains/statemine/src/lib.rs index accdd940080c3f75f1897304870b53d5f1313afd..21d509441cd11d15fb864f2609fc681d1c6ea0a6 100644 --- a/cumulus/polkadot-parachains/statemine/src/lib.rs +++ b/cumulus/polkadot-parachains/statemine/src/lib.rs @@ -802,6 +802,26 @@ impl frame_support::traits::OnRuntimeUpgrade for UniquesV1Migration { } } +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + [frame_system, SystemBench::<Runtime>] + [pallet_assets, Assets] + [pallet_balances, Balances] + [pallet_multisig, Multisig] + [pallet_proxy, Proxy] + [pallet_session, SessionBench::<Runtime>] + [pallet_uniques, Uniques] + [pallet_utility, Utility] + [pallet_timestamp, Timestamp] + [pallet_collator_selection, CollatorSelection] + ); +} + impl_runtime_apis! { impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { fn slot_duration() -> sp_consensus_aura::SlotDuration { @@ -928,33 +948,22 @@ 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, frame_system, SystemBench::<Runtime>); - list_benchmark!(list, extra, pallet_assets, Assets); - list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_multisig, Multisig); - list_benchmark!(list, extra, pallet_proxy, Proxy); - list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>); - list_benchmark!(list, extra, pallet_uniques, Uniques); - list_benchmark!(list, extra, pallet_utility, Utility); - list_benchmark!(list, extra, pallet_timestamp, Timestamp); - list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } 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 {} @@ -977,17 +986,7 @@ impl_runtime_apis! { let mut batches = Vec::<BenchmarkBatch>::new(); let params = (&config, &whitelist); - - add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>); - add_benchmark!(params, batches, pallet_assets, Assets); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_multisig, Multisig); - add_benchmark!(params, batches, pallet_proxy, Proxy); - add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>); - add_benchmark!(params, batches, pallet_uniques, Uniques); - add_benchmark!(params, batches, pallet_utility, Utility); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection); + add_benchmarks!(params, batches); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/cumulus/polkadot-parachains/statemint/src/lib.rs b/cumulus/polkadot-parachains/statemint/src/lib.rs index 13444bfd8afd5a36218580f2fbf948c97805696f..a7a2305088b1416f55ff5a6269452a2b7a8ad24a 100644 --- a/cumulus/polkadot-parachains/statemint/src/lib.rs +++ b/cumulus/polkadot-parachains/statemint/src/lib.rs @@ -797,6 +797,26 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + [frame_system, SystemBench::<Runtime>] + [pallet_assets, Assets] + [pallet_balances, Balances] + [pallet_multisig, Multisig] + [pallet_proxy, Proxy] + [pallet_session, SessionBench::<Runtime>] + [pallet_uniques, Uniques] + [pallet_utility, Utility] + [pallet_timestamp, Timestamp] + [pallet_collator_selection, CollatorSelection] + ); +} + impl_runtime_apis! { impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { fn slot_duration() -> sp_consensus_aura::SlotDuration { @@ -923,33 +943,22 @@ 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, frame_system, SystemBench::<Runtime>); - list_benchmark!(list, extra, pallet_assets, Assets); - list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_multisig, Multisig); - list_benchmark!(list, extra, pallet_proxy, Proxy); - list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>); - list_benchmark!(list, extra, pallet_uniques, Uniques); - list_benchmark!(list, extra, pallet_utility, Utility); - list_benchmark!(list, extra, pallet_timestamp, Timestamp); - list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } 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 {} @@ -972,17 +981,7 @@ impl_runtime_apis! { let mut batches = Vec::<BenchmarkBatch>::new(); let params = (&config, &whitelist); - - add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>); - add_benchmark!(params, batches, pallet_assets, Assets); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_multisig, Multisig); - add_benchmark!(params, batches, pallet_proxy, Proxy); - add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>); - add_benchmark!(params, batches, pallet_uniques, Uniques); - add_benchmark!(params, batches, pallet_utility, Utility); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection); + add_benchmarks!(params, batches); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/cumulus/polkadot-parachains/westmint/src/lib.rs b/cumulus/polkadot-parachains/westmint/src/lib.rs index 155014a280e68fb06aabc64ece2de40f6a7c4f27..c7145497bba0ab7d7ecd064a638af18a08321f49 100644 --- a/cumulus/polkadot-parachains/westmint/src/lib.rs +++ b/cumulus/polkadot-parachains/westmint/src/lib.rs @@ -780,6 +780,26 @@ impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip { } } +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + [frame_system, SystemBench::<Runtime>] + [pallet_assets, Assets] + [pallet_balances, Balances] + [pallet_multisig, Multisig] + [pallet_proxy, Proxy] + [pallet_session, SessionBench::<Runtime>] + [pallet_uniques, Uniques] + [pallet_utility, Utility] + [pallet_timestamp, Timestamp] + [pallet_collator_selection, CollatorSelection] + ); +} + impl_runtime_apis! { impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { fn slot_duration() -> sp_consensus_aura::SlotDuration { @@ -906,33 +926,22 @@ 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, frame_system, SystemBench::<Runtime>); - list_benchmark!(list, extra, pallet_assets, Assets); - list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_multisig, Multisig); - list_benchmark!(list, extra, pallet_proxy, Proxy); - list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>); - list_benchmark!(list, extra, pallet_uniques, Uniques); - list_benchmark!(list, extra, pallet_utility, Utility); - list_benchmark!(list, extra, pallet_timestamp, Timestamp); - list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } 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 {} @@ -955,17 +964,7 @@ impl_runtime_apis! { let mut batches = Vec::<BenchmarkBatch>::new(); let params = (&config, &whitelist); - - add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>); - add_benchmark!(params, batches, pallet_assets, Assets); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_multisig, Multisig); - add_benchmark!(params, batches, pallet_proxy, Proxy); - add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>); - add_benchmark!(params, batches, pallet_uniques, Uniques); - add_benchmark!(params, batches, pallet_utility, Utility); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection); + add_benchmarks!(params, batches); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches)