diff --git a/polkadot/bridges/bin/millau/runtime/src/lib.rs b/polkadot/bridges/bin/millau/runtime/src/lib.rs index 10edf4de34..d698df0f47 100644 --- a/polkadot/bridges/bin/millau/runtime/src/lib.rs +++ b/polkadot/bridges/bin/millau/runtime/src/lib.rs @@ -556,6 +556,17 @@ pub type Executive = frame_executive::Executive< AllPallets, >; +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + [pallet_bridge_token_swap, BridgeRialtoTokenSwap] + ); +} + impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { @@ -802,22 +813,20 @@ impl_runtime_apis! { Vec, Vec, ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; let mut list = Vec::::new(); - - list_benchmark!(list, extra, pallet_bridge_token_swap, BridgeRialtoTokenSwap); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig, ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, add_benchmark}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; let whitelist: Vec = vec![ // Block Number @@ -850,7 +859,7 @@ impl_runtime_apis! { } } - add_benchmark!(params, batches, pallet_bridge_token_swap, BridgeRialtoTokenSwap); + add_benchmarks!(params, batches); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/polkadot/bridges/bin/rialto-parachain/runtime/src/lib.rs b/polkadot/bridges/bin/rialto-parachain/runtime/src/lib.rs index 407af35727..71e3244a75 100644 --- a/polkadot/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/polkadot/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -472,6 +472,19 @@ construct_runtime!( } ); +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + [frame_system, SystemBench::] + [pallet_balances, Balances] + [pallet_timestamp, Timestamp] + ); +} + impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { @@ -586,7 +599,7 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, 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 {} @@ -606,10 +619,7 @@ impl_runtime_apis! { let mut batches = Vec::::new(); let params = (&config, &whitelist); - - add_benchmark!(params, batches, frame_system, SystemBench::); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); + add_benchmarks!(params, batches); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/polkadot/bridges/bin/rialto/runtime/src/lib.rs b/polkadot/bridges/bin/rialto/runtime/src/lib.rs index 4c1901f5a3..0d48b96c65 100644 --- a/polkadot/bridges/bin/rialto/runtime/src/lib.rs +++ b/polkadot/bridges/bin/rialto/runtime/src/lib.rs @@ -573,6 +573,19 @@ pub type Executive = frame_executive::Executive< AllPallets, >; +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + [pallet_bridge_messages, + MessagesBench::] + [pallet_bridge_grandpa, BridgeMillauGrandpa] + ); +} + impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { @@ -947,18 +960,15 @@ impl_runtime_apis! { Vec, Vec, ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use pallet_bridge_messages::benchmarking::Pallet as MessagesBench; let mut list = Vec::::new(); - - list_benchmark!(list, extra, pallet_bridge_messages, MessagesBench::); - list_benchmark!(list, extra, pallet_bridge_grandpa, BridgeMillauGrandpa); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } @@ -968,7 +978,7 @@ impl_runtime_apis! { Vec, sp_runtime::RuntimeString, > { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; use frame_support::traits::StorageInfoTrait; let whitelist: Vec = vec![ @@ -1153,13 +1163,7 @@ impl_runtime_apis! { } } - add_benchmark!( - params, - batches, - pallet_bridge_messages, - MessagesBench:: - ); - add_benchmark!(params, batches, pallet_bridge_grandpa, BridgeMillauGrandpa); + add_benchmarks!(params, batches); Ok(batches) } diff --git a/polkadot/runtime/kusama/src/lib.rs b/polkadot/runtime/kusama/src/lib.rs index 02d2d18393..6fe53240da 100644 --- a/polkadot/runtime/kusama/src/lib.rs +++ b/polkadot/runtime/kusama/src/lib.rs @@ -2947,6 +2947,57 @@ impl OnRuntimeUpgrade for SessionHistoricalPalletPrefixMigration { } } +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + // Polkadot + // NOTE: Make sure to prefix these with `runtime_common::` so + // the that path resolves correctly in the generated file. + [runtime_common::auctions, Auctions] + [runtime_common::crowdloan, Crowdloan] + [runtime_common::claims, Claims] + [runtime_common::slots, Slots] + [runtime_common::paras_registrar, Registrar] + [runtime_parachains::configuration, Configuration] + [runtime_parachains::hrmp, Hrmp] + [runtime_parachains::disputes, ParasDisputes] + [runtime_parachains::initializer, Initializer] + [runtime_parachains::paras_inherent, ParaInherent] + [runtime_parachains::paras, Paras] + // Substrate + [pallet_balances, Balances] + [pallet_bags_list, BagsList] + [pallet_bounties, Bounties] + [pallet_collective, Council] + [pallet_collective, TechnicalCommittee] + [pallet_democracy, Democracy] + [pallet_elections_phragmen, PhragmenElection] + [pallet_election_provider_multi_phase, ElectionProviderMultiPhase] + [pallet_gilt, Gilt] + [pallet_identity, Identity] + [pallet_im_online, ImOnline] + [pallet_indices, Indices] + [pallet_membership, TechnicalMembership] + [pallet_multisig, Multisig] + [pallet_offences, OffencesBench::] + [pallet_preimage, Preimage] + [pallet_proxy, Proxy] + [pallet_scheduler, Scheduler] + [pallet_session, SessionBench::] + [pallet_staking, Staking] + [frame_system, SystemBench::] + [pallet_timestamp, Timestamp] + [pallet_tips, Tips] + [pallet_treasury, Treasury] + [pallet_utility, Utility] + [pallet_vesting, Vesting] + ); +} + #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -3280,7 +3331,7 @@ sp_api::impl_runtime_apis! { Vec, Vec, ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use pallet_session_benchmarking::Pallet as SessionBench; @@ -3288,51 +3339,9 @@ sp_api::impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; let mut list = Vec::::new(); - - // Polkadot - // NOTE: Make sure to prefix these `runtime_common::` so that path resolves correctly - // in the generated file. - list_benchmark!(list, extra, runtime_common::auctions, Auctions); - list_benchmark!(list, extra, runtime_common::crowdloan, Crowdloan); - list_benchmark!(list, extra, runtime_common::claims, Claims); - list_benchmark!(list, extra, runtime_common::slots, Slots); - list_benchmark!(list, extra, runtime_common::paras_registrar, Registrar); - list_benchmark!(list, extra, runtime_parachains::configuration, Configuration); - list_benchmark!(list, extra, runtime_parachains::hrmp, Hrmp); - list_benchmark!(list, extra, runtime_parachains::disputes, ParasDisputes); - list_benchmark!(list, extra, runtime_parachains::initializer, Initializer); - list_benchmark!(list, extra, runtime_parachains::paras_inherent, ParaInherent); - list_benchmark!(list, extra, runtime_parachains::paras, Paras); - // Substrate - list_benchmark!(list, extra, pallet_bags_list, BagsList); - list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_bounties, Bounties); - list_benchmark!(list, extra, pallet_collective, Council); - list_benchmark!(list, extra, pallet_collective, TechnicalCommittee); - list_benchmark!(list, extra, pallet_democracy, Democracy); - list_benchmark!(list, extra, pallet_elections_phragmen, PhragmenElection); - list_benchmark!(list, extra, pallet_election_provider_multi_phase, ElectionProviderMultiPhase); - list_benchmark!(list, extra, pallet_gilt, Gilt); - list_benchmark!(list, extra, pallet_identity, Identity); - list_benchmark!(list, extra, pallet_im_online, ImOnline); - list_benchmark!(list, extra, pallet_indices, Indices); - list_benchmark!(list, extra, pallet_membership, TechnicalMembership); - list_benchmark!(list, extra, pallet_multisig, Multisig); - list_benchmark!(list, extra, pallet_offences, OffencesBench::); - list_benchmark!(list, extra, pallet_preimage, Preimage); - list_benchmark!(list, extra, pallet_proxy, Proxy); - list_benchmark!(list, extra, pallet_scheduler, Scheduler); - list_benchmark!(list, extra, pallet_session, SessionBench::); - list_benchmark!(list, extra, pallet_staking, Staking); - list_benchmark!(list, extra, frame_system, SystemBench::); - list_benchmark!(list, extra, pallet_timestamp, Timestamp); - list_benchmark!(list, extra, pallet_tips, Tips); - list_benchmark!(list, extra, pallet_treasury, Treasury); - list_benchmark!(list, extra, pallet_utility, Utility); - list_benchmark!(list, extra, pallet_vesting, Vesting); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } @@ -3342,7 +3351,7 @@ sp_api::impl_runtime_apis! { Vec, sp_runtime::RuntimeString, > { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; // Trying to add benchmarks directly to some pallets caused cyclic dependency issues. // To get around that, we separated the benchmarks into its own crate. use pallet_session_benchmarking::Pallet as SessionBench; @@ -3370,47 +3379,8 @@ sp_api::impl_runtime_apis! { let mut batches = Vec::::new(); let params = (&config, &whitelist); - // Polkadot - // NOTE: Make sure to prefix these `runtime_common::` so that path resolves correctly - // in the generated file. - add_benchmark!(params, batches, runtime_common::auctions, Auctions); - add_benchmark!(params, batches, runtime_common::crowdloan, Crowdloan); - add_benchmark!(params, batches, runtime_common::claims, Claims); - add_benchmark!(params, batches, runtime_common::slots, Slots); - add_benchmark!(params, batches, runtime_common::paras_registrar, Registrar); - add_benchmark!(params, batches, runtime_parachains::configuration, Configuration); - add_benchmark!(params, batches, runtime_parachains::hrmp, Hrmp); - add_benchmark!(params, batches, runtime_parachains::disputes, ParasDisputes); - add_benchmark!(params, batches, runtime_parachains::initializer, Initializer); - add_benchmark!(params, batches, runtime_parachains::paras_inherent, ParaInherent); - add_benchmark!(params, batches, runtime_parachains::paras, Paras); - // Substrate - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_bags_list, BagsList); - add_benchmark!(params, batches, pallet_bounties, Bounties); - add_benchmark!(params, batches, pallet_collective, Council); - add_benchmark!(params, batches, pallet_collective, TechnicalCommittee); - add_benchmark!(params, batches, pallet_democracy, Democracy); - add_benchmark!(params, batches, pallet_elections_phragmen, PhragmenElection); - add_benchmark!(params, batches, pallet_election_provider_multi_phase, ElectionProviderMultiPhase); - add_benchmark!(params, batches, pallet_gilt, Gilt); - add_benchmark!(params, batches, pallet_identity, Identity); - add_benchmark!(params, batches, pallet_im_online, ImOnline); - add_benchmark!(params, batches, pallet_indices, Indices); - add_benchmark!(params, batches, pallet_membership, TechnicalMembership); - add_benchmark!(params, batches, pallet_multisig, Multisig); - add_benchmark!(params, batches, pallet_offences, OffencesBench::); - add_benchmark!(params, batches, pallet_preimage, Preimage); - add_benchmark!(params, batches, pallet_proxy, Proxy); - add_benchmark!(params, batches, pallet_scheduler, Scheduler); - add_benchmark!(params, batches, pallet_session, SessionBench::); - add_benchmark!(params, batches, pallet_staking, Staking); - add_benchmark!(params, batches, frame_system, SystemBench::); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - add_benchmark!(params, batches, pallet_tips, Tips); - add_benchmark!(params, batches, pallet_treasury, Treasury); - add_benchmark!(params, batches, pallet_utility, Utility); - add_benchmark!(params, batches, pallet_vesting, Vesting); + + add_benchmarks!(params, batches); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/polkadot/runtime/polkadot/src/lib.rs b/polkadot/runtime/polkadot/src/lib.rs index c49a6d46ce..13dd2375e0 100644 --- a/polkadot/runtime/polkadot/src/lib.rs +++ b/polkadot/runtime/polkadot/src/lib.rs @@ -1701,6 +1701,53 @@ impl OnRuntimeUpgrade for SessionHistoricalPalletPrefixMigration { } } +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + // Polkadot + // NOTE: Make sure to prefix these with `runtime_common::` so + // the that path resolves correctly in the generated file. + [runtime_common::claims, Claims] + [runtime_common::crowdloan, Crowdloan] + [runtime_common::slots, Slots] + [runtime_common::paras_registrar, Registrar] + [runtime_parachains::configuration, Configuration] + [runtime_parachains::initializer, Initializer] + [runtime_parachains::paras, Paras] + [runtime_parachains::paras_inherent, ParaInherent] + // Substrate + [pallet_bags_list, BagsList] + [pallet_balances, Balances] + [pallet_bounties, Bounties] + [pallet_collective, Council] + [pallet_collective, TechnicalCommittee] + [pallet_democracy, Democracy] + [pallet_elections_phragmen, PhragmenElection] + [pallet_election_provider_multi_phase, ElectionProviderMultiPhase] + [pallet_identity, Identity] + [pallet_im_online, ImOnline] + [pallet_indices, Indices] + [pallet_membership, TechnicalMembership] + [pallet_multisig, Multisig] + [pallet_offences, OffencesBench::] + [pallet_preimage, Preimage] + [pallet_proxy, Proxy] + [pallet_scheduler, Scheduler] + [pallet_session, SessionBench::] + [pallet_staking, Staking] + [frame_system, SystemBench::] + [pallet_timestamp, Timestamp] + [pallet_tips, Tips] + [pallet_treasury, Treasury] + [pallet_utility, Utility] + [pallet_vesting, Vesting] + ); +} + #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -2035,7 +2082,7 @@ sp_api::impl_runtime_apis! { Vec, Vec, ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use pallet_session_benchmarking::Pallet as SessionBench; @@ -2043,47 +2090,9 @@ sp_api::impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; let mut list = Vec::::new(); - - // Polkadot - // NOTE: Make sure to prefix these `runtime_common::` so that path resolves correctly - // in the generated file. - list_benchmark!(list, extra, runtime_common::claims, Claims); - list_benchmark!(list, extra, runtime_common::crowdloan, Crowdloan); - list_benchmark!(list, extra, runtime_common::slots, Slots); - list_benchmark!(list, extra, runtime_common::paras_registrar, Registrar); - list_benchmark!(list, extra, runtime_parachains::configuration, Configuration); - list_benchmark!(list, extra, runtime_parachains::initializer, Initializer); - list_benchmark!(list, extra, runtime_parachains::paras, Paras); - list_benchmark!(list, extra, runtime_parachains::paras_inherent, ParaInherent); - // Substrate - list_benchmark!(list, extra, pallet_bags_list, BagsList); - list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_bounties, Bounties); - list_benchmark!(list, extra, pallet_collective, Council); - list_benchmark!(list, extra, pallet_collective, TechnicalCommittee); - list_benchmark!(list, extra, pallet_democracy, Democracy); - list_benchmark!(list, extra, pallet_elections_phragmen, PhragmenElection); - list_benchmark!(list, extra, pallet_election_provider_multi_phase, ElectionProviderMultiPhase); - list_benchmark!(list, extra, pallet_identity, Identity); - list_benchmark!(list, extra, pallet_im_online, ImOnline); - list_benchmark!(list, extra, pallet_indices, Indices); - list_benchmark!(list, extra, pallet_membership, TechnicalMembership); - list_benchmark!(list, extra, pallet_multisig, Multisig); - list_benchmark!(list, extra, pallet_offences, OffencesBench::); - list_benchmark!(list, extra, pallet_preimage, Preimage); - list_benchmark!(list, extra, pallet_proxy, Proxy); - list_benchmark!(list, extra, pallet_scheduler, Scheduler); - list_benchmark!(list, extra, pallet_session, SessionBench::); - list_benchmark!(list, extra, pallet_staking, Staking); - list_benchmark!(list, extra, frame_system, SystemBench::); - list_benchmark!(list, extra, pallet_timestamp, Timestamp); - list_benchmark!(list, extra, pallet_tips, Tips); - list_benchmark!(list, extra, pallet_treasury, Treasury); - list_benchmark!(list, extra, pallet_utility, Utility); - list_benchmark!(list, extra, pallet_vesting, Vesting); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } @@ -2093,7 +2102,7 @@ sp_api::impl_runtime_apis! { Vec, sp_runtime::RuntimeString, > { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; // Trying to add benchmarks directly to some pallets caused cyclic dependency issues. // To get around that, we separated the benchmarks into its own crate. use pallet_session_benchmarking::Pallet as SessionBench; @@ -2121,43 +2130,7 @@ sp_api::impl_runtime_apis! { let mut batches = Vec::::new(); let params = (&config, &whitelist); - // Polkadot - // NOTE: Make sure to prefix these `runtime_common::` so that path resolves correctly - // in the generated file. - add_benchmark!(params, batches, runtime_common::claims, Claims); - add_benchmark!(params, batches, runtime_common::crowdloan, Crowdloan); - add_benchmark!(params, batches, runtime_common::slots, Slots); - add_benchmark!(params, batches, runtime_common::paras_registrar, Registrar); - add_benchmark!(params, batches, runtime_parachains::configuration, Configuration); - add_benchmark!(params, batches, runtime_parachains::initializer, Initializer); - add_benchmark!(params, batches, runtime_parachains::paras, Paras); - add_benchmark!(params, batches, runtime_parachains::paras_inherent, ParaInherent); - // Substrate - add_benchmark!(params, batches, pallet_bags_list, BagsList); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_bounties, Bounties); - add_benchmark!(params, batches, pallet_collective, Council); - add_benchmark!(params, batches, pallet_collective, TechnicalCommittee); - add_benchmark!(params, batches, pallet_democracy, Democracy); - add_benchmark!(params, batches, pallet_elections_phragmen, PhragmenElection); - add_benchmark!(params, batches, pallet_election_provider_multi_phase, ElectionProviderMultiPhase); - add_benchmark!(params, batches, pallet_identity, Identity); - add_benchmark!(params, batches, pallet_im_online, ImOnline); - add_benchmark!(params, batches, pallet_indices, Indices); - add_benchmark!(params, batches, pallet_membership, TechnicalMembership); - add_benchmark!(params, batches, pallet_multisig, Multisig); - add_benchmark!(params, batches, pallet_offences, OffencesBench::); - add_benchmark!(params, batches, pallet_preimage, Preimage); - add_benchmark!(params, batches, pallet_proxy, Proxy); - add_benchmark!(params, batches, pallet_scheduler, Scheduler); - add_benchmark!(params, batches, pallet_session, SessionBench::); - add_benchmark!(params, batches, pallet_staking, Staking); - add_benchmark!(params, batches, frame_system, SystemBench::); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - add_benchmark!(params, batches, pallet_tips, Tips); - add_benchmark!(params, batches, pallet_treasury, Treasury); - add_benchmark!(params, batches, pallet_utility, Utility); - add_benchmark!(params, batches, pallet_vesting, Vesting); + add_benchmarks!(params, batches); Ok(batches) } diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 1c15d2c932..fa65abcc23 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -1095,6 +1095,20 @@ impl pallet_multisig::Config for Runtime { type WeightInfo = (); } +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + [runtime_parachains::configuration, Configuration] + [runtime_parachains::disputes, ParasDisputes] + [runtime_parachains::paras_inherent, ParaInherent] + [runtime_parachains::paras, Paras] + ); +} + #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -1552,18 +1566,13 @@ sp_api::impl_runtime_apis! { Vec, Vec, ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; let mut list = Vec::::new(); - - list_benchmark!(list, extra, runtime_parachains::configuration, Configuration); - list_benchmark!(list, extra, runtime_parachains::disputes, ParasDisputes); - list_benchmark!(list, extra, runtime_parachains::paras_inherent, ParaInherent); - list_benchmark!(list, extra, runtime_parachains::paras, Paras); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } @@ -1573,7 +1582,7 @@ sp_api::impl_runtime_apis! { Vec, sp_runtime::RuntimeString, > { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; let mut batches = Vec::::new(); let whitelist: Vec = vec![ @@ -1589,11 +1598,7 @@ sp_api::impl_runtime_apis! { hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), ]; let params = (&config, &whitelist); - - add_benchmark!(params, batches, runtime_parachains::configuration, Configuration); - add_benchmark!(params, batches, runtime_parachains::disputes, ParasDisputes); - add_benchmark!(params, batches, runtime_parachains::paras_inherent, ParaInherent); - add_benchmark!(params, batches, runtime_parachains::paras, Paras); + add_benchmarks!(params, batches); Ok(batches) } diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index d57e17ebb0..88e553d0a7 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -1126,6 +1126,49 @@ impl OnRuntimeUpgrade for SessionHistoricalPalletPrefixMigration { Ok(()) } } +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + // Polkadot + // NOTE: Make sure to prefix these with `runtime_common::` so + // the that path resolves correctly in the generated file. + [runtime_common::auctions, Auctions] + [runtime_common::crowdloan, Crowdloan] + [runtime_common::paras_registrar, Registrar] + [runtime_common::slots, Slots] + [runtime_parachains::configuration, Configuration] + [runtime_parachains::hrmp, Hrmp] + [runtime_parachains::initializer, Initializer] + [runtime_parachains::paras, Paras] + [runtime_parachains::paras_inherent, ParaInherent] + // Substrate + [pallet_bags_list, BagsList] + [pallet_balances, Balances] + [pallet_election_provider_multi_phase, ElectionProviderMultiPhase] + [pallet_identity, Identity] + [pallet_im_online, ImOnline] + [pallet_indices, Indices] + [pallet_multisig, Multisig] + [pallet_offences, OffencesBench::] + [pallet_preimage, Preimage] + [pallet_proxy, Proxy] + [pallet_scheduler, Scheduler] + [pallet_session, SessionBench::] + [pallet_staking, Staking] + [frame_system, SystemBench::] + [pallet_timestamp, Timestamp] + [pallet_utility, Utility] + [pallet_vesting, Vesting] + // XCM + // NOTE: Make sure you point to the individual modules below. + [pallet_xcm_benchmarks::fungible, XcmBalances] + [pallet_xcm_benchmarks::generic, XcmGeneric] + ); +} #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { @@ -1460,7 +1503,7 @@ sp_api::impl_runtime_apis! { Vec, Vec, ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use pallet_session_benchmarking::Pallet as SessionBench; @@ -1471,46 +1514,9 @@ sp_api::impl_runtime_apis! { type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; let mut list = Vec::::new(); - - // Polkadot - // NOTE: Make sure to prefix these `runtime_common::` so that path resolves correctly - // in the generated file. - list_benchmark!(list, extra, runtime_common::auctions, Auctions); - list_benchmark!(list, extra, runtime_common::crowdloan, Crowdloan); - list_benchmark!(list, extra, runtime_common::paras_registrar, Registrar); - list_benchmark!(list, extra, runtime_common::slots, Slots); - list_benchmark!(list, extra, runtime_parachains::configuration, Configuration); - list_benchmark!(list, extra, runtime_parachains::hrmp, Hrmp); - list_benchmark!(list, extra, runtime_parachains::initializer, Initializer); - list_benchmark!(list, extra, runtime_parachains::paras_inherent, ParaInherent); - list_benchmark!(list, extra, runtime_parachains::paras, Paras); - - // Substrate - list_benchmark!(list, extra, pallet_bags_list, BagsList); - list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_election_provider_multi_phase, ElectionProviderMultiPhase); - list_benchmark!(list, extra, pallet_identity, Identity); - list_benchmark!(list, extra, pallet_im_online, ImOnline); - list_benchmark!(list, extra, pallet_indices, Indices); - list_benchmark!(list, extra, pallet_multisig, Multisig); - list_benchmark!(list, extra, pallet_offences, OffencesBench::); - list_benchmark!(list, extra, pallet_preimage, Preimage); - list_benchmark!(list, extra, pallet_proxy, Proxy); - list_benchmark!(list, extra, pallet_scheduler, Scheduler); - list_benchmark!(list, extra, pallet_session, SessionBench::); - list_benchmark!(list, extra, pallet_staking, Staking); - list_benchmark!(list, extra, frame_system, SystemBench::); - list_benchmark!(list, extra, pallet_timestamp, Timestamp); - list_benchmark!(list, extra, pallet_utility, Utility); - list_benchmark!(list, extra, pallet_vesting, Vesting); - - // XCM Benchmarks - // NOTE: Make sure you point to the individual modules below. - list_benchmark!(list, extra, pallet_xcm_benchmarks::fungible, XcmBalances); - list_benchmark!(list, extra, pallet_xcm_benchmarks::generic, XcmGeneric); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } @@ -1520,7 +1526,7 @@ sp_api::impl_runtime_apis! { Vec, sp_runtime::RuntimeString, > { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey, BenchmarkError}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, BenchmarkError}; // Trying to add benchmarks directly to some pallets caused cyclic dependency issues. // To get around that, we separated the benchmarks into its own crate. use pallet_session_benchmarking::Pallet as SessionBench; @@ -1623,42 +1629,7 @@ sp_api::impl_runtime_apis! { let mut batches = Vec::::new(); let params = (&config, &whitelist); - // Polkadot - // NOTE: Make sure to prefix these `runtime_common::` so that path resolves correctly - // in the generated file. - add_benchmark!(params, batches, runtime_common::auctions, Auctions); - add_benchmark!(params, batches, runtime_common::crowdloan, Crowdloan); - add_benchmark!(params, batches, runtime_common::paras_registrar, Registrar); - add_benchmark!(params, batches, runtime_common::slots, Slots); - add_benchmark!(params, batches, runtime_parachains::configuration, Configuration); - add_benchmark!(params, batches, runtime_parachains::hrmp, Hrmp); - add_benchmark!(params, batches, runtime_parachains::initializer, Initializer); - add_benchmark!(params, batches, runtime_parachains::paras, Paras); - add_benchmark!(params, batches, runtime_parachains::paras_inherent, ParaInherent); - - // Substrate - add_benchmark!(params, batches, pallet_bags_list, BagsList); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_election_provider_multi_phase, ElectionProviderMultiPhase); - add_benchmark!(params, batches, pallet_identity, Identity); - add_benchmark!(params, batches, pallet_im_online, ImOnline); - add_benchmark!(params, batches, pallet_indices, Indices); - add_benchmark!(params, batches, pallet_multisig, Multisig); - add_benchmark!(params, batches, pallet_offences, OffencesBench::); - add_benchmark!(params, batches, pallet_preimage, Preimage); - add_benchmark!(params, batches, pallet_proxy, Proxy); - add_benchmark!(params, batches, pallet_scheduler, Scheduler); - add_benchmark!(params, batches, pallet_session, SessionBench::); - add_benchmark!(params, batches, pallet_staking, Staking); - add_benchmark!(params, batches, frame_system, SystemBench::); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - add_benchmark!(params, batches, pallet_utility, Utility); - add_benchmark!(params, batches, pallet_vesting, Vesting); - - // XCM Benchmarks - // NOTE: Make sure you point to the individual modules below. - add_benchmark!(params, batches, pallet_xcm_benchmarks::fungible, XcmBalances); - add_benchmark!(params, batches, pallet_xcm_benchmarks::generic, XcmGeneric); + add_benchmarks!(params, batches); Ok(batches) }