diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index 50a1e9efaaac..c0e1615599e7 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -156,7 +156,9 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; } -impl configuration::Config for Test {} +impl configuration::Config for Test { + type WeightInfo = configuration::weights::WeightInfo; +} impl shared::Config for Test {} diff --git a/runtime/common/src/paras_registrar.rs b/runtime/common/src/paras_registrar.rs index 5f444bcffc0f..ee595cd0df05 100644 --- a/runtime/common/src/paras_registrar.rs +++ b/runtime/common/src/paras_registrar.rs @@ -213,7 +213,7 @@ pub mod pallet { /// /// ## Events /// The `Registered` event is emitted in case of success. - #[pallet::weight(T::WeightInfo::register())] + #[pallet::weight(::WeightInfo::register())] pub fn register( origin: OriginFor, id: ParaId, @@ -231,7 +231,7 @@ pub mod pallet { /// /// The deposit taken can be specified for this registration. Any `ParaId` /// can be registered, including sub-1000 IDs which are System Parachains. - #[pallet::weight(T::WeightInfo::force_register())] + #[pallet::weight(::WeightInfo::force_register())] pub fn force_register( origin: OriginFor, who: T::AccountId, @@ -247,7 +247,7 @@ pub mod pallet { /// Deregister a Para Id, freeing all data and returning any deposit. /// /// The caller must be Root, the `para` owner, or the `para` itself. The para must be a parathread. - #[pallet::weight(T::WeightInfo::deregister())] + #[pallet::weight(::WeightInfo::deregister())] pub fn deregister(origin: OriginFor, id: ParaId) -> DispatchResult { Self::ensure_root_para_or_owner(origin, id)?; Self::do_deregister(id) @@ -264,7 +264,7 @@ pub mod pallet { /// `ParaId` to be a long-term identifier of a notional "parachain". However, their /// scheduling info (i.e. whether they're a parathread or parachain), auction information /// and the auction deposit are switched. - #[pallet::weight(T::WeightInfo::swap())] + #[pallet::weight(::WeightInfo::swap())] pub fn swap(origin: OriginFor, id: ParaId, other: ParaId) -> DispatchResult { Self::ensure_root_para_or_owner(origin, id)?; @@ -325,7 +325,7 @@ pub mod pallet { /// /// ## Events /// The `Reserved` event is emitted in case of success, which provides the ID reserved for use. - #[pallet::weight(T::WeightInfo::reserve())] + #[pallet::weight(::WeightInfo::reserve())] pub fn reserve(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; let id = NextFreeParaId::::get().max(LOWEST_PUBLIC_ID); @@ -659,7 +659,9 @@ mod tests { type Event = Event; } - impl configuration::Config for Test {} + impl configuration::Config for Test { + type WeightInfo = configuration::weights::WeightInfo; + } parameter_types! { pub const ParaDeposit: Balance = 10; diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index cd6f3fc2e277..78e910f01f01 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1126,7 +1126,9 @@ impl pallet_proxy::Config for Runtime { impl parachains_origin::Config for Runtime {} -impl parachains_configuration::Config for Runtime {} +impl parachains_configuration::Config for Runtime { + type WeightInfo = weights::runtime_parachains_configuration::WeightInfo; +} impl parachains_shared::Config for Runtime {} @@ -2000,6 +2002,7 @@ sp_api::impl_runtime_apis! { 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); // Substrate list_benchmark!(list, extra, pallet_bags_list, BagsList); list_benchmark!(list, extra, pallet_balances, Balances); @@ -2074,6 +2077,7 @@ sp_api::impl_runtime_apis! { 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); // Substrate add_benchmark!(params, batches, pallet_balances, Balances); add_benchmark!(params, batches, pallet_bags_list, BagsList); diff --git a/runtime/kusama/src/weights/mod.rs b/runtime/kusama/src/weights/mod.rs index 35273e1c98a0..adb103ad4eee 100644 --- a/runtime/kusama/src/weights/mod.rs +++ b/runtime/kusama/src/weights/mod.rs @@ -44,3 +44,4 @@ pub mod runtime_common_claims; pub mod runtime_common_crowdloan; pub mod runtime_common_paras_registrar; pub mod runtime_common_slots; +pub mod runtime_parachains_configuration; diff --git a/runtime/kusama/src/weights/runtime_parachains_configuration.rs b/runtime/kusama/src/weights/runtime_parachains_configuration.rs new file mode 100644 index 000000000000..ae840f37752d --- /dev/null +++ b/runtime/kusama/src/weights/runtime_parachains_configuration.rs @@ -0,0 +1,91 @@ +// Copyright 2017-2021 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . +//! Autogenerated weights for `runtime_parachains::configuration` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-09-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128 + +// Executed Command: +// target/release/polkadot +// benchmark +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=runtime_parachains::configuration +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/runtime_parachains_configuration.rs + + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `runtime_parachains::configuration`. +pub struct WeightInfo(PhantomData); +impl runtime_parachains::configuration::WeightInfo for WeightInfo { + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_block_number() -> Weight { + (12_378_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_u32() -> Weight { + (12_384_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_option_u32() -> Weight { + (12_746_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_weight() -> Weight { + (12_563_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Benchmark Override (r:0 w:0) + fn set_hrmp_open_request_ttl() -> Weight { + (2_000_000_000_000 as Weight) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_balance() -> Weight { + (12_644_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/runtime/parachains/Cargo.toml b/runtime/parachains/Cargo.toml index 8e3b41d95e6b..3b75b95619fe 100644 --- a/runtime/parachains/Cargo.toml +++ b/runtime/parachains/Cargo.toml @@ -28,12 +28,12 @@ pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } xcm = { package = "xcm", path = "../../xcm", default-features = false } xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", default-features = false } diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index 64aaac6b3487..bcfc05e1a6c5 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -26,6 +26,10 @@ use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_POV_SIZE}; use sp_runtime::traits::Zero; use sp_std::prelude::*; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; +pub mod weights; + pub use pallet::*; pub mod migration; @@ -258,6 +262,15 @@ impl HostConfiguration { } } +pub trait WeightInfo { + fn set_config_with_block_number() -> Weight; + fn set_config_with_u32() -> Weight; + fn set_config_with_option_u32() -> Weight; + fn set_config_with_weight() -> Weight; + fn set_config_with_balance() -> Weight; + fn set_hrmp_open_request_ttl() -> Weight; +} + #[frame_support::pallet] pub mod pallet { use super::*; @@ -268,7 +281,10 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + shared::Config {} + pub trait Config: frame_system::Config + shared::Config { + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; + } #[pallet::error] pub enum Error { @@ -310,7 +326,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Set the validation upgrade frequency. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_block_number())] pub fn set_validation_upgrade_frequency( origin: OriginFor, new: T::BlockNumber, @@ -323,7 +339,7 @@ pub mod pallet { } /// Set the validation upgrade delay. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_block_number())] pub fn set_validation_upgrade_delay( origin: OriginFor, new: T::BlockNumber, @@ -336,7 +352,7 @@ pub mod pallet { } /// Set the acceptance period for an included candidate. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_block_number())] pub fn set_code_retention_period( origin: OriginFor, new: T::BlockNumber, @@ -349,7 +365,7 @@ pub mod pallet { } /// Set the max validation code size for incoming upgrades. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_max_code_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; ensure!(new <= MAX_CODE_SIZE, Error::::InvalidNewValue); @@ -360,7 +376,7 @@ pub mod pallet { } /// Set the max POV block size for incoming upgrades. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_max_pov_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; ensure!(new <= MAX_POV_SIZE, Error::::InvalidNewValue); @@ -371,7 +387,7 @@ pub mod pallet { } /// Set the max head data size for paras. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_max_head_data_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -381,7 +397,7 @@ pub mod pallet { } /// Set the number of parathread execution cores. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_parathread_cores(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -391,7 +407,7 @@ pub mod pallet { } /// Set the number of retries for a particular parathread. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_parathread_retries(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -401,7 +417,7 @@ pub mod pallet { } /// Set the parachain validator-group rotation frequency - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_block_number())] pub fn set_group_rotation_frequency( origin: OriginFor, new: T::BlockNumber, @@ -417,7 +433,7 @@ pub mod pallet { } /// Set the availability period for parachains. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_block_number())] pub fn set_chain_availability_period( origin: OriginFor, new: T::BlockNumber, @@ -433,7 +449,7 @@ pub mod pallet { } /// Set the availability period for parathreads. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_block_number())] pub fn set_thread_availability_period( origin: OriginFor, new: T::BlockNumber, @@ -449,7 +465,7 @@ pub mod pallet { } /// Set the scheduling lookahead, in expected number of blocks at peak throughput. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_scheduling_lookahead(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -459,7 +475,7 @@ pub mod pallet { } /// Set the maximum number of validators to assign to any core. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_option_u32())] pub fn set_max_validators_per_core( origin: OriginFor, new: Option, @@ -472,7 +488,7 @@ pub mod pallet { } /// Set the maximum number of validators to use in parachain consensus. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_option_u32())] pub fn set_max_validators(origin: OriginFor, new: Option) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -482,7 +498,7 @@ pub mod pallet { } /// Set the dispute period, in number of sessions to keep for disputes. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_dispute_period(origin: OriginFor, new: SessionIndex) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -492,7 +508,7 @@ pub mod pallet { } /// Set the dispute post conclusion acceptance period. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_block_number())] pub fn set_dispute_post_conclusion_acceptance_period( origin: OriginFor, new: T::BlockNumber, @@ -506,7 +522,7 @@ pub mod pallet { } /// Set the maximum number of dispute spam slots. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_dispute_max_spam_slots(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -516,7 +532,7 @@ pub mod pallet { } /// Set the dispute conclusion by time out period. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_block_number())] pub fn set_dispute_conclusion_by_time_out_period( origin: OriginFor, new: T::BlockNumber, @@ -530,7 +546,7 @@ pub mod pallet { /// Set the no show slots, in number of number of consensus slots. /// Must be at least 1. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_no_show_slots(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; @@ -543,7 +559,7 @@ pub mod pallet { } /// Set the total number of delay tranches. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_n_delay_tranches(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -553,7 +569,7 @@ pub mod pallet { } /// Set the zeroth delay tranche width. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_zeroth_delay_tranche_width(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -563,7 +579,7 @@ pub mod pallet { } /// Set the number of validators needed to approve a block. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_needed_approvals(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -573,7 +589,7 @@ pub mod pallet { } /// Set the number of samples to do of the `RelayVRFModulo` approval assignment criterion. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_relay_vrf_modulo_samples(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -583,7 +599,7 @@ pub mod pallet { } /// Sets the maximum items that can present in a upward dispatch queue at once. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_max_upward_queue_count(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -593,7 +609,7 @@ pub mod pallet { } /// Sets the maximum total size of items that can present in a upward dispatch queue at once. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_max_upward_queue_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -603,7 +619,7 @@ pub mod pallet { } /// Set the critical downward message size. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_max_downward_message_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -613,7 +629,7 @@ pub mod pallet { } /// Sets the soft limit for the phase of dispatching dispatchable upward messages. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_weight())] pub fn set_ump_service_total_weight(origin: OriginFor, new: Weight) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -623,7 +639,7 @@ pub mod pallet { } /// Sets the maximum size of an upward message that can be sent by a candidate. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_max_upward_message_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -633,7 +649,7 @@ pub mod pallet { } /// Sets the maximum number of messages that a candidate can contain. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_max_upward_message_num_per_candidate( origin: OriginFor, new: u32, @@ -646,7 +662,7 @@ pub mod pallet { } /// Sets the number of sessions after which an HRMP open channel request expires. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_hrmp_open_request_ttl())] // Deprecated, but is not marked as such, because that would trigger warnings coming from // the macro. pub fn set_hrmp_open_request_ttl(_origin: OriginFor, _new: u32) -> DispatchResult { @@ -654,7 +670,7 @@ pub mod pallet { } /// Sets the amount of funds that the sender should provide for opening an HRMP channel. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_balance())] pub fn set_hrmp_sender_deposit(origin: OriginFor, new: Balance) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -665,7 +681,7 @@ pub mod pallet { /// Sets the amount of funds that the recipient should provide for accepting opening an HRMP /// channel. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_balance())] pub fn set_hrmp_recipient_deposit(origin: OriginFor, new: Balance) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -675,7 +691,7 @@ pub mod pallet { } /// Sets the maximum number of messages allowed in an HRMP channel at once. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_hrmp_channel_max_capacity(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -685,7 +701,7 @@ pub mod pallet { } /// Sets the maximum total size of messages in bytes allowed in an HRMP channel at once. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_hrmp_channel_max_total_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -695,7 +711,7 @@ pub mod pallet { } /// Sets the maximum number of inbound HRMP channels a parachain is allowed to accept. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_hrmp_max_parachain_inbound_channels( origin: OriginFor, new: u32, @@ -708,7 +724,7 @@ pub mod pallet { } /// Sets the maximum number of inbound HRMP channels a parathread is allowed to accept. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_hrmp_max_parathread_inbound_channels( origin: OriginFor, new: u32, @@ -721,7 +737,7 @@ pub mod pallet { } /// Sets the maximum size of a message that could ever be put into an HRMP channel. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_hrmp_channel_max_message_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { @@ -731,7 +747,7 @@ pub mod pallet { } /// Sets the maximum number of outbound HRMP channels a parachain is allowed to open. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_hrmp_max_parachain_outbound_channels( origin: OriginFor, new: u32, @@ -744,7 +760,7 @@ pub mod pallet { } /// Sets the maximum number of outbound HRMP channels a parathread is allowed to open. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_hrmp_max_parathread_outbound_channels( origin: OriginFor, new: u32, @@ -757,7 +773,7 @@ pub mod pallet { } /// Sets the maximum number of outbound HRMP messages can be sent by a candidate. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_hrmp_max_message_num_per_candidate( origin: OriginFor, new: u32, @@ -770,7 +786,7 @@ pub mod pallet { } /// Sets the maximum amount of weight any individual upward message may consume. - #[pallet::weight((1_000, DispatchClass::Operational))] + #[pallet::weight(T::WeightInfo::set_config_with_weight())] pub fn set_ump_max_individual_weight(origin: OriginFor, new: Weight) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { diff --git a/runtime/parachains/src/configuration/benchmarking.rs b/runtime/parachains/src/configuration/benchmarking.rs new file mode 100644 index 000000000000..8b319cb8fabb --- /dev/null +++ b/runtime/parachains/src/configuration/benchmarking.rs @@ -0,0 +1,44 @@ +// Copyright 2020 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +use crate::configuration::*; +use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, BenchmarkError, BenchmarkResult}; +use frame_system::RawOrigin; +use sp_runtime::traits::One; + +benchmarks! { + set_config_with_block_number {}: set_code_retention_period(RawOrigin::Root, One::one()) + + set_config_with_u32 {}: set_max_code_size(RawOrigin::Root, 100) + + set_config_with_option_u32 {}: set_max_validators(RawOrigin::Root, Some(10)) + + set_config_with_weight {}: set_ump_service_total_weight(RawOrigin::Root, 3_000_000) + + set_hrmp_open_request_ttl {}: { + Err(BenchmarkError::Override( + BenchmarkResult::from_weight(T::BlockWeights::get().max_block) + ))?; + } + + set_config_with_balance {}: set_hrmp_sender_deposit(RawOrigin::Root, 100_000_000_000) +} + +impl_benchmark_test_suite!( + Pallet, + crate::mock::new_test_ext(Default::default()), + crate::mock::Test +); diff --git a/runtime/parachains/src/configuration/weights.rs b/runtime/parachains/src/configuration/weights.rs new file mode 100644 index 000000000000..da70d6cb29d1 --- /dev/null +++ b/runtime/parachains/src/configuration/weights.rs @@ -0,0 +1,82 @@ + +//! Autogenerated weights for `runtime_parachains::configuration` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-09-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 + +// Executed Command: +// ./target/release/polkadot +// benchmark +// --chain +// westend-dev +// --execution=wasm +// --wasm-execution=compiled +// --pallet +// runtime_parachains::configuration +// --steps +// 50 +// --repeat +// 20 +// --raw +// --extrinsic +// * +// --output +// runtime/parachains/src/configuration/weights.rs + + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `runtime_parachains::configuration`. +pub struct WeightInfo(PhantomData); +impl super::WeightInfo for WeightInfo { + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_block_number() -> Weight { + (16_730_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_u32() -> Weight { + (16_592_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_option_u32() -> Weight { + (16_419_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_weight() -> Weight { + (16_732_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Benchmark Override (r:0 w:0) + fn set_hrmp_open_request_ttl() -> Weight { + (2_000_000_000_000 as Weight) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_balance() -> Weight { + (16_752_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/runtime/parachains/src/lib.rs b/runtime/parachains/src/lib.rs index 1ea90bb84e63..ab48d693d601 100644 --- a/runtime/parachains/src/lib.rs +++ b/runtime/parachains/src/lib.rs @@ -20,6 +20,7 @@ //! particular the `Initializer` module, as it is responsible for initializing the state //! of the other modules. +#![cfg_attr(feature = "runtime-benchmarks", recursion_limit = "256")] #![cfg_attr(not(feature = "std"), no_std)] pub mod configuration; diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 5cf8d6237485..c4da0991de18 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -114,7 +114,9 @@ impl crate::initializer::Config for Test { type ForceOrigin = frame_system::EnsureRoot; } -impl crate::configuration::Config for Test {} +impl crate::configuration::Config for Test { + type WeightInfo = crate::configuration::weights::WeightInfo; +} impl crate::shared::Config for Test {} diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index cbedecf056ee..182c8f953cc0 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -560,7 +560,9 @@ impl pallet_authorship::Config for Runtime { impl parachains_origin::Config for Runtime {} -impl parachains_configuration::Config for Runtime {} +impl parachains_configuration::Config for Runtime { + type WeightInfo = parachains_configuration::weights::WeightInfo; +} impl parachains_shared::Config for Runtime {} diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index a1fe03cb37f6..58ccea45c249 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -454,7 +454,9 @@ impl pallet_sudo::Config for Runtime { type Call = Call; } -impl parachains_configuration::Config for Runtime {} +impl parachains_configuration::Config for Runtime { + type WeightInfo = parachains_configuration::weights::WeightInfo; +} impl parachains_shared::Config for Runtime {} diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 09baa14a691b..e7587856ecda 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -795,7 +795,9 @@ impl pallet_proxy::Config for Runtime { impl parachains_origin::Config for Runtime {} -impl parachains_configuration::Config for Runtime {} +impl parachains_configuration::Config for Runtime { + type WeightInfo = parachains_configuration::weights::WeightInfo; +} impl parachains_shared::Config for Runtime {} @@ -1462,6 +1464,7 @@ sp_api::impl_runtime_apis! { 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); // Substrate list_benchmark!(list, extra, pallet_bags_list, BagsList); list_benchmark!(list, extra, pallet_balances, Balances); @@ -1527,6 +1530,7 @@ sp_api::impl_runtime_apis! { 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); // Substrate add_benchmark!(params, batches, pallet_bags_list, BagsList); add_benchmark!(params, batches, pallet_balances, Balances); diff --git a/runtime/westend/src/weights/mod.rs b/runtime/westend/src/weights/mod.rs index 05fefbef7d71..76e23ae5fb49 100644 --- a/runtime/westend/src/weights/mod.rs +++ b/runtime/westend/src/weights/mod.rs @@ -34,3 +34,4 @@ pub mod runtime_common_auctions; pub mod runtime_common_crowdloan; pub mod runtime_common_paras_registrar; pub mod runtime_common_slots; +pub mod runtime_parachains_configuration; diff --git a/runtime/westend/src/weights/runtime_parachains_configuration.rs b/runtime/westend/src/weights/runtime_parachains_configuration.rs new file mode 100644 index 000000000000..6c1753e7c3b3 --- /dev/null +++ b/runtime/westend/src/weights/runtime_parachains_configuration.rs @@ -0,0 +1,91 @@ +// Copyright 2017-2021 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . +//! Autogenerated weights for `runtime_parachains::configuration` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-09-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 + +// Executed Command: +// target/release/polkadot +// benchmark +// --chain=westend-dev +// --steps=50 +// --repeat=20 +// --pallet=runtime_parachains::configuration +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/westend/src/weights/runtime_parachains_configuration.rs + + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `runtime_parachains::configuration`. +pub struct WeightInfo(PhantomData); +impl runtime_parachains::configuration::WeightInfo for WeightInfo { + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_block_number() -> Weight { + (12_795_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_u32() -> Weight { + (12_758_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_option_u32() -> Weight { + (12_861_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_weight() -> Weight { + (12_854_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Benchmark Override (r:0 w:0) + fn set_hrmp_open_request_ttl() -> Weight { + (2_000_000_000_000 as Weight) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + fn set_config_with_balance() -> Weight { + (12_838_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index ee5c77afe587..bcdac942a30a 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -107,7 +107,9 @@ impl pallet_balances::Config for Runtime { impl shared::Config for Runtime {} -impl configuration::Config for Runtime {} +impl configuration::Config for Runtime { + type WeightInfo = configuration::weights::WeightInfo; +} // aims to closely emulate the Kusama XcmConfig parameter_types! { diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index a6f6f1989174..cc50aec90d18 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -88,7 +88,9 @@ impl pallet_balances::Config for Runtime { impl shared::Config for Runtime {} -impl configuration::Config for Runtime {} +impl configuration::Config for Runtime { + type WeightInfo = configuration::weights::WeightInfo; +} parameter_types! { pub const KsmLocation: MultiLocation = Here.into();