From b1343de94fa44d9f181a2778efd5f19e0e6118e9 Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Wed, 22 Sep 2021 23:48:33 -0700 Subject: [PATCH 01/13] Add benchmarking to rococo; Remove weights from runtime_parachains --- Cargo.lock | 2 + runtime/parachains/src/configuration.rs | 1 - runtime/parachains/src/paras.rs | 1 - runtime/rococo/Cargo.toml | 5 ++ runtime/rococo/src/lib.rs | 55 ++++++++++++++++++- runtime/rococo/src/weights/mod.rs | 19 +++++++ .../runtime_parachains_configuration.rs} | 49 ++++++++++------- .../src/weights/runtime_parachains_paras.rs} | 53 ++++++++++-------- runtime/westend/src/lib.rs | 2 +- 9 files changed, 140 insertions(+), 47 deletions(-) create mode 100644 runtime/rococo/src/weights/mod.rs rename runtime/{parachains/src/configuration/weights.rs => rococo/src/weights/runtime_parachains_configuration.rs} (66%) rename runtime/{parachains/src/paras/weights.rs => rococo/src/weights/runtime_parachains_paras.rs} (69%) diff --git a/Cargo.lock b/Cargo.lock index c887e6fd17d7..91213b72d4a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7811,10 +7811,12 @@ dependencies = [ "bp-runtime", "bp-wococo", "bridge-runtime-common", + "frame-benchmarking", "frame-executive", "frame-support", "frame-system", "frame-system-rpc-runtime-api", + "hex-literal", "log", "pallet-authority-discovery", "pallet-authorship", diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index f2c94ef91532..c0b6c9698a19 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -28,7 +28,6 @@ use sp_std::prelude::*; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; -pub mod weights; pub use pallet::*; diff --git a/runtime/parachains/src/paras.rs b/runtime/parachains/src/paras.rs index 666012a3b4e3..857ccc9c01ee 100644 --- a/runtime/parachains/src/paras.rs +++ b/runtime/parachains/src/paras.rs @@ -43,7 +43,6 @@ pub use crate::Origin as ParachainOrigin; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; -pub mod weights; pub use pallet::*; diff --git a/runtime/rococo/Cargo.toml b/runtime/rococo/Cargo.toml index 527e66890819..05aeb03352d8 100644 --- a/runtime/rococo/Cargo.toml +++ b/runtime/rococo/Cargo.toml @@ -68,6 +68,9 @@ xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", defa xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default-features = false } pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } +hex-literal = { version = "0.3.3", optional = true } + # Bridge Dependencies bp-messages = { path = "../../bridges/primitives/messages", default-features = false } bp-rococo = { path = "../../bridges/primitives/chain-rococo", default-features = false } @@ -169,6 +172,8 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "xcm-builder/runtime-benchmarks", + "frame-benchmarking", + "hex-literal" ] try-runtime = [ "frame-executive/try-runtime", diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 9f03cc8253e8..9c26a2dd92d3 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -94,6 +94,7 @@ use xcm_executor::XcmExecutor; /// Constant values used within the runtime. pub mod constants; mod validator_manager; +mod weights; // Make the WASM binary available. #[cfg(feature = "std")] @@ -570,7 +571,7 @@ impl pallet_authorship::Config for Runtime { impl parachains_origin::Config for Runtime {} impl parachains_configuration::Config for Runtime { - type WeightInfo = parachains_configuration::weights::WeightInfo; + type WeightInfo = weights::runtime_parachains_configuration::WeightInfo; } impl parachains_shared::Config for Runtime {} @@ -591,7 +592,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; + type WeightInfo = weights::runtime_parachains_paras::WeightInfo; } parameter_types! { @@ -1559,4 +1560,54 @@ sp_api::impl_runtime_apis! { TransactionPayment::query_fee_details(uxt, len) } } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { + use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + + let mut list = Vec::::new(); + + list_benchmark!(list, extra, runtime_parachains::configuration, Configuration); + list_benchmark!(list, extra, runtime_parachains::paras, Paras); + + let storage_info = AllPalletsWithSystem::storage_info(); + + return (list, storage_info) + } + + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig, + ) -> Result< + Vec, + sp_runtime::RuntimeString, + > { + use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; + + let mut batches = Vec::::new(); + let whitelist: Vec = vec![ + // Block Number + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), + // Total Issuance + hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(), + // Execution Phase + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(), + // Event Count + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(), + // System Events + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), + ]; + let params = (&config, &whitelist); + + add_benchmark!(params, batches, runtime_parachains::configuration, Configuration); + add_benchmark!(params, batches, runtime_parachains::paras, Paras); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) + } + } } diff --git a/runtime/rococo/src/weights/mod.rs b/runtime/rococo/src/weights/mod.rs new file mode 100644 index 000000000000..7ce67c1956db --- /dev/null +++ b/runtime/rococo/src/weights/mod.rs @@ -0,0 +1,19 @@ +// Copyright (C) 2020 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! A list of the different weight modules for our runtime. + +pub mod runtime_parachains_configuration; +pub mod runtime_parachains_paras; diff --git a/runtime/parachains/src/configuration/weights.rs b/runtime/rococo/src/weights/runtime_parachains_configuration.rs similarity index 66% rename from runtime/parachains/src/configuration/weights.rs rename to runtime/rococo/src/weights/runtime_parachains_configuration.rs index da70d6cb29d1..6c1753e7c3b3 100644 --- a/runtime/parachains/src/configuration/weights.rs +++ b/runtime/rococo/src/weights/runtime_parachains_configuration.rs @@ -1,4 +1,18 @@ +// Copyright 2017-2021 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . //! Autogenerated weights for `runtime_parachains::configuration` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev @@ -6,23 +20,18 @@ //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 // Executed Command: -// ./target/release/polkadot +// target/release/polkadot // benchmark -// --chain -// westend-dev +// --chain=westend-dev +// --steps=50 +// --repeat=20 +// --pallet=runtime_parachains::configuration +// --extrinsic=* // --execution=wasm // --wasm-execution=compiled -// --pallet -// runtime_parachains::configuration -// --steps -// 50 -// --repeat -// 20 -// --raw -// --extrinsic -// * -// --output -// runtime/parachains/src/configuration/weights.rs +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/westend/src/weights/runtime_parachains_configuration.rs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -34,12 +43,12 @@ use sp_std::marker::PhantomData; /// Weight functions for `runtime_parachains::configuration`. pub struct WeightInfo(PhantomData); -impl super::WeightInfo for WeightInfo { +impl runtime_parachains::configuration::WeightInfo for WeightInfo { // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfig (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) fn set_config_with_block_number() -> Weight { - (16_730_000 as Weight) + (12_795_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -47,7 +56,7 @@ impl super::WeightInfo for WeightInfo { // 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) + (12_758_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -55,7 +64,7 @@ impl super::WeightInfo for WeightInfo { // 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) + (12_861_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -63,7 +72,7 @@ impl super::WeightInfo for WeightInfo { // 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) + (12_854_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -75,7 +84,7 @@ impl super::WeightInfo for WeightInfo { // 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) + (12_838_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } diff --git a/runtime/parachains/src/paras/weights.rs b/runtime/rococo/src/weights/runtime_parachains_paras.rs similarity index 69% rename from runtime/parachains/src/paras/weights.rs rename to runtime/rococo/src/weights/runtime_parachains_paras.rs index d02acf4bc687..f04f3162a263 100644 --- a/runtime/parachains/src/paras/weights.rs +++ b/runtime/rococo/src/weights/runtime_parachains_paras.rs @@ -1,4 +1,18 @@ +// 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 @@ -6,23 +20,18 @@ //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 // Executed Command: -// ./target/release/polkadot +// target/release/polkadot // benchmark -// --chain -// westend-dev +// --chain=westend-dev +// --steps=50 +// --repeat=20 +// --pallet=runtime_parachains::paras +// --extrinsic=* // --execution=wasm // --wasm-execution=compiled -// --pallet -// runtime_parachains::paras -// --steps -// 50 -// --repeat -// 20 -// --raw -// --extrinsic -// * -// --output -// runtime/parachains/src/paras/weights.rs +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/westend/src/weights/runtime_parachains_paras.rs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -34,7 +43,7 @@ use sp_std::marker::PhantomData; /// Weight functions for `runtime_parachains::paras`. pub struct WeightInfo(PhantomData); -impl super::WeightInfo for WeightInfo { +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) @@ -42,7 +51,7 @@ impl super::WeightInfo for WeightInfo { // 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) + (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)) @@ -50,9 +59,9 @@ impl super::WeightInfo for WeightInfo { } // Storage: Paras Heads (r:0 w:1) fn force_set_current_head(s: u32, ) -> Weight { - (0 as Weight) + (17_522_000 as Weight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) + .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) @@ -65,7 +74,7 @@ impl super::WeightInfo for WeightInfo { // 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) + (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)) @@ -81,16 +90,16 @@ impl super::WeightInfo for WeightInfo { // 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) + (71_155_000 as Weight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) + .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 { - (32_014_000 as Weight) + (27_230_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/westend/src/lib.rs b/runtime/westend/src/lib.rs index 179088dc1a57..707d09dab61b 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -805,7 +805,7 @@ impl pallet_proxy::Config for Runtime { impl parachains_origin::Config for Runtime {} impl parachains_configuration::Config for Runtime { - type WeightInfo = parachains_configuration::weights::WeightInfo; + type WeightInfo = weights::runtime_parachains_configuration::WeightInfo; } impl parachains_shared::Config for Runtime {} From 288d43a4b976578c293fcaac1df77b53db740d19 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Thu, 23 Sep 2021 07:03:28 +0000 Subject: [PATCH 02/13] cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=rococo-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtime/rococo/src/weights/runtime_parachains_paras.rs --header=./file_header.txt --- .../rococo/src/weights/runtime_parachains_paras.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/runtime/rococo/src/weights/runtime_parachains_paras.rs b/runtime/rococo/src/weights/runtime_parachains_paras.rs index f04f3162a263..49a4005a7c7d 100644 --- a/runtime/rococo/src/weights/runtime_parachains_paras.rs +++ b/runtime/rococo/src/weights/runtime_parachains_paras.rs @@ -16,13 +16,13 @@ //! 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 +//! DATE: 2021-09-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 128 // Executed Command: // target/release/polkadot // benchmark -// --chain=westend-dev +// --chain=rococo-dev // --steps=50 // --repeat=20 // --pallet=runtime_parachains::paras @@ -30,8 +30,8 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 +// --output=./runtime/rococo/src/weights/runtime_parachains_paras.rs // --header=./file_header.txt -// --output=./runtime/westend/src/weights/runtime_parachains_paras.rs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -59,7 +59,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn } // Storage: Paras Heads (r:0 w:1) fn force_set_current_head(s: u32, ) -> Weight { - (17_522_000 as Weight) + (14_890_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)) @@ -90,7 +90,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // 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) + (69_079_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)) @@ -99,7 +99,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) fn force_queue_action() -> Weight { - (27_230_000 as Weight) + (26_784_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } From 2e7675b85432bc8555a4dfdfe637311f69bbd65b Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Thu, 23 Sep 2021 00:20:26 -0700 Subject: [PATCH 03/13] Impl TestWeightInfo for Paras and Configuration --- runtime/parachains/src/configuration.rs | 22 ++++++++++++++++++++++ runtime/parachains/src/mock.rs | 4 ++-- runtime/parachains/src/paras.rs | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index c0b6c9698a19..aee3e12a9842 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -277,6 +277,28 @@ pub trait WeightInfo { fn set_hrmp_open_request_ttl() -> Weight; } +pub struct TestWeightInfo; +impl WeightInfo for TestWeightInfo { + fn set_config_with_block_number() -> Weight { + 0 + } + fn set_config_with_u32() -> Weight { + 0 + } + fn set_config_with_option_u32() -> Weight { + 0 + } + fn set_config_with_weight() -> Weight { + 0 + } + fn set_config_with_balance() -> Weight { + 0 + } + fn set_hrmp_open_request_ttl() -> Weight { + 0 + } +} + #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 387e0a7bf5e8..8221b3a416f2 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -115,7 +115,7 @@ impl crate::initializer::Config for Test { } impl crate::configuration::Config for Test { - type WeightInfo = crate::configuration::weights::WeightInfo; + type WeightInfo = crate::configuration::TestWeightInfo; } impl crate::shared::Config for Test {} @@ -123,7 +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; + type WeightInfo = crate::paras::TestWeightInfo; } impl crate::dmp::Config for Test {} diff --git a/runtime/parachains/src/paras.rs b/runtime/parachains/src/paras.rs index 857ccc9c01ee..af90cf547909 100644 --- a/runtime/parachains/src/paras.rs +++ b/runtime/parachains/src/paras.rs @@ -278,6 +278,25 @@ pub trait WeightInfo { fn force_queue_action() -> Weight; } +pub struct TestWeightInfo; +impl WeightInfo for TestWeightInfo { + fn force_set_current_code(c: u32) -> Weight { + 0 + } + fn force_set_current_head(s: u32) -> Weight { + 0 + } + fn force_schedule_code_upgrade(c: u32) -> Weight { + 0 + } + fn force_note_new_head(s: u32) -> Weight { + 0 + } + fn force_queue_action() -> Weight { + 0 + } +} + #[frame_support::pallet] pub mod pallet { use super::*; From dab9ac4420082e66ab1badb264dce6d13682667e Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Thu, 23 Sep 2021 00:25:45 -0700 Subject: [PATCH 04/13] fmt --- runtime/parachains/src/paras.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/parachains/src/paras.rs b/runtime/parachains/src/paras.rs index af90cf547909..fbcfee491095 100644 --- a/runtime/parachains/src/paras.rs +++ b/runtime/parachains/src/paras.rs @@ -289,7 +289,7 @@ impl WeightInfo for TestWeightInfo { fn force_schedule_code_upgrade(c: u32) -> Weight { 0 } - fn force_note_new_head(s: u32) -> Weight { + fn force_note_new_head(s: u32) -> Weight { 0 } fn force_queue_action() -> Weight { From 3148c583d5ba9ed6b25418a794e1d6dcccd3a45b Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Thu, 23 Sep 2021 07:37:53 +0000 Subject: [PATCH 05/13] cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=rococo-dev --steps=50 --repeat=20 --pallet=runtime_parachains::configuration --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtime/rococo/src/weights/runtime_parachains_configuration.rs --header=./file_header.txt --- .../runtime_parachains_configuration.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/runtime/rococo/src/weights/runtime_parachains_configuration.rs b/runtime/rococo/src/weights/runtime_parachains_configuration.rs index 6c1753e7c3b3..c783fb4131a3 100644 --- a/runtime/rococo/src/weights/runtime_parachains_configuration.rs +++ b/runtime/rococo/src/weights/runtime_parachains_configuration.rs @@ -16,13 +16,13 @@ //! 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 +//! DATE: 2021-09-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 128 // Executed Command: // target/release/polkadot // benchmark -// --chain=westend-dev +// --chain=rococo-dev // --steps=50 // --repeat=20 // --pallet=runtime_parachains::configuration @@ -30,8 +30,8 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 +// --output=./runtime/rococo/src/weights/runtime_parachains_configuration.rs // --header=./file_header.txt -// --output=./runtime/westend/src/weights/runtime_parachains_configuration.rs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -48,7 +48,7 @@ impl runtime_parachains::configuration::WeightInfo for // 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) + (13_098_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -56,7 +56,7 @@ impl runtime_parachains::configuration::WeightInfo for // 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) + (13_216_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -64,7 +64,7 @@ impl runtime_parachains::configuration::WeightInfo for // 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) + (13_080_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -72,7 +72,7 @@ impl runtime_parachains::configuration::WeightInfo for // 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) + (13_178_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -84,7 +84,7 @@ impl runtime_parachains::configuration::WeightInfo for // 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) + (13_080_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } From 9007d36ead2289ead98f87c5a0cd68a8b51288ad Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Thu, 23 Sep 2021 00:49:22 -0700 Subject: [PATCH 06/13] Fix CI complaint: error: unused variable: `c` --- runtime/parachains/src/paras.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/parachains/src/paras.rs b/runtime/parachains/src/paras.rs index fbcfee491095..a61e497a2845 100644 --- a/runtime/parachains/src/paras.rs +++ b/runtime/parachains/src/paras.rs @@ -280,16 +280,16 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { - fn force_set_current_code(c: u32) -> Weight { + fn force_set_current_code(_c: u32) -> Weight { 0 } - fn force_set_current_head(s: u32) -> Weight { + fn force_set_current_head(_s: u32) -> Weight { 0 } - fn force_schedule_code_upgrade(c: u32) -> Weight { + fn force_schedule_code_upgrade(_c: u32) -> Weight { 0 } - fn force_note_new_head(s: u32) -> Weight { + fn force_note_new_head(_s: u32) -> Weight { 0 } fn force_queue_action() -> Weight { From fccf31898cfe8babcae344b2da641096bd983dc0 Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Thu, 23 Sep 2021 01:30:50 -0700 Subject: [PATCH 07/13] polkadot-runtime-common & polkadot-test-runtime compile --- runtime/common/src/integration_tests.rs | 4 ++-- runtime/test-runtime/src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index 5653100815aa..beb0ef86446e 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -159,7 +159,7 @@ impl pallet_balances::Config for Test { } impl configuration::Config for Test { - type WeightInfo = configuration::weights::WeightInfo; + type WeightInfo = configuration::TestWeightInfo; } impl shared::Config for Test {} @@ -167,7 +167,7 @@ impl shared::Config for Test {} impl paras::Config for Test { type Origin = Origin; type Event = Event; - type WeightInfo = paras::weights::WeightInfo; + type WeightInfo = paras::TestWeightInfo; } parameter_types! { diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 722aab3e16af..6a632370cf7b 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -457,7 +457,7 @@ impl pallet_sudo::Config for Runtime { } impl parachains_configuration::Config for Runtime { - type WeightInfo = parachains_configuration::weights::WeightInfo; + type WeightInfo = parachains_configuration::TestWeightInfo; } impl parachains_shared::Config for Runtime {} @@ -486,7 +486,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; + type WeightInfo = parachains_paras::TestWeightInfo; } impl parachains_dmp::Config for Runtime {} From 2c2e5f8f5a9f8ddbddf87e66ffa334ec7d5d396b Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Thu, 23 Sep 2021 01:52:38 -0700 Subject: [PATCH 08/13] xcm-simulator compile --- runtime/common/src/paras_registrar.rs | 4 ++-- xcm/xcm-builder/tests/mock/mod.rs | 2 +- xcm/xcm-simulator/example/src/relay_chain.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/common/src/paras_registrar.rs b/runtime/common/src/paras_registrar.rs index 448bc5092403..fd45c7969372 100644 --- a/runtime/common/src/paras_registrar.rs +++ b/runtime/common/src/paras_registrar.rs @@ -657,11 +657,11 @@ mod tests { impl paras::Config for Test { type Origin = Origin; type Event = Event; - type WeightInfo = paras::weights::WeightInfo; + type WeightInfo = paras::TestWeightInfo; } impl configuration::Config for Test { - type WeightInfo = configuration::weights::WeightInfo; + type WeightInfo = configuration::TestWeightInfo; } parameter_types! { diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index bcdac942a30a..3f6ba653ffc8 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -108,7 +108,7 @@ impl pallet_balances::Config for Runtime { impl shared::Config for Runtime {} impl configuration::Config for Runtime { - type WeightInfo = configuration::weights::WeightInfo; + type WeightInfo = configuration::TestWeightInfo; } // aims to closely emulate the Kusama XcmConfig diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index cc50aec90d18..8dcb5f1f310b 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -89,7 +89,7 @@ impl pallet_balances::Config for Runtime { impl shared::Config for Runtime {} impl configuration::Config for Runtime { - type WeightInfo = configuration::weights::WeightInfo; + type WeightInfo = configuration::TestWeightInfo; } parameter_types! { From 1f6923dc84f02cba54c6ec52539ed0ff71935710 Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Thu, 23 Sep 2021 10:08:07 -0700 Subject: [PATCH 09/13] change TestWeightInfo to max_block --- runtime/parachains/src/configuration.rs | 12 ++++++------ runtime/parachains/src/paras.rs | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index b2b42ea80ccb..0a9a9391fb35 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -280,22 +280,22 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn set_config_with_block_number() -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } fn set_config_with_u32() -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } fn set_config_with_option_u32() -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } fn set_config_with_weight() -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } fn set_config_with_balance() -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } fn set_hrmp_open_request_ttl() -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } } diff --git a/runtime/parachains/src/paras.rs b/runtime/parachains/src/paras.rs index a61e497a2845..7175bdfb3467 100644 --- a/runtime/parachains/src/paras.rs +++ b/runtime/parachains/src/paras.rs @@ -281,19 +281,19 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn force_set_current_code(_c: u32) -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } fn force_set_current_head(_s: u32) -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } fn force_schedule_code_upgrade(_c: u32) -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } fn force_note_new_head(_s: u32) -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } fn force_queue_action() -> Weight { - 0 + frame_system::limits::BlockWeights::default().max_block } } From 7dc853567c9a4419705fceb8303e3e96f03d630b Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Thu, 23 Sep 2021 17:26:18 +0000 Subject: [PATCH 10/13] cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=rococo-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtime/rococo/src/weights/runtime_parachains_paras.rs --header=./file_header.txt --- runtime/rococo/src/weights/runtime_parachains_paras.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/rococo/src/weights/runtime_parachains_paras.rs b/runtime/rococo/src/weights/runtime_parachains_paras.rs index 49a4005a7c7d..25d73a72b6ef 100644 --- a/runtime/rococo/src/weights/runtime_parachains_paras.rs +++ b/runtime/rococo/src/weights/runtime_parachains_paras.rs @@ -59,7 +59,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn } // Storage: Paras Heads (r:0 w:1) fn force_set_current_head(s: u32, ) -> Weight { - (14_890_000 as Weight) + (17_241_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)) @@ -90,7 +90,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras PastCodeHash (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn force_note_new_head(s: u32, ) -> Weight { - (69_079_000 as Weight) + (70_119_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)) @@ -99,7 +99,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) fn force_queue_action() -> Weight { - (26_784_000 as Weight) + (26_597_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } From ee8d0963b9bb7fbc38fddf951e3ba86fc5b79615 Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Thu, 23 Sep 2021 18:30:29 -0700 Subject: [PATCH 11/13] ordering --- runtime/rococo/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 28e4fde1e2dd..52edca600867 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1574,8 +1574,8 @@ sp_api::impl_runtime_apis! { let mut list = Vec::::new(); list_benchmark!(list, extra, runtime_parachains::configuration, Configuration); - list_benchmark!(list, extra, runtime_parachains::paras, Paras); list_benchmark!(list, extra, runtime_parachains::disputes, ParasDisputes); + list_benchmark!(list, extra, runtime_parachains::paras, Paras); let storage_info = AllPalletsWithSystem::storage_info(); @@ -1606,8 +1606,8 @@ sp_api::impl_runtime_apis! { let params = (&config, &whitelist); add_benchmark!(params, batches, runtime_parachains::configuration, Configuration); - add_benchmark!(params, batches, runtime_parachains::paras, Paras); add_benchmark!(params, batches, runtime_parachains::disputes, ParasDisputes); + add_benchmark!(params, batches, runtime_parachains::paras, Paras); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) From cd36b0528d9229c818c387b730cab9057118d0b1 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Fri, 24 Sep 2021 01:43:08 +0000 Subject: [PATCH 12/13] cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=rococo-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtime/rococo/src/weights/runtime_parachains_paras.rs --header=./file_header.txt --- runtime/rococo/src/weights/runtime_parachains_paras.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/rococo/src/weights/runtime_parachains_paras.rs b/runtime/rococo/src/weights/runtime_parachains_paras.rs index 25d73a72b6ef..b3d93dd5c60d 100644 --- a/runtime/rococo/src/weights/runtime_parachains_paras.rs +++ b/runtime/rococo/src/weights/runtime_parachains_paras.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::paras` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-09-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-09-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 128 // Executed Command: @@ -59,7 +59,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn } // Storage: Paras Heads (r:0 w:1) fn force_set_current_head(s: u32, ) -> Weight { - (17_241_000 as Weight) + (18_653_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)) @@ -90,7 +90,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras PastCodeHash (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn force_note_new_head(s: u32, ) -> Weight { - (70_119_000 as Weight) + (69_515_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)) @@ -99,7 +99,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) fn force_queue_action() -> Weight { - (26_597_000 as Weight) + (26_804_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } From 174cb8a109ecf7a4a7ce8dbf38f3168643b7d505 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 6 Oct 2021 01:34:52 -0700 Subject: [PATCH 13/13] Replace max_block with Weight::MAX --- runtime/parachains/src/configuration.rs | 12 ++++++------ runtime/parachains/src/paras.rs | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index 0a9a9391fb35..3a58ddfdc8f5 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -280,22 +280,22 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn set_config_with_block_number() -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } fn set_config_with_u32() -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } fn set_config_with_option_u32() -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } fn set_config_with_weight() -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } fn set_config_with_balance() -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } fn set_hrmp_open_request_ttl() -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } } diff --git a/runtime/parachains/src/paras.rs b/runtime/parachains/src/paras.rs index 7175bdfb3467..4582e3e99c44 100644 --- a/runtime/parachains/src/paras.rs +++ b/runtime/parachains/src/paras.rs @@ -281,19 +281,19 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn force_set_current_code(_c: u32) -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } fn force_set_current_head(_s: u32) -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } fn force_schedule_code_upgrade(_c: u32) -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } fn force_note_new_head(_s: u32) -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } fn force_queue_action() -> Weight { - frame_system::limits::BlockWeights::default().max_block + Weight::MAX } }