Add benchmarking for parachain runtime configuration pallet (#3862)

* Add benchmarking for parachain runtime configuration pallet

* cargo fmt

* Add WeightInfo trait

* Specify missing WeightInfo associated type in mocks

* Fix typo

* cargo run --quiet --release --features=runtime-benchmarks -- 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

* Fix compilation errors

* cargo run --quiet --release --features=runtime-benchmarks -- 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

* Condense the number of WeightInfo methods

* Fixes

* cargo run --quiet --release --features=runtime-benchmarks -- 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

* Make use of weights generated from kusama benchmarking

* Use a better dispatch function for weighing set_config_with_block_number

* cargo run --quiet --release --features=runtime-benchmarks -- 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

* cargo run --quiet --release --features=runtime-benchmarks -- 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

Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Keith Yeung
2021-09-18 02:57:50 -07:00
committed by GitHub
parent aca0b2429d
commit 706f142516
18 changed files with 407 additions and 58 deletions
@@ -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<Test>;
}
impl shared::Config for Test {}
@@ -213,7 +213,7 @@ pub mod pallet {
///
/// ## Events
/// The `Registered` event is emitted in case of success.
#[pallet::weight(T::WeightInfo::register())]
#[pallet::weight(<T as Config>::WeightInfo::register())]
pub fn register(
origin: OriginFor<T>,
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(<T as Config>::WeightInfo::force_register())]
pub fn force_register(
origin: OriginFor<T>,
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(<T as Config>::WeightInfo::deregister())]
pub fn deregister(origin: OriginFor<T>, 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(<T as Config>::WeightInfo::swap())]
pub fn swap(origin: OriginFor<T>, 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(<T as Config>::WeightInfo::reserve())]
pub fn reserve(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let id = NextFreeParaId::<T>::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<Test>;
}
parameter_types! {
pub const ParaDeposit: Balance = 10;
+5 -1
View File
@@ -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<Runtime>;
}
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);
@@ -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;
@@ -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 <http://www.gnu.org/licenses/>.
//! 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<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for WeightInfo<T> {
// 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))
}
}
+2 -2
View File
@@ -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 }
@@ -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<BlockNumber: Zero> HostConfiguration<BlockNumber> {
}
}
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<T>(_);
#[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<T> {
@@ -310,7 +326,7 @@ pub mod pallet {
#[pallet::call]
impl<T: Config> Pallet<T> {
/// 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<T>,
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<T>,
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<T>,
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<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
ensure!(new <= MAX_CODE_SIZE, Error::<T>::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<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
ensure!(new <= MAX_POV_SIZE, Error::<T>::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<T>, 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<T>, 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<T>, 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<T>,
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<T>,
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<T>,
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<T>, 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<T>,
new: Option<u32>,
@@ -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<T>, new: Option<u32>) -> 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<T>, 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<T>,
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<T>, 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<T>,
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<T>, 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<T>, 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<T>, 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<T>, 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<T>, 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<T>, 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<T>, 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<T>, 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<T>, 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<T>, 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<T>,
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<T>, _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<T>, 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<T>, 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<T>, 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<T>, 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<T>,
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<T>,
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<T>, 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<T>,
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<T>,
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<T>,
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<T>, new: Weight) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
@@ -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 <http://www.gnu.org/licenses/>.
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
);
@@ -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<T>(PhantomData<T>);
impl<T: frame_system::Config> super::WeightInfo for WeightInfo<T> {
// 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))
}
}
+1
View File
@@ -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;
+3 -1
View File
@@ -114,7 +114,9 @@ impl crate::initializer::Config for Test {
type ForceOrigin = frame_system::EnsureRoot<u64>;
}
impl crate::configuration::Config for Test {}
impl crate::configuration::Config for Test {
type WeightInfo = crate::configuration::weights::WeightInfo<Test>;
}
impl crate::shared::Config for Test {}
+3 -1
View File
@@ -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<Runtime>;
}
impl parachains_shared::Config for Runtime {}
+3 -1
View File
@@ -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<Runtime>;
}
impl parachains_shared::Config for Runtime {}
+5 -1
View File
@@ -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<Runtime>;
}
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);
@@ -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;
@@ -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 <http://www.gnu.org/licenses/>.
//! 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<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for WeightInfo<T> {
// 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))
}
}
+3 -1
View File
@@ -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<Runtime>;
}
// aims to closely emulate the Kusama XcmConfig
parameter_types! {
@@ -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<Runtime>;
}
parameter_types! {
pub const KsmLocation: MultiLocation = Here.into();