diff --git a/polkadot/bridges/bin/rialto/node/src/chain_spec.rs b/polkadot/bridges/bin/rialto/node/src/chain_spec.rs index a0d3512b40..5c7b79e241 100644 --- a/polkadot/bridges/bin/rialto/node/src/chain_spec.rs +++ b/polkadot/bridges/bin/rialto/node/src/chain_spec.rs @@ -265,7 +265,7 @@ fn testnet_genesis( // an import since that's a made up number and should be replaced with a constant // obtained by benchmarking anyway. ump_service_total_weight: 4 * 1_000_000_000, - max_upward_message_size: 1024 * 1024, + max_upward_message_size: 50 * 1024, max_upward_message_num_per_candidate: 5, hrmp_sender_deposit: 0, hrmp_recipient_deposit: 0, diff --git a/polkadot/node/service/src/chain_spec.rs b/polkadot/node/service/src/chain_spec.rs index f55dd54933..cb5f5692b5 100644 --- a/polkadot/node/service/src/chain_spec.rs +++ b/polkadot/node/service/src/chain_spec.rs @@ -192,7 +192,7 @@ fn default_parachains_host_configuration( max_upward_queue_size: 1024 * 1024, max_downward_message_size: 1024 * 1024, ump_service_total_weight: 100_000_000_000, - max_upward_message_size: 1024 * 1024, + max_upward_message_size: 50 * 1024, max_upward_message_num_per_candidate: 5, hrmp_sender_deposit: 0, hrmp_recipient_deposit: 0, diff --git a/polkadot/runtime/kusama/src/lib.rs b/polkadot/runtime/kusama/src/lib.rs index 543565d0ff..7c3499ae3f 100644 --- a/polkadot/runtime/kusama/src/lib.rs +++ b/polkadot/runtime/kusama/src/lib.rs @@ -1228,6 +1228,7 @@ impl parachains_ump::Config for Runtime { crate::parachains_ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = EnsureRoot; + type WeightInfo = weights::runtime_parachains_ump::WeightInfo; } impl parachains_dmp::Config for Runtime {} @@ -1543,6 +1544,7 @@ mod benches { [runtime_parachains::initializer, Initializer] [runtime_parachains::paras_inherent, ParaInherent] [runtime_parachains::paras, Paras] + [runtime_parachains::ump, Ump] // Substrate [pallet_balances, Balances] [pallet_bags_list, BagsList] diff --git a/polkadot/runtime/kusama/src/weights/mod.rs b/polkadot/runtime/kusama/src/weights/mod.rs index 42f406954a..ed53e5ac79 100644 --- a/polkadot/runtime/kusama/src/weights/mod.rs +++ b/polkadot/runtime/kusama/src/weights/mod.rs @@ -51,3 +51,4 @@ pub mod runtime_parachains_hrmp; pub mod runtime_parachains_initializer; pub mod runtime_parachains_paras; pub mod runtime_parachains_paras_inherent; +pub mod runtime_parachains_ump; diff --git a/polkadot/runtime/kusama/src/weights/runtime_parachains_ump.rs b/polkadot/runtime/kusama/src/weights/runtime_parachains_ump.rs new file mode 100644 index 0000000000..0f7a88aeb4 --- /dev/null +++ b/polkadot/runtime/kusama/src/weights/runtime_parachains_ump.rs @@ -0,0 +1,66 @@ +// 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::ump` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-01-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot +// benchmark +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=runtime_parachains::ump +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/runtime_parachains_ump.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::ump`. +pub struct WeightInfo(PhantomData); +impl runtime_parachains::ump::WeightInfo for WeightInfo { + fn sink_process_upward_message(s: u32, ) -> Weight { + (3_715_000 as Weight) + // Standard Error: 0 + .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) + } + // Storage: Ump NeedsDispatch (r:1 w:1) + // Storage: Ump NextDispatchRoundStartWith (r:1 w:1) + // Storage: Ump RelayDispatchQueues (r:0 w:1) + // Storage: Ump RelayDispatchQueueSize (r:0 w:1) + fn clean_ump_after_outgoing() -> Weight { + (6_711_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + // Storage: Ump Overweight (r:1 w:1) + fn service_overweight() -> Weight { + (16_427_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/polkadot/runtime/parachains/src/configuration.rs b/polkadot/runtime/parachains/src/configuration.rs index 8337be8c29..4c296a2533 100644 --- a/polkadot/runtime/parachains/src/configuration.rs +++ b/polkadot/runtime/parachains/src/configuration.rs @@ -322,6 +322,8 @@ pub enum InconsistentError { }, /// `validation_upgrade_delay` is less than or equal 1. ValidationUpgradeDelayIsTooLow { validation_upgrade_delay: BlockNumber }, + /// Maximum UMP message size (`MAX_UPWARD_MESSAGE_SIZE_BOUND`) exceeded. + MaxUpwardMessageSizeExceeded { max_message_size: u32 }, /// Maximum number of HRMP outbound channels exceeded. MaxHrmpOutboundChannelsExceeded, /// Maximum number of HRMP inbound channels exceeded. @@ -388,6 +390,12 @@ where }) } + if self.max_upward_message_size > crate::ump::MAX_UPWARD_MESSAGE_SIZE_BOUND { + return Err(MaxUpwardMessageSizeExceeded { + max_message_size: self.max_upward_message_size, + }) + } + if self.hrmp_max_parachain_outbound_channels > crate::hrmp::HRMP_MAX_OUTBOUND_CHANNELS_BOUND { return Err(MaxHrmpOutboundChannelsExceeded) diff --git a/polkadot/runtime/parachains/src/mock.rs b/polkadot/runtime/parachains/src/mock.rs index 05abd0de27..3c99a07f33 100644 --- a/polkadot/runtime/parachains/src/mock.rs +++ b/polkadot/runtime/parachains/src/mock.rs @@ -230,6 +230,7 @@ impl crate::ump::Config for Test { type UmpSink = TestUmpSink; type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = frame_system::EnsureRoot; + type WeightInfo = crate::ump::TestWeightInfo; } impl crate::hrmp::Config for Test { diff --git a/polkadot/runtime/parachains/src/ump.rs b/polkadot/runtime/parachains/src/ump.rs index 10a16bb0a1..3ccb51a332 100644 --- a/polkadot/runtime/parachains/src/ump.rs +++ b/polkadot/runtime/parachains/src/ump.rs @@ -28,6 +28,15 @@ use xcm::latest::Outcome; pub use pallet::*; +/// Maximum value that `config.max_upward_message_size` can be set to +/// +/// This is used for benchmarking sanely bounding relevant storate items. It is expected from the `configurations` +/// pallet to check these values before setting. +pub const MAX_UPWARD_MESSAGE_SIZE_BOUND: u32 = 50 * 1024; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; + #[cfg(test)] pub(crate) mod tests; @@ -99,29 +108,38 @@ impl, C: Config> UmpSink for XcmSi }; let id = upward_message_id(&data[..]); - let maybe_msg = VersionedXcm::::decode_all_with_depth_limit( + let maybe_msg_and_weight = VersionedXcm::::decode_all_with_depth_limit( xcm::MAX_XCM_DECODE_DEPTH, &mut data, ) - .map(Xcm::::try_from); - match maybe_msg { + .map(|xcm| { + ( + Xcm::::try_from(xcm), + // NOTE: We are overestimating slightly here. + // The benchmark is timing this whole function with different message sizes and a NOOP extrinsic to + // measure the size-dependent weight. But as we use the weight funtion **in** the benchmarked funtion we + // are taking call and control-flow overhead into account twice. + ::WeightInfo::sink_process_upward_message(data.len() as u32), + ) + }); + match maybe_msg_and_weight { Err(_) => { Pallet::::deposit_event(Event::InvalidFormat(id)); Ok(0) }, - Ok(Err(())) => { + Ok((Err(()), weight_used)) => { Pallet::::deposit_event(Event::UnsupportedVersion(id)); - Ok(0) + Ok(weight_used) }, - Ok(Ok(xcm_message)) => { + Ok((Ok(xcm_message), weight_used)) => { let xcm_junction = Junction::Parachain(origin.into()); let outcome = XcmExecutor::execute_xcm(xcm_junction, xcm_message, max_weight); match outcome { Outcome::Error(XcmError::WeightLimitReached(required)) => Err((id, required)), outcome => { - let weight_used = outcome.weight_used(); + let outcome_weight = outcome.weight_used(); Pallet::::deposit_event(Event::ExecutedUpward(id, outcome)); - Ok(weight_used) + Ok(weight_used.saturating_add(outcome_weight)) }, } }, @@ -165,6 +183,29 @@ impl fmt::Debug for AcceptanceCheckErr { } } +/// Weight information of this pallet. +pub trait WeightInfo { + fn service_overweight() -> Weight; + fn sink_process_upward_message(s: u32) -> Weight; + fn clean_ump_after_outgoing() -> Weight; +} + +/// fallback implementation +pub struct TestWeightInfo; +impl WeightInfo for TestWeightInfo { + fn service_overweight() -> Weight { + Weight::MAX + } + + fn sink_process_upward_message(_msg_size: u32) -> Weight { + Weight::MAX + } + + fn clean_ump_after_outgoing() -> Weight { + Weight::MAX + } +} + #[frame_support::pallet] pub mod pallet { use super::*; @@ -192,6 +233,9 @@ pub mod pallet { /// Origin which is allowed to execute overweight messages. type ExecuteOverweightOrigin: EnsureOrigin; + + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; } #[pallet::event] @@ -303,7 +347,7 @@ pub mod pallet { /// /// Events: /// - `OverweightServiced`: On success. - #[pallet::weight(weight_limit.saturating_add(1_000_000))] + #[pallet::weight(weight_limit.saturating_add(::WeightInfo::service_overweight()))] pub fn service_overweight( origin: OriginFor, index: OverweightIndex, @@ -317,7 +361,7 @@ pub mod pallet { .map_err(|_| Error::::WeightOverLimit)?; Overweight::::remove(index); Self::deposit_event(Event::OverweightServiced(index, used)); - Ok(Some(used.saturating_add(1_000_000)).into()) + Ok(Some(used.saturating_add(::WeightInfo::service_overweight())).into()) } } } @@ -336,20 +380,22 @@ impl Pallet { pub(crate) fn initializer_on_new_session( _notification: &initializer::SessionChangeNotification, outgoing_paras: &[ParaId], - ) { - Self::perform_outgoing_para_cleanup(outgoing_paras); + ) -> Weight { + Self::perform_outgoing_para_cleanup(outgoing_paras) } /// Iterate over all paras that were noted for offboarding and remove all the data /// associated with them. - fn perform_outgoing_para_cleanup(outgoing: &[ParaId]) { + fn perform_outgoing_para_cleanup(outgoing: &[ParaId]) -> Weight { + let mut weight: Weight = 0; for outgoing_para in outgoing { - Self::clean_ump_after_outgoing(outgoing_para); + weight = weight.saturating_add(Self::clean_ump_after_outgoing(outgoing_para)); } + weight } /// Remove all relevant storage items for an outgoing parachain. - fn clean_ump_after_outgoing(outgoing_para: &ParaId) { + pub(crate) fn clean_ump_after_outgoing(outgoing_para: &ParaId) -> Weight { ::RelayDispatchQueueSize::remove(outgoing_para); ::RelayDispatchQueues::remove(outgoing_para); @@ -366,6 +412,8 @@ impl Pallet { ::NextDispatchRoundStartWith::mutate(|v| { *v = v.filter(|p| p == outgoing_para) }); + + ::WeightInfo::clean_ump_after_outgoing() } /// Check that all the upward messages sent by a candidate pass the acceptance criteria. Returns diff --git a/polkadot/runtime/parachains/src/ump/benchmarking.rs b/polkadot/runtime/parachains/src/ump/benchmarking.rs new file mode 100644 index 0000000000..2c132324d4 --- /dev/null +++ b/polkadot/runtime/parachains/src/ump/benchmarking.rs @@ -0,0 +1,139 @@ +// 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::{Pallet as Ump, *}; +use frame_system::RawOrigin; +use xcm::prelude::*; + +fn assert_last_event_type(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!(sp_std::mem::discriminant(event), sp_std::mem::discriminant(&system_event)); +} + +fn queue_upward_msg( + host_conf: &HostConfiguration, + para: ParaId, + msg: UpwardMessage, +) { + let len = msg.len() as u32; + let msgs = vec![msg]; + Ump::::check_upward_messages(host_conf, para, &msgs).unwrap(); + let _ = Ump::::receive_upward_messages(para, msgs); + assert_last_event_type::(Event::UpwardMessagesReceived(para, 1, len).into()); +} + +// Create a message with at least `size` bytes encoded length +fn create_message_min_size(size: u32) -> Vec { + // Create a message with an empty remark call to determine the encoding overhead + let msg_size_empty_transact = VersionedXcm::::from(Xcm::(vec![Transact { + origin_type: OriginKind::SovereignAccount, + require_weight_at_most: Weight::MAX, + call: frame_system::Call::::remark_with_event { remark: vec![] }.encode().into(), + }])) + .encode() + .len(); + + // Create a message with a remark call of just the size required to make the whole encoded message the requested size + let size = size.saturating_sub(msg_size_empty_transact as u32) as usize; + let mut remark = Vec::new(); + remark.resize(size, 0u8); + let msg = VersionedXcm::::from(Xcm::(vec![Transact { + origin_type: OriginKind::SovereignAccount, + require_weight_at_most: Weight::MAX, + call: frame_system::Call::::remark_with_event { remark }.encode().into(), + }])) + .encode(); + + assert!(msg.len() >= size); + msg +} + +fn create_message_overweight() -> Vec { + let max_block_weight = T::BlockWeights::get().max_block; + // We use a `set_code` Call because it + let call = frame_system::Call::::set_code { code: vec![] }; + VersionedXcm::::from(Xcm::(vec![Transact { + origin_type: OriginKind::Superuser, + require_weight_at_most: max_block_weight, + call: call.encode().into(), + }])) + .encode() +} + +frame_benchmarking::benchmarks! { + // NOTE: We are overestimating slightly here. + // The benchmark is timing this whole function with different message sizes and a NOOP extrinsic to + // measure the size-dependent weight. But as we use the weight function **in** the benchmarked function we + // are taking call and control-flow overhead into account twice. + process_upward_message { + let s in 0..MAX_UPWARD_MESSAGE_SIZE_BOUND; + let para = ParaId::from(1978); + let data = create_message_min_size::(s); + }: { + assert!(T::UmpSink::process_upward_message(para, &data[..], Weight::MAX).is_ok()); + } + + clean_ump_after_outgoing { + // max number of queued messages. + let count = configuration::ActiveConfig::::get().max_upward_queue_count; + let host_conf = configuration::ActiveConfig::::get(); + let msg = create_message_min_size::(0); + // Start with the block number 1. This is needed because should an event be + // emitted during the genesis block they will be implicitly wiped. + frame_system::Pallet::::set_block_number(1u32.into()); + // fill the queue, each message has it's own para-id. + for id in 0..count { + queue_upward_msg::(&host_conf, ParaId::from(id), msg.clone()); + } + }: { + Ump::::clean_ump_after_outgoing(&ParaId::from(0)); + } + + service_overweight { + let host_conf = configuration::ActiveConfig::::get(); + let weight = host_conf.ump_max_individual_weight + host_conf.ump_max_individual_weight + 1000000; + let para = ParaId::from(1978); + // The message's weight does not really matter here, as we add service_overweight's + // max_weight parameter to the extrinsic's weight in the weight calculation. + // The size of the message influences decoding time, so we create a min-sized message here + // and take the decoding weight into account by adding it to the extrinsic execution weight + // in the process_upward_message function. + let msg = create_message_overweight::(); + + // This just makes sure that 0 is not a valid index and we can use it later on. + let _ = Ump::::service_overweight(RawOrigin::Root.into(), 0, 1000); + // Start with the block number 1. This is needed because should an event be + // emitted during the genesis block they will be implicitly wiped. + frame_system::Pallet::::set_block_number(1u32.into()); + queue_upward_msg::(&host_conf, para, msg.clone()); + Ump::::process_pending_upward_messages(); + assert_last_event_type::( + Event::OverweightEnqueued(para, upward_message_id(&msg), 0, 0).into() + ); + }: _(RawOrigin::Root, 0, Weight::MAX) + verify { + assert_last_event_type::(Event::OverweightServiced(0, 0).into()); + } +} + +frame_benchmarking::impl_benchmark_test_suite!( + Ump, + crate::mock::new_test_ext(crate::ump::tests::GenesisConfigBuilder::default().build()), + crate::mock::Test +); diff --git a/polkadot/runtime/parachains/src/ump/tests.rs b/polkadot/runtime/parachains/src/ump/tests.rs index 8a45e7bbbb..8911a52c51 100644 --- a/polkadot/runtime/parachains/src/ump/tests.rs +++ b/polkadot/runtime/parachains/src/ump/tests.rs @@ -22,7 +22,7 @@ use crate::mock::{ use frame_support::{assert_noop, assert_ok, weights::Weight}; use std::collections::HashSet; -struct GenesisConfigBuilder { +pub(super) struct GenesisConfigBuilder { max_upward_message_size: u32, max_upward_message_num_per_candidate: u32, max_upward_queue_count: u32, @@ -45,7 +45,7 @@ impl Default for GenesisConfigBuilder { } impl GenesisConfigBuilder { - fn build(self) -> crate::mock::MockGenesisConfig { + pub(super) fn build(self) -> crate::mock::MockGenesisConfig { let mut genesis = default_genesis_config(); let config = &mut genesis.configuration.config; diff --git a/polkadot/runtime/polkadot/src/lib.rs b/polkadot/runtime/polkadot/src/lib.rs index 41f5ffdd34..a34ae0853b 100644 --- a/polkadot/runtime/polkadot/src/lib.rs +++ b/polkadot/runtime/polkadot/src/lib.rs @@ -1210,6 +1210,7 @@ impl parachains_ump::Config for Runtime { type UmpSink = (); type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = EnsureRoot; + type WeightInfo = parachains_ump::TestWeightInfo; } impl parachains_dmp::Config for Runtime {} @@ -1677,6 +1678,7 @@ mod benches { [runtime_parachains::initializer, Initializer] [runtime_parachains::paras, Paras] [runtime_parachains::paras_inherent, ParaInherent] + [runtime_parachains::ump, Ump] // Substrate [pallet_bags_list, BagsList] [pallet_balances, Balances] @@ -2092,6 +2094,7 @@ sp_api::impl_runtime_apis! { let mut batches = Vec::::new(); let params = (&config, &whitelist); + add_benchmarks!(params, batches); Ok(batches) diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 021d66c374..0db1036269 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -655,6 +655,7 @@ impl parachains_ump::Config for Runtime { crate::parachains_ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = EnsureRoot; + type WeightInfo = weights::runtime_parachains_ump::WeightInfo; } impl parachains_dmp::Config for Runtime {} @@ -1124,6 +1125,7 @@ mod benches { [runtime_parachains::disputes, ParasDisputes] [runtime_parachains::paras_inherent, ParaInherent] [runtime_parachains::paras, Paras] + [runtime_parachains::ump, Ump] ); } diff --git a/polkadot/runtime/rococo/src/weights/mod.rs b/polkadot/runtime/rococo/src/weights/mod.rs index b8931b180a..ca9d51706a 100644 --- a/polkadot/runtime/rococo/src/weights/mod.rs +++ b/polkadot/runtime/rococo/src/weights/mod.rs @@ -20,3 +20,4 @@ pub mod runtime_parachains_disputes; pub mod runtime_parachains_hrmp; pub mod runtime_parachains_paras; pub mod runtime_parachains_paras_inherent; +pub mod runtime_parachains_ump; diff --git a/polkadot/runtime/rococo/src/weights/runtime_parachains_ump.rs b/polkadot/runtime/rococo/src/weights/runtime_parachains_ump.rs new file mode 100644 index 0000000000..14da7e26c5 --- /dev/null +++ b/polkadot/runtime/rococo/src/weights/runtime_parachains_ump.rs @@ -0,0 +1,66 @@ +// 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::ump` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-01-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot +// benchmark +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=runtime_parachains::ump +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/runtime_parachains_ump.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::ump`. +pub struct WeightInfo(PhantomData); +impl runtime_parachains::ump::WeightInfo for WeightInfo { + fn sink_process_upward_message(s: u32, ) -> Weight { + (3_539_000 as Weight) + // Standard Error: 0 + .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) + } + // Storage: Ump NeedsDispatch (r:1 w:1) + // Storage: Ump NextDispatchRoundStartWith (r:1 w:1) + // Storage: Ump RelayDispatchQueues (r:0 w:1) + // Storage: Ump RelayDispatchQueueSize (r:0 w:1) + fn clean_ump_after_outgoing() -> Weight { + (6_621_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + // Storage: Ump Overweight (r:1 w:1) + fn service_overweight() -> Weight { + (16_026_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 180694af68..363f124921 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -516,6 +516,7 @@ impl parachains_ump::Config for Runtime { type UmpSink = (); type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = frame_system::EnsureRoot; + type WeightInfo = parachains_ump::TestWeightInfo; } parameter_types! { diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index a23d653dcc..121e46f198 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -852,6 +852,7 @@ impl parachains_ump::Config for Runtime { crate::parachains_ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = EnsureRoot; + type WeightInfo = weights::runtime_parachains_ump::WeightInfo; } impl parachains_dmp::Config for Runtime {} @@ -1126,6 +1127,7 @@ mod benches { [runtime_parachains::initializer, Initializer] [runtime_parachains::paras, Paras] [runtime_parachains::paras_inherent, ParaInherent] + [runtime_parachains::ump, Ump] // Substrate [pallet_bags_list, BagsList] [pallet_balances, Balances] diff --git a/polkadot/runtime/westend/src/weights/mod.rs b/polkadot/runtime/westend/src/weights/mod.rs index 69ace0a5a6..d04a8fc3c9 100644 --- a/polkadot/runtime/westend/src/weights/mod.rs +++ b/polkadot/runtime/westend/src/weights/mod.rs @@ -40,4 +40,5 @@ pub mod runtime_parachains_hrmp; pub mod runtime_parachains_initializer; pub mod runtime_parachains_paras; pub mod runtime_parachains_paras_inherent; +pub mod runtime_parachains_ump; pub mod xcm; diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_ump.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_ump.rs new file mode 100644 index 0000000000..fe37be059b --- /dev/null +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_ump.rs @@ -0,0 +1,66 @@ +// 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::ump` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-01-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot +// benchmark +// --chain=westend-dev +// --steps=50 +// --repeat=20 +// --pallet=runtime_parachains::ump +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/westend/src/weights/runtime_parachains_ump.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::ump`. +pub struct WeightInfo(PhantomData); +impl runtime_parachains::ump::WeightInfo for WeightInfo { + fn sink_process_upward_message(s: u32, ) -> Weight { + (3_455_000 as Weight) + // Standard Error: 0 + .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) + } + // Storage: Ump NeedsDispatch (r:1 w:1) + // Storage: Ump NextDispatchRoundStartWith (r:1 w:1) + // Storage: Ump RelayDispatchQueues (r:0 w:1) + // Storage: Ump RelayDispatchQueueSize (r:0 w:1) + fn clean_ump_after_outgoing() -> Weight { + (6_759_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + // Storage: Ump Overweight (r:1 w:1) + fn service_overweight() -> Weight { + (16_482_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/polkadot/xcm/xcm-simulator/example/src/relay_chain.rs b/polkadot/xcm/xcm-simulator/example/src/relay_chain.rs index 792a58d1a8..a648ba96ba 100644 --- a/polkadot/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/polkadot/xcm/xcm-simulator/example/src/relay_chain.rs @@ -170,6 +170,7 @@ impl ump::Config for Runtime { type UmpSink = ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = frame_system::EnsureRoot; + type WeightInfo = ump::TestWeightInfo; } impl origin::Config for Runtime {} diff --git a/polkadot/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/polkadot/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 792a58d1a8..a648ba96ba 100644 --- a/polkadot/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/polkadot/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -170,6 +170,7 @@ impl ump::Config for Runtime { type UmpSink = ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = frame_system::EnsureRoot; + type WeightInfo = ump::TestWeightInfo; } impl origin::Config for Runtime {}