diff --git a/primitives/src/v1/mod.rs b/primitives/src/v1/mod.rs index e32fb68f79db..40ca368fc6e9 100644 --- a/primitives/src/v1/mod.rs +++ b/primitives/src/v1/mod.rs @@ -237,6 +237,13 @@ pub const ASSIGNMENT_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"asgn"); /// * when detecting a code decompression bomb in the client pub const MAX_CODE_SIZE: u32 = 3 * 1024 * 1024; +/// Maximum head data size we support right now. +/// +/// Used for: +/// * initial genesis for the Parachains configuration +/// * checking updates to this stored runtime configuration do not exceed this limit +pub const MAX_HEAD_DATA_SIZE: u32 = 1 * 1024 * 1024; + /// Maximum PoV size we support right now. /// /// Used for: diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index c0e1615599e7..03d457b5c00b 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -165,6 +165,7 @@ impl shared::Config for Test {} impl paras::Config for Test { type Origin = Origin; type Event = Event; + type WeightInfo = paras::weights::WeightInfo; } parameter_types! { diff --git a/runtime/common/src/paras_registrar.rs b/runtime/common/src/paras_registrar.rs index ee595cd0df05..448bc5092403 100644 --- a/runtime/common/src/paras_registrar.rs +++ b/runtime/common/src/paras_registrar.rs @@ -657,6 +657,7 @@ mod tests { impl paras::Config for Test { type Origin = Origin; type Event = Event; + type WeightInfo = paras::weights::WeightInfo; } impl configuration::Config for Test { diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 86ef70dc9838..8c7b8e094904 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1149,6 +1149,7 @@ impl parachains_inclusion::Config for Runtime { impl parachains_paras::Config for Runtime { type Origin = Origin; type Event = Event; + type WeightInfo = weights::runtime_parachains_paras::WeightInfo; } parameter_types! { @@ -2050,6 +2051,7 @@ sp_api::impl_runtime_apis! { 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::paras, Paras); // Substrate list_benchmark!(list, extra, pallet_bags_list, BagsList); list_benchmark!(list, extra, pallet_balances, Balances); @@ -2125,6 +2127,7 @@ sp_api::impl_runtime_apis! { 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::paras, Paras); // 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 adb103ad4eee..0b944e458a90 100644 --- a/runtime/kusama/src/weights/mod.rs +++ b/runtime/kusama/src/weights/mod.rs @@ -45,3 +45,4 @@ pub mod runtime_common_crowdloan; pub mod runtime_common_paras_registrar; pub mod runtime_common_slots; pub mod runtime_parachains_configuration; +pub mod runtime_parachains_paras; diff --git a/runtime/kusama/src/weights/runtime_parachains_paras.rs b/runtime/kusama/src/weights/runtime_parachains_paras.rs new file mode 100644 index 000000000000..728d95561bfc --- /dev/null +++ b/runtime/kusama/src/weights/runtime_parachains_paras.rs @@ -0,0 +1,106 @@ +// 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::paras` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-09-21, 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::paras +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/runtime_parachains_paras.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::paras`. +pub struct WeightInfo(PhantomData); +impl runtime_parachains::paras::WeightInfo for WeightInfo { + // Storage: Paras CurrentCodeHash (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras PastCodeMeta (r:1 w:1) + // Storage: Paras PastCodePruning (r:1 w:1) + // Storage: Paras PastCodeHash (r:0 w:1) + // Storage: Paras CodeByHash (r:0 w:1) + fn force_set_current_code(c: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) + } + // Storage: Paras Heads (r:0 w:1) + fn force_set_current_head(s: u32, ) -> Weight { + (16_088_000 as Weight) + // Standard Error: 0 + .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Paras FutureCodeUpgrades (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: Paras UpgradeCooldowns (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras FutureCodeHash (r:0 w:1) + // Storage: Paras UpgradeRestrictionSignal (r:0 w:1) + fn force_schedule_code_upgrade(c: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(8 as Weight)) + } + // Storage: Paras FutureCodeUpgrades (r:1 w:1) + // Storage: Paras FutureCodeHash (r:1 w:1) + // Storage: Paras CurrentCodeHash (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras PastCodeMeta (r:1 w:1) + // Storage: Paras PastCodePruning (r:1 w:1) + // Storage: Paras Heads (r:0 w:1) + // Storage: Paras PastCodeHash (r:0 w:1) + // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) + fn force_note_new_head(s: u32, ) -> Weight { + (69_114_000 as Weight) + // Standard Error: 0 + .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(9 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras ActionsQueue (r:1 w:1) + fn force_queue_action() -> Weight { + (26_752_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index bcfc05e1a6c5..f2c94ef91532 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -22,7 +22,7 @@ use crate::shared; use frame_support::{pallet_prelude::*, weights::constants::WEIGHT_PER_MILLIS}; use frame_system::pallet_prelude::*; use parity_scale_codec::{Decode, Encode}; -use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_POV_SIZE}; +use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE}; use sp_runtime::traits::Zero; use sp_std::prelude::*; @@ -256,6 +256,13 @@ impl HostConfiguration { ) } + if self.max_head_data_size > MAX_HEAD_DATA_SIZE { + panic!( + "`max_head_data_size` ({}) is bigger than allowed by the client ({})", + self.max_head_data_size, MAX_HEAD_DATA_SIZE + ) + } + if self.max_pov_size > MAX_POV_SIZE { panic!("`max_pov_size` is bigger than allowed by the client") } @@ -390,6 +397,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::set_config_with_u32())] pub fn set_max_head_data_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; + ensure!(new <= MAX_HEAD_DATA_SIZE, Error::::InvalidNewValue); Self::update_config_member(|config| { sp_std::mem::replace(&mut config.max_head_data_size, new) != new }); diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index c4da0991de18..387e0a7bf5e8 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -123,6 +123,7 @@ impl crate::shared::Config for Test {} impl crate::paras::Config for Test { type Origin = Origin; type Event = Event; + type WeightInfo = crate::paras::weights::WeightInfo; } impl crate::dmp::Config for Test {} diff --git a/runtime/parachains/src/paras.rs b/runtime/parachains/src/paras.rs index 9a840837ae94..666012a3b4e3 100644 --- a/runtime/parachains/src/paras.rs +++ b/runtime/parachains/src/paras.rs @@ -41,6 +41,10 @@ use serde::{Deserialize, Serialize}; pub use crate::Origin as ParachainOrigin; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; +pub mod weights; + pub use pallet::*; // the two key times necessary to track for every code replacement. @@ -267,6 +271,14 @@ pub struct ParaGenesisArgs { pub parachain: bool, } +pub trait WeightInfo { + fn force_set_current_code(c: u32) -> Weight; + fn force_set_current_head(s: u32) -> Weight; + fn force_schedule_code_upgrade(c: u32) -> Weight; + fn force_note_new_head(s: u32) -> Weight; + fn force_queue_action() -> Weight; +} + #[frame_support::pallet] pub mod pallet { use super::*; @@ -283,6 +295,9 @@ pub mod pallet { + Into::Origin>>; type Event: From + IsType<::Event>; + + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; } #[pallet::event] @@ -490,7 +505,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Set the storage for the parachain validation code immediately. - #[pallet::weight(0)] + #[pallet::weight(::WeightInfo::force_set_current_code(new_code.0.len() as u32))] pub fn force_set_current_code( origin: OriginFor, para: ParaId, @@ -509,7 +524,7 @@ pub mod pallet { } /// Set the storage for the current parachain head data immediately. - #[pallet::weight(0)] + #[pallet::weight(::WeightInfo::force_set_current_head(new_head.0.len() as u32))] pub fn force_set_current_head( origin: OriginFor, para: ParaId, @@ -522,7 +537,7 @@ pub mod pallet { } /// Schedule an upgrade as if it was scheduled in the given relay parent block. - #[pallet::weight(0)] + #[pallet::weight(::WeightInfo::force_schedule_code_upgrade(new_code.0.len() as u32))] pub fn force_schedule_code_upgrade( origin: OriginFor, para: ParaId, @@ -537,7 +552,7 @@ pub mod pallet { } /// Note a new block head for para within the context of the current block. - #[pallet::weight(0)] + #[pallet::weight(::WeightInfo::force_note_new_head(new_head.0.len() as u32))] pub fn force_note_new_head( origin: OriginFor, para: ParaId, @@ -553,7 +568,7 @@ pub mod pallet { /// Put a parachain directly into the next session's action queue. /// We can't queue it any sooner than this without going into the /// initializer... - #[pallet::weight(0)] + #[pallet::weight(::WeightInfo::force_queue_action())] pub fn force_queue_action(origin: OriginFor, para: ParaId) -> DispatchResult { ensure_root(origin)?; let next_session = shared::Pallet::::session_index().saturating_add(One::one()); diff --git a/runtime/parachains/src/paras/benchmarking.rs b/runtime/parachains/src/paras/benchmarking.rs new file mode 100644 index 000000000000..2e9a26c260a3 --- /dev/null +++ b/runtime/parachains/src/paras/benchmarking.rs @@ -0,0 +1,135 @@ +// Copyright 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 . + +use super::*; +use crate::{configuration::HostConfiguration, shared}; +use frame_benchmarking::{benchmarks, impl_benchmark_test_suite}; +use frame_system::RawOrigin; +use primitives::v1::{HeadData, Id as ParaId, ValidationCode, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE}; +use sp_runtime::traits::{One, Saturating}; + +// 2 ^ 10, because binary search time complexity is O(log(2, n)) and n = 1024 gives us a big and +// round number. +// Due to the limited number of parachains, the number of pruning, upcoming upgrades and cooldowns +// shouldn't exceed this number. +const SAMPLE_SIZE: u32 = 1024; + +fn assert_last_event(generic_event: ::Event) { + let events = frame_system::Pallet::::events(); + let system_event: ::Event = generic_event.into(); + // compare to the last event record + let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; + assert_eq!(event, &system_event); +} + +fn generate_disordered_pruning() { + let mut needs_pruning = Vec::new(); + + for i in 0..SAMPLE_SIZE { + let id = ParaId::from(i); + let block_number = T::BlockNumber::from(1000u32); + needs_pruning.push((id, block_number)); + } + + as Store>::PastCodePruning::put(needs_pruning); +} + +fn generate_disordered_upgrades() { + let mut upgrades = Vec::new(); + let mut cooldowns = Vec::new(); + + for i in 0..SAMPLE_SIZE { + let id = ParaId::from(i); + let block_number = T::BlockNumber::from(1000u32); + upgrades.push((id, block_number)); + cooldowns.push((id, block_number)); + } + + as Store>::UpcomingUpgrades::put(upgrades); + as Store>::UpgradeCooldowns::put(cooldowns); +} + +fn generate_disordered_actions_queue() { + let mut queue = Vec::new(); + let next_session = shared::Pallet::::session_index().saturating_add(One::one()); + + for _ in 0..SAMPLE_SIZE { + let id = ParaId::from(1000); + queue.push(id); + } + + as Store>::ActionsQueue::mutate(next_session, |v| { + *v = queue; + }); +} + +benchmarks! { + force_set_current_code { + let c in 1 .. MAX_CODE_SIZE; + let new_code = ValidationCode(vec![0; c as usize]); + let para_id = ParaId::from(c as u32); + generate_disordered_pruning::(); + }: _(RawOrigin::Root, para_id, new_code) + verify { + assert_last_event::(Event::CurrentCodeUpdated(para_id).into()); + } + force_set_current_head { + let s in 1 .. MAX_HEAD_DATA_SIZE; + let new_head = HeadData(vec![0; s as usize]); + let para_id = ParaId::from(1000); + }: _(RawOrigin::Root, para_id, new_head) + verify { + assert_last_event::(Event::CurrentHeadUpdated(para_id).into()); + } + force_schedule_code_upgrade { + let c in 1 .. MAX_CODE_SIZE; + let new_code = ValidationCode(vec![0; c as usize]); + let para_id = ParaId::from(c as u32); + let block = T::BlockNumber::from(c); + generate_disordered_upgrades::(); + }: _(RawOrigin::Root, para_id, new_code, block) + verify { + assert_last_event::(Event::CodeUpgradeScheduled(para_id).into()); + } + force_note_new_head { + let s in 1 .. MAX_HEAD_DATA_SIZE; + let para_id = ParaId::from(1000); + let new_head = HeadData(vec![0; s as usize]); + // schedule an expired code upgrade for this para_id so that force_note_new_head would use + // the worst possible code path + let expired = frame_system::Pallet::::block_number().saturating_sub(One::one()); + let config = HostConfiguration::::default(); + generate_disordered_pruning::(); + Pallet::::schedule_code_upgrade(para_id, ValidationCode(vec![0]), expired, &config); + }: _(RawOrigin::Root, para_id, new_head) + verify { + assert_last_event::(Event::NewHeadNoted(para_id).into()); + } + force_queue_action { + let para_id = ParaId::from(1000); + generate_disordered_actions_queue::(); + }: _(RawOrigin::Root, para_id) + verify { + let next_session = crate::shared::Pallet::::session_index().saturating_add(One::one()); + assert_last_event::(Event::ActionQueued(para_id, next_session).into()); + } +} + +impl_benchmark_test_suite!( + Pallet, + crate::mock::new_test_ext(Default::default()), + crate::mock::Test +); diff --git a/runtime/parachains/src/paras/weights.rs b/runtime/parachains/src/paras/weights.rs new file mode 100644 index 000000000000..d02acf4bc687 --- /dev/null +++ b/runtime/parachains/src/paras/weights.rs @@ -0,0 +1,97 @@ + +//! Autogenerated weights for `runtime_parachains::paras` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-09-21, 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::paras +// --steps +// 50 +// --repeat +// 20 +// --raw +// --extrinsic +// * +// --output +// runtime/parachains/src/paras/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::paras`. +pub struct WeightInfo(PhantomData); +impl super::WeightInfo for WeightInfo { + // Storage: Paras CurrentCodeHash (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras PastCodeMeta (r:1 w:1) + // Storage: Paras PastCodePruning (r:1 w:1) + // Storage: Paras PastCodeHash (r:0 w:1) + // Storage: Paras CodeByHash (r:0 w:1) + fn force_set_current_code(c: u32, ) -> Weight { + (14_669_000 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) + } + // Storage: Paras Heads (r:0 w:1) + fn force_set_current_head(s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Paras FutureCodeUpgrades (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: Paras UpgradeCooldowns (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras FutureCodeHash (r:0 w:1) + // Storage: Paras UpgradeRestrictionSignal (r:0 w:1) + fn force_schedule_code_upgrade(c: u32, ) -> Weight { + (37_383_000 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(8 as Weight)) + } + // Storage: Paras FutureCodeUpgrades (r:1 w:1) + // Storage: Paras FutureCodeHash (r:1 w:1) + // Storage: Paras CurrentCodeHash (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras PastCodeMeta (r:1 w:1) + // Storage: Paras PastCodePruning (r:1 w:1) + // Storage: Paras Heads (r:0 w:1) + // Storage: Paras PastCodeHash (r:0 w:1) + // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) + fn force_note_new_head(s: u32, ) -> Weight { + (60_855_000 as Weight) + // Standard Error: 0 + .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(9 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras ActionsQueue (r:1 w:1) + fn force_queue_action() -> Weight { + (32_014_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index b86314c50b9f..d9e42a75ec16 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -588,6 +588,7 @@ impl parachains_inclusion::Config for Runtime { impl parachains_paras::Config for Runtime { type Origin = Origin; type Event = Event; + type WeightInfo = parachains_paras::weights::WeightInfo; } parameter_types! { diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 58ccea45c249..9ead46d3cf81 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -484,6 +484,7 @@ impl parachains_session_info::Config for Runtime {} impl parachains_paras::Config for Runtime { type Origin = Origin; type Event = Event; + type WeightInfo = parachains_paras::weights::WeightInfo; } impl parachains_dmp::Config for Runtime {} diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 31b9342dc66b..a583d5618135 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -818,6 +818,7 @@ impl parachains_inclusion::Config for Runtime { impl parachains_paras::Config for Runtime { type Origin = Origin; type Event = Event; + type WeightInfo = weights::runtime_parachains_paras::WeightInfo; } parameter_types! { @@ -1474,6 +1475,7 @@ sp_api::impl_runtime_apis! { 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::paras, Paras); // Substrate list_benchmark!(list, extra, pallet_bags_list, BagsList); list_benchmark!(list, extra, pallet_balances, Balances); @@ -1540,6 +1542,7 @@ sp_api::impl_runtime_apis! { 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::paras, Paras); // 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 76e23ae5fb49..c7dba930ed49 100644 --- a/runtime/westend/src/weights/mod.rs +++ b/runtime/westend/src/weights/mod.rs @@ -35,3 +35,4 @@ pub mod runtime_common_crowdloan; pub mod runtime_common_paras_registrar; pub mod runtime_common_slots; pub mod runtime_parachains_configuration; +pub mod runtime_parachains_paras; diff --git a/runtime/westend/src/weights/runtime_parachains_paras.rs b/runtime/westend/src/weights/runtime_parachains_paras.rs new file mode 100644 index 000000000000..f04f3162a263 --- /dev/null +++ b/runtime/westend/src/weights/runtime_parachains_paras.rs @@ -0,0 +1,106 @@ +// 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::paras` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-09-21, 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::paras +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/westend/src/weights/runtime_parachains_paras.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::paras`. +pub struct WeightInfo(PhantomData); +impl runtime_parachains::paras::WeightInfo for WeightInfo { + // Storage: Paras CurrentCodeHash (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras PastCodeMeta (r:1 w:1) + // Storage: Paras PastCodePruning (r:1 w:1) + // Storage: Paras PastCodeHash (r:0 w:1) + // Storage: Paras CodeByHash (r:0 w:1) + fn force_set_current_code(c: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) + } + // Storage: Paras Heads (r:0 w:1) + fn force_set_current_head(s: u32, ) -> Weight { + (17_522_000 as Weight) + // Standard Error: 0 + .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Paras FutureCodeUpgrades (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: Paras UpgradeCooldowns (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras FutureCodeHash (r:0 w:1) + // Storage: Paras UpgradeRestrictionSignal (r:0 w:1) + fn force_schedule_code_upgrade(c: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(8 as Weight)) + } + // Storage: Paras FutureCodeUpgrades (r:1 w:1) + // Storage: Paras FutureCodeHash (r:1 w:1) + // Storage: Paras CurrentCodeHash (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras PastCodeMeta (r:1 w:1) + // Storage: Paras PastCodePruning (r:1 w:1) + // Storage: Paras Heads (r:0 w:1) + // Storage: Paras PastCodeHash (r:0 w:1) + // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) + fn force_note_new_head(s: u32, ) -> Weight { + (71_155_000 as Weight) + // Standard Error: 0 + .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(9 as Weight)) + } + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras ActionsQueue (r:1 w:1) + fn force_queue_action() -> Weight { + (27_230_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +}