From 2902f6272399c02f91ef65a1882051c300b25926 Mon Sep 17 00:00:00 2001 From: Sergey Shulepov Date: Wed, 16 Feb 2022 17:40:18 +0000 Subject: [PATCH 1/6] paras: `include_pvf_check_statement` rt bench MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves #4933 This PR adds a benchmark for the `include_pvf_check_statement` dispatchable. This is a necessary step to make it work without modifications. That enables us to proceed with testing on Versi. This introduces 5 new benchmarks. Those measure performance of the `include_pvf_check_statement` under 2 different conditions: 1. regular vote submission. That's the common case. 2. submission of the last vote. That happens only once and leads to a heavy finalization stage. There are 2 different types of finalization (one for onboarding, one for upgrading) and there are two outcomes: accepted and rejected. Those 4 are similar but I decided to cover them all and assign the maximum of all 4. This is to avoid a situation when one of those paths becomes more heavier than others and opens up an attack venue. The regular vote submission weight is drastically different from the submission last vote weight. That's why in case during runtime finalization was not executed the weight consumed value will be lowered down to the regular vote submission. The finalization weight is proportional to the number of "causes", i.e. the events that caused the PVF pre-checking vote in the first place, and here we assume that the maximum number of causes is 100. Theoretically, there is nothing that prevents an adversary to register/upgrade to more than 100 parachains. In that case, the consumed weight will be lower than the actual time consumed by the finalization process. That can enable a DoS vector. However, practically, it is not very possible. Right now it is very expensive to call `schedule_para_initialize` because it requires a very large lock up of funds. Moreover, finalizing a vote with 100 causes leads to around 31ms time spent. Finalizing more will require more time. However, finalizing with 200 causes will cause ≈62ms delay. This is not that bad since even though we had a full block and the adversary tried to finalize 200 causes it won't be able to even exceed the operational extrinsic boundary of 250ms and even if so it won't make big difference. That said, this should be addressed later on, esp. when we enable parathreads, which will make creating causes easier. One of potential solutions will be shifting the logic of finalization into `on_initialize`/`on_finalize`. Another is to create a maximum number of causes and then reject upgrades or onboardings if that was reached. --- Cargo.lock | 1 + .../src/weights/runtime_parachains_paras.rs | 6 + runtime/parachains/Cargo.toml | 2 + runtime/parachains/src/paras/benchmarking.rs | 48 ++++- .../src/paras/benchmarking/pvf_check.rs | 195 ++++++++++++++++++ runtime/parachains/src/paras/mod.rs | 49 ++++- runtime/parachains/src/paras/tests.rs | 66 +++++- runtime/parachains/src/shared.rs | 2 +- .../src/weights/runtime_parachains_paras.rs | 5 + .../src/weights/runtime_parachains_paras.rs | 5 + .../src/weights/runtime_parachains_paras.rs | 5 + 11 files changed, 375 insertions(+), 9 deletions(-) create mode 100644 runtime/parachains/src/paras/benchmarking/pvf_check.rs diff --git a/Cargo.lock b/Cargo.lock index 86ff6d361a4f..0d7c2506f509 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7148,6 +7148,7 @@ dependencies = [ "scale-info", "serde", "sp-api", + "sp-application-crypto", "sp-core", "sp-inherents", "sp-io", diff --git a/runtime/kusama/src/weights/runtime_parachains_paras.rs b/runtime/kusama/src/weights/runtime_parachains_paras.rs index 36ec52fcf5ba..8586105c546e 100644 --- a/runtime/kusama/src/weights/runtime_parachains_paras.rs +++ b/runtime/kusama/src/weights/runtime_parachains_paras.rs @@ -110,4 +110,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + + fn include_pvf_check_statement_finalize_upgrade_accept() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_upgrade_reject() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_onboarding_accept() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_onboarding_reject() -> u64 { Weight::MAX } + fn include_pvf_check_statement() -> u64 { Weight::MAX } } diff --git a/runtime/parachains/Cargo.toml b/runtime/parachains/Cargo.toml index 028b749452d9..565cc48608fd 100644 --- a/runtime/parachains/Cargo.toml +++ b/runtime/parachains/Cargo.toml @@ -24,6 +24,7 @@ sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } sp-tracing = { version = "4.0.0-dev", branch = "master", git = "https://github.com/paritytech/substrate", default-features = false, optional = true } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -96,6 +97,7 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "primitives/runtime-benchmarks", "static_assertions", + "sp-application-crypto", ] try-runtime = [ "frame-support/try-runtime", diff --git a/runtime/parachains/src/paras/benchmarking.rs b/runtime/parachains/src/paras/benchmarking.rs index bd9106422d90..9af049372b15 100644 --- a/runtime/parachains/src/paras/benchmarking.rs +++ b/runtime/parachains/src/paras/benchmarking.rs @@ -15,12 +15,16 @@ // along with Polkadot. If not, see . use super::*; -use crate::{configuration::HostConfiguration, shared}; +use crate::configuration::HostConfiguration; use frame_benchmarking::benchmarks; 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}; +mod pvf_check; + +use self::pvf_check::{VoteCause, VoteOutcome}; + // 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 @@ -139,6 +143,48 @@ benchmarks! { let code_hash = [0; 32].into(); }: _(RawOrigin::Root, code_hash) + include_pvf_check_statement { + let (stmt, signature) = pvf_check::prepare_inclusion_bench::(); + }: { + let _ = Pallet::::include_pvf_check_statement(RawOrigin::None.into(), stmt, signature); + } + + include_pvf_check_statement_finalize_upgrade_accept { + let (stmt, signature) = pvf_check::prepare_finalization_bench::( + VoteCause::Upgrade, + VoteOutcome::Accept, + ); + }: { + let _ = Pallet::::include_pvf_check_statement(RawOrigin::None.into(), stmt, signature); + } + + include_pvf_check_statement_finalize_upgrade_reject { + let (stmt, signature) = pvf_check::prepare_finalization_bench::( + VoteCause::Upgrade, + VoteOutcome::Reject, + ); + }: { + let _ = Pallet::::include_pvf_check_statement(RawOrigin::None.into(), stmt, signature); + } + + include_pvf_check_statement_finalize_onboarding_accept { + let (stmt, signature) = pvf_check::prepare_finalization_bench::( + VoteCause::Onboarding, + VoteOutcome::Accept, + ); + }: { + let _ = Pallet::::include_pvf_check_statement(RawOrigin::None.into(), stmt, signature); + } + + include_pvf_check_statement_finalize_onboarding_reject { + let (stmt, signature) = pvf_check::prepare_finalization_bench::( + VoteCause::Onboarding, + VoteOutcome::Reject, + ); + }: { + let _ = Pallet::::include_pvf_check_statement(RawOrigin::None.into(), stmt, signature); + } + impl_benchmark_test_suite!( Pallet, crate::mock::new_test_ext(Default::default()), diff --git a/runtime/parachains/src/paras/benchmarking/pvf_check.rs b/runtime/parachains/src/paras/benchmarking/pvf_check.rs new file mode 100644 index 000000000000..0e1fdd7189ff --- /dev/null +++ b/runtime/parachains/src/paras/benchmarking/pvf_check.rs @@ -0,0 +1,195 @@ +// Copyright 2022 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 . + +//! This module focuses on the benchmarking of the `include_pvf_check_statement` dispatchable. + +use crate::{configuration, paras::*, shared::Pallet as ParasShared}; +use frame_system::RawOrigin; +use primitives::v1::{HeadData, Id as ParaId, ValidationCode, ValidatorId, ValidatorIndex}; +use sp_application_crypto::RuntimeAppPublic; + +// Constants for the benchmarking +const SESSION_INDEX: SessionIndex = 1; +const VALIDATOR_NUM: usize = 800; +const CAUSES_NUM: usize = 100; +fn validation_code() -> ValidationCode { + ValidationCode(vec![0]) +} +fn old_validation_code() -> ValidationCode { + ValidationCode(vec![1]) +} + +/// Prepares the PVF check statement and the validator signature to pass into +/// `include_pvf_check_statement` during benchmarking phase. +/// +/// It won't trigger finalization, so we expect the benchmarking will only measure the performance +/// of only vote accounting. +pub fn prepare_inclusion_bench() -> (PvfCheckStatement, ValidatorSignature) +where + T: Config + shared::Config, +{ + initialize::(); + // we do not plan to trigger finalization, thus the cause is inconsequential. + initialize_pvf_active_vote::(VoteCause::Onboarding); + + // `unwrap` cannot panic here since the `initialize` function should initialize validators count + // to be more than 0. + // + // VoteDirection doesn't matter here as well. + let stmt_n_sig = generate_statements::(VoteOutcome::Accept).next().unwrap(); + + stmt_n_sig +} + +/// Prepares conditions for benchmarking of the finalization part of `include_pvf_check_statement`. +/// +/// This function will initialize a PVF pre-check vote, then submit a number of PVF pre-checking +/// statements so that to achieve the quorum only one statement is left. This statement is returned +/// from this function and is expected to be passed into `include_pvf_check_statement` during the +/// benchmarking phase. +pub fn prepare_finalization_bench( + cause: VoteCause, + outcome: VoteOutcome, +) -> (PvfCheckStatement, ValidatorSignature) +where + T: Config + shared::Config, +{ + initialize::(); + initialize_pvf_active_vote::(cause); + + let mut stmts = generate_statements::(outcome).collect::>(); + // this should be ensured by the `initialize` function. + assert!(stmts.len() > 2); + + // stash the last statement to be used in the benchmarking phase. + let stmt_n_sig = stmts.pop().unwrap(); + + for (stmt, sig) in stmts { + let r = Pallet::::include_pvf_check_statement(RawOrigin::None.into(), stmt, sig); + assert!(r.is_ok()); + } + + stmt_n_sig +} + +/// What caused the PVF pre-checking vote? +#[derive(PartialEq, Eq, Copy, Clone, Debug)] +pub enum VoteCause { + Onboarding, + Upgrade, +} + +/// The outcome of the PVF pre-checking vote. +#[derive(PartialEq, Eq, Copy, Clone, Debug)] +pub enum VoteOutcome { + Accept, + Reject, +} + +fn initialize() +where + T: Config + shared::Config, +{ + // 0. generate a list of validators + let validators = (0..VALIDATOR_NUM) + .map(|_| ::generate_pair(None)) + .collect::>(); + + // 1. Make sure PVF pre-checking is enabled in the config. + let mut config = configuration::Pallet::::config(); + config.pvf_checking_enabled = true; + configuration::Pallet::::force_set_active_config(config.clone()); + + // 2. initialize a new session with deterministic validator set. + ParasShared::::set_active_validators_ascending(validators.clone()); + ParasShared::::set_session_index(SESSION_INDEX); +} + +/// Creates a new PVF pre-checking active vote. +/// +/// The subject of the vote (i.e. validation code) and the cause (upgrade/onboarding) is specified +/// by the test setup. +fn initialize_pvf_active_vote(vote_cause: VoteCause) +where + T: Config + shared::Config, +{ + for i in 0..CAUSES_NUM { + let id = ParaId::from(i as u32); + + if vote_cause == VoteCause::Upgrade { + // we do care about validation code being actually different, since there is a check + // that prevents upgrading to the same code. + let old_validation_code = old_validation_code(); + let validation_code = validation_code(); + + let mut parachains = ParachainsCache::new(); + Pallet::::initialize_para_now( + &mut parachains, + id, + &ParaGenesisArgs { + parachain: true, + genesis_head: HeadData(vec![1, 2, 3, 4]), + validation_code: old_validation_code, + }, + ); + // don't care about performance here, but we do care about robustness. So dump the cache + // asap. + drop(parachains); + + Pallet::::schedule_code_upgrade( + id, + validation_code, + /* relay_parent_number */ 1u32.into(), + &configuration::Pallet::::config(), + ); + } else { + let r = Pallet::::schedule_para_initialize( + id, + ParaGenesisArgs { + parachain: true, + genesis_head: HeadData(vec![1, 2, 3, 4]), + validation_code: validation_code(), + }, + ); + assert!(r.is_ok()); + } + } +} + +/// Generates a list of votes combined with signatures for the active validator set. The number of +/// votes is equal to the minimum number of votes required to reach the supermajority. +fn generate_statements( + vote_outcome: VoteOutcome, +) -> impl Iterator +where + T: Config + shared::Config, +{ + let validators = ParasShared::::active_validator_keys(); + + let required_votes = primitives::v1::supermajority_threshold(validators.len()); + (0..required_votes).map(move |validator_index| { + let stmt = PvfCheckStatement { + accept: vote_outcome == VoteOutcome::Accept, + subject: validation_code().hash(), + session_index: SESSION_INDEX, + + validator_index: ValidatorIndex(validator_index as u32), + }; + let signature = validators[validator_index].sign(&stmt.signing_payload()).unwrap(); + + (stmt, signature) + }) +} diff --git a/runtime/parachains/src/paras/mod.rs b/runtime/parachains/src/paras/mod.rs index 26b70b42bdbf..7e68e0cbaf94 100644 --- a/runtime/parachains/src/paras/mod.rs +++ b/runtime/parachains/src/paras/mod.rs @@ -407,6 +407,12 @@ pub trait WeightInfo { fn force_queue_action() -> Weight; fn add_trusted_validation_code(c: u32) -> Weight; fn poke_unused_validation_code() -> Weight; + + fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight; + fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight; + fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight; + fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight; + fn include_pvf_check_statement() -> Weight; } pub struct TestWeightInfo; @@ -432,6 +438,22 @@ impl WeightInfo for TestWeightInfo { fn poke_unused_validation_code() -> Weight { Weight::MAX } + fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight { + Weight::MAX + } + fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight { + Weight::MAX + } + fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight { + Weight::MAX + } + fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight { + Weight::MAX + } + fn include_pvf_check_statement() -> Weight { + // This special value is to distinguish from the finalizing variants above in tests. + Weight::MAX - 1 + } } #[frame_support::pallet] @@ -858,12 +880,23 @@ pub mod pallet { /// Includes a statement for a PVF pre-checking vote. Potentially, finalizes the vote and /// enacts the results if that was the last vote before achieving the supermajority. - #[pallet::weight(Weight::MAX)] + #[pallet::weight( + sp_std::cmp::max( + sp_std::cmp::max( + ::WeightInfo::include_pvf_check_statement_finalize_upgrade_accept(), + ::WeightInfo::include_pvf_check_statement_finalize_upgrade_reject(), + ), + sp_std::cmp::max( + ::WeightInfo::include_pvf_check_statement_finalize_onboarding_accept(), + ::WeightInfo::include_pvf_check_statement_finalize_onboarding_reject(), + ) + ) + )] pub fn include_pvf_check_statement( origin: OriginFor, stmt: PvfCheckStatement, signature: ValidatorSignature, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { ensure_none(origin)?; // Make sure that PVF pre-checking is enabled. @@ -934,13 +967,17 @@ pub mod pallet { Self::enact_pvf_rejected(&stmt.subject, active_vote.causes); }, } + + // No weight refund since this statement was the last one and lead to finalization. + Ok(().into()) } else { - // No quorum has been achieved. So just store the updated state back into the - // storage. + // No quorum has been achieved. + // + // - So just store the updated state back into the storage. + // - Only charge weight for simple vote inclusion. PvfActiveVoteMap::::insert(&stmt.subject, active_vote); + Ok(Some(::WeightInfo::include_pvf_check_statement()).into()) } - - Ok(()) } } diff --git a/runtime/parachains/src/paras/tests.rs b/runtime/parachains/src/paras/tests.rs index 7f4ac54711c1..c783aebe0892 100644 --- a/runtime/parachains/src/paras/tests.rs +++ b/runtime/parachains/src/paras/tests.rs @@ -1280,7 +1280,8 @@ fn pvf_check_submit_vote() { ::validate_unsigned(TransactionSource::InBlock, &call) .map(|_| ()); let dispatch_result = - Paras::include_pvf_check_statement(None.into(), stmt.clone(), signature.clone()); + Paras::include_pvf_check_statement(None.into(), stmt.clone(), signature.clone()) + .map(|_| ()); (validate_unsigned, dispatch_result) }; @@ -1378,6 +1379,69 @@ fn pvf_check_submit_vote() { }); } +#[test] +fn include_pvf_check_statement_refunds_weight() { + let a = ParaId::from(111); + let old_code: ValidationCode = vec![1, 2, 3].into(); + let new_code: ValidationCode = vec![3, 2, 1].into(); + + let paras = vec![( + a, + ParaGenesisArgs { + parachain: false, + genesis_head: Default::default(), + validation_code: old_code, + }, + )]; + + let genesis_config = MockGenesisConfig { + paras: GenesisConfig { paras, ..Default::default() }, + configuration: crate::configuration::GenesisConfig { + config: HostConfiguration { pvf_checking_enabled: true, ..Default::default() }, + ..Default::default() + }, + ..Default::default() + }; + + new_test_ext(genesis_config).execute_with(|| { + // At this point `a` is already onboarded. Run to block 1 performing session change at + // the end of block #0. + run_to_block(2, Some(vec![1])); + + // Relay parent of the block that schedules the upgrade. + const RELAY_PARENT: BlockNumber = 1; + // Expected current session index. + const EXPECTED_SESSION: SessionIndex = 1; + + Paras::schedule_code_upgrade(a, new_code.clone(), RELAY_PARENT, &Configuration::config()); + + let mut stmts = IntoIterator::into_iter([0, 1, 2, 3]) + .map(|i| { + let stmt = PvfCheckStatement { + accept: true, + subject: new_code.hash(), + session_index: EXPECTED_SESSION, + validator_index: (i as u32).into(), + }; + let sig = VALIDATORS[i].sign(&stmt.signing_payload()); + (stmt, sig) + }) + .collect::>(); + let last_one = stmts.pop().unwrap(); + + // Verify that just vote submission is priced accordingly. + for (stmt, sig) in stmts { + let r = Paras::include_pvf_check_statement(None.into(), stmt, sig.into()).unwrap(); + assert_eq!(r.actual_weight, Some(TestWeightInfo::include_pvf_check_statement())); + } + + // Verify that the last statement is priced maximally. + let (stmt, sig) = last_one; + let r = Paras::include_pvf_check_statement(None.into(), stmt, sig.into()).unwrap(); + assert_eq!(r.actual_weight, None); + }); +} + #[test] fn add_trusted_validation_code_inserts_with_no_users() { // This test is to ensure that trusted validation code is inserted into the storage diff --git a/runtime/parachains/src/shared.rs b/runtime/parachains/src/shared.rs index 7bd33c503c63..1315ebc01f4b 100644 --- a/runtime/parachains/src/shared.rs +++ b/runtime/parachains/src/shared.rs @@ -124,7 +124,7 @@ impl Pallet { CurrentSessionIndex::::set(index); } - #[cfg(test)] + #[cfg(any(feature = "runtime-benchmarks", test))] pub(crate) fn set_active_validators_ascending(active: Vec) { ActiveValidatorIndices::::set( (0..active.len()).map(|i| ValidatorIndex(i as _)).collect(), diff --git a/runtime/polkadot/src/weights/runtime_parachains_paras.rs b/runtime/polkadot/src/weights/runtime_parachains_paras.rs index 1e67b0e9359c..f1f6f30a236d 100644 --- a/runtime/polkadot/src/weights/runtime_parachains_paras.rs +++ b/runtime/polkadot/src/weights/runtime_parachains_paras.rs @@ -110,4 +110,9 @@ impl runtime_parachains::paras::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + fn include_pvf_check_statement_finalize_upgrade_accept() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_upgrade_reject() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_onboarding_accept() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_onboarding_reject() -> u64 { Weight::MAX } + fn include_pvf_check_statement() -> u64 { Weight::MAX } } diff --git a/runtime/rococo/src/weights/runtime_parachains_paras.rs b/runtime/rococo/src/weights/runtime_parachains_paras.rs index 10d0cd013021..82d1ebce79a4 100644 --- a/runtime/rococo/src/weights/runtime_parachains_paras.rs +++ b/runtime/rococo/src/weights/runtime_parachains_paras.rs @@ -110,4 +110,9 @@ impl runtime_parachains::paras::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + fn include_pvf_check_statement_finalize_upgrade_accept() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_upgrade_reject() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_onboarding_accept() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_onboarding_reject() -> u64 { Weight::MAX } + fn include_pvf_check_statement() -> u64 { Weight::MAX } } diff --git a/runtime/westend/src/weights/runtime_parachains_paras.rs b/runtime/westend/src/weights/runtime_parachains_paras.rs index 630f51edc4e5..4224a776c3b1 100644 --- a/runtime/westend/src/weights/runtime_parachains_paras.rs +++ b/runtime/westend/src/weights/runtime_parachains_paras.rs @@ -113,4 +113,9 @@ impl runtime_parachains::paras::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + fn include_pvf_check_statement_finalize_upgrade_accept() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_upgrade_reject() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_onboarding_accept() -> u64 { Weight::MAX } + fn include_pvf_check_statement_finalize_onboarding_reject() -> u64 { Weight::MAX } + fn include_pvf_check_statement() -> u64 { Weight::MAX } } From 608be47f81728517459235e32a6e36238d2577df Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Mon, 21 Feb 2022 14:54:08 +0000 Subject: [PATCH 2/6] cargo run --quiet --profile=production --features=runtime-benchmarks -- benchmark --chain=polkadot-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/polkadot/src/weights/runtime_parachains_paras.rs --- .../src/weights/runtime_parachains_paras.rs | 97 +++++++++++++++---- 1 file changed, 79 insertions(+), 18 deletions(-) diff --git a/runtime/polkadot/src/weights/runtime_parachains_paras.rs b/runtime/polkadot/src/weights/runtime_parachains_paras.rs index f1f6f30a236d..ed4a040d4c18 100644 --- a/runtime/polkadot/src/weights/runtime_parachains_paras.rs +++ b/runtime/polkadot/src/weights/runtime_parachains_paras.rs @@ -16,11 +16,11 @@ //! Autogenerated weights for `runtime_parachains::paras` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-12-29, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 128 +//! DATE: 2022-02-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// target/production/polkadot // benchmark // --chain=polkadot-dev // --steps=50 @@ -45,17 +45,20 @@ 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(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add((2_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 { - (15_314_000 as Weight) + (8_514_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)) @@ -74,23 +77,24 @@ impl runtime_parachains::paras::WeightInfo for WeightIn 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((2_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) } // Storage: Paras FutureCodeUpgrades (r:1 w:0) // Storage: Paras Heads (r:0 w:1) + // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn force_note_new_head(s: u32, ) -> Weight { - (19_183_000 as Weight) + (13_963_000 as Weight) // Standard Error: 0 .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) fn force_queue_action() -> Weight { - (23_668_000 as Weight) + (15_934_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -99,20 +103,77 @@ impl runtime_parachains::paras::WeightInfo for WeightIn fn add_trusted_validation_code(c: u32, ) -> Weight { (0 as Weight) // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((2_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Paras CodeByHashRefs (r:1 w:0) // Storage: Paras CodeByHash (r:0 w:1) fn poke_unused_validation_code() -> Weight { - (4_647_000 as Weight) + (2_406_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - fn include_pvf_check_statement_finalize_upgrade_accept() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_upgrade_reject() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_onboarding_accept() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_onboarding_reject() -> u64 { Weight::MAX } - fn include_pvf_check_statement() -> u64 { Weight::MAX } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + fn include_pvf_check_statement() -> Weight { + (120_016_000 as Weight) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras FutureCodeUpgrades (r:0 w:100) + fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight { + (623_579_000 as Weight) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().writes(104 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras UpgradeGoAheadSignal (r:0 w:100) + // Storage: Paras FutureCodeHash (r:0 w:100) + fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight { + (552_089_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(204 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras ActionsQueue (r:1 w:1) + fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight { + (498_524_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras ParaLifecycles (r:0 w:100) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras CurrentCodeHash (r:0 w:100) + // Storage: Paras UpcomingParasGenesis (r:0 w:100) + fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight { + (611_386_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(304 as Weight)) + } } From c7bf8c4d69a343eb8da722078eed01252beb9693 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Mon, 21 Feb 2022 15:34:36 +0000 Subject: [PATCH 3/6] cargo run --quiet --profile=production --features=runtime-benchmarks -- 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 --- .../src/weights/runtime_parachains_paras.rs | 98 +++++++++++++++---- 1 file changed, 79 insertions(+), 19 deletions(-) diff --git a/runtime/kusama/src/weights/runtime_parachains_paras.rs b/runtime/kusama/src/weights/runtime_parachains_paras.rs index 8586105c546e..f646638c2786 100644 --- a/runtime/kusama/src/weights/runtime_parachains_paras.rs +++ b/runtime/kusama/src/weights/runtime_parachains_paras.rs @@ -16,11 +16,11 @@ //! Autogenerated weights for `runtime_parachains::paras` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-12-28, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128 +//! DATE: 2022-02-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// target/production/polkadot // benchmark // --chain=kusama-dev // --steps=50 @@ -45,17 +45,20 @@ 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(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add((2_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 { - (11_803_000 as Weight) + (10_155_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)) @@ -74,23 +77,24 @@ impl runtime_parachains::paras::WeightInfo for WeightIn 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((2_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) } // Storage: Paras FutureCodeUpgrades (r:1 w:0) // Storage: Paras Heads (r:0 w:1) + // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn force_note_new_head(s: u32, ) -> Weight { - (18_655_000 as Weight) + (15_433_000 as Weight) // Standard Error: 0 .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) fn force_queue_action() -> Weight { - (23_208_000 as Weight) + (16_160_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -99,21 +103,77 @@ impl runtime_parachains::paras::WeightInfo for WeightIn fn add_trusted_validation_code(c: u32, ) -> Weight { (0 as Weight) // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((2_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Paras CodeByHashRefs (r:1 w:0) // Storage: Paras CodeByHash (r:0 w:1) fn poke_unused_validation_code() -> Weight { - (4_639_000 as Weight) + (2_464_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - - fn include_pvf_check_statement_finalize_upgrade_accept() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_upgrade_reject() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_onboarding_accept() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_onboarding_reject() -> u64 { Weight::MAX } - fn include_pvf_check_statement() -> u64 { Weight::MAX } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + fn include_pvf_check_statement() -> Weight { + (117_279_000 as Weight) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras FutureCodeUpgrades (r:0 w:100) + fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight { + (624_849_000 as Weight) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().writes(104 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras UpgradeGoAheadSignal (r:0 w:100) + // Storage: Paras FutureCodeHash (r:0 w:100) + fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight { + (551_320_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(204 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras ActionsQueue (r:1 w:1) + fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight { + (498_904_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras ParaLifecycles (r:0 w:100) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras CurrentCodeHash (r:0 w:100) + // Storage: Paras UpcomingParasGenesis (r:0 w:100) + fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight { + (609_470_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(304 as Weight)) + } } From b15ec6100aa5dd7725bd142f960944fd60d814fb Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Mon, 21 Feb 2022 16:15:48 +0000 Subject: [PATCH 4/6] cargo run --quiet --profile=production --features=runtime-benchmarks -- 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 --- .../src/weights/runtime_parachains_paras.rs | 76 ++++++++++++++++--- 1 file changed, 64 insertions(+), 12 deletions(-) diff --git a/runtime/westend/src/weights/runtime_parachains_paras.rs b/runtime/westend/src/weights/runtime_parachains_paras.rs index 4224a776c3b1..d64471c488c3 100644 --- a/runtime/westend/src/weights/runtime_parachains_paras.rs +++ b/runtime/westend/src/weights/runtime_parachains_paras.rs @@ -16,11 +16,11 @@ //! Autogenerated weights for `runtime_parachains::paras` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-12-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 +//! DATE: 2022-02-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// target/production/polkadot // benchmark // --chain=westend-dev // --steps=50 @@ -58,7 +58,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn } // Storage: Paras Heads (r:0 w:1) fn force_set_current_head(s: u32, ) -> Weight { - (13_711_000 as Weight) + (10_166_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)) @@ -84,7 +84,7 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn force_note_new_head(s: u32, ) -> Weight { - (18_543_000 as Weight) + (15_413_000 as Weight) // Standard Error: 0 .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) @@ -93,7 +93,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 { - (22_153_000 as Weight) + (15_999_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -109,13 +109,65 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras CodeByHashRefs (r:1 w:0) // Storage: Paras CodeByHash (r:0 w:1) fn poke_unused_validation_code() -> Weight { - (4_207_000 as Weight) + (2_445_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - fn include_pvf_check_statement_finalize_upgrade_accept() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_upgrade_reject() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_onboarding_accept() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_onboarding_reject() -> u64 { Weight::MAX } - fn include_pvf_check_statement() -> u64 { Weight::MAX } + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + fn include_pvf_check_statement() -> Weight { + (116_591_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras FutureCodeUpgrades (r:0 w:100) + fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight { + (622_057_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(104 as Weight)) + } + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras UpgradeGoAheadSignal (r:0 w:100) + // Storage: Paras FutureCodeHash (r:0 w:100) + fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight { + (550_573_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(204 as Weight)) + } + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras ActionsQueue (r:1 w:1) + fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight { + (499_580_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras ParaLifecycles (r:0 w:100) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras CurrentCodeHash (r:0 w:100) + // Storage: Paras UpcomingParasGenesis (r:0 w:100) + fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight { + (602_317_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(304 as Weight)) + } } From be6b1da31f3d8eb5621e3ad3b305fa7d9d233b49 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Mon, 21 Feb 2022 16:56:02 +0000 Subject: [PATCH 5/6] cargo run --quiet --profile=production --features runtime-benchmarks -- benchmark --chain=rococo-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/rococo/src/weights/runtime_parachains_paras.rs --- .../src/weights/runtime_parachains_paras.rs | 97 +++++++++++++++---- 1 file changed, 79 insertions(+), 18 deletions(-) diff --git a/runtime/rococo/src/weights/runtime_parachains_paras.rs b/runtime/rococo/src/weights/runtime_parachains_paras.rs index 82d1ebce79a4..6f6b6943a14f 100644 --- a/runtime/rococo/src/weights/runtime_parachains_paras.rs +++ b/runtime/rococo/src/weights/runtime_parachains_paras.rs @@ -16,11 +16,11 @@ //! Autogenerated weights for `runtime_parachains::paras` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-12-29, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 128 +//! DATE: 2022-02-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// target/production/polkadot // benchmark // --chain=rococo-dev // --steps=50 @@ -45,17 +45,20 @@ 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(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add((2_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 { - (14_013_000 as Weight) + (10_856_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)) @@ -74,23 +77,24 @@ impl runtime_parachains::paras::WeightInfo for WeightIn 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((2_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) } // Storage: Paras FutureCodeUpgrades (r:1 w:0) // Storage: Paras Heads (r:0 w:1) + // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn force_note_new_head(s: u32, ) -> Weight { - (17_583_000 as Weight) + (13_762_000 as Weight) // Standard Error: 0 .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) fn force_queue_action() -> Weight { - (23_310_000 as Weight) + (15_946_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -99,20 +103,77 @@ impl runtime_parachains::paras::WeightInfo for WeightIn fn add_trusted_validation_code(c: u32, ) -> Weight { (0 as Weight) // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((2_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Paras CodeByHashRefs (r:1 w:0) // Storage: Paras CodeByHash (r:0 w:1) fn poke_unused_validation_code() -> Weight { - (4_372_000 as Weight) + (2_509_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - fn include_pvf_check_statement_finalize_upgrade_accept() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_upgrade_reject() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_onboarding_accept() -> u64 { Weight::MAX } - fn include_pvf_check_statement_finalize_onboarding_reject() -> u64 { Weight::MAX } - fn include_pvf_check_statement() -> u64 { Weight::MAX } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + fn include_pvf_check_statement() -> Weight { + (117_675_000 as Weight) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras FutureCodeUpgrades (r:0 w:100) + fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight { + (618_769_000 as Weight) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().writes(104 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras UpgradeGoAheadSignal (r:0 w:100) + // Storage: Paras FutureCodeHash (r:0 w:100) + fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight { + (553_319_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(204 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras ActionsQueue (r:1 w:1) + fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight { + (507_519_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) + // Storage: Paras PvfActiveVoteMap (r:1 w:1) + // Storage: Paras PvfActiveVoteList (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras ParaLifecycles (r:0 w:100) + // Storage: Paras CodeByHash (r:0 w:1) + // Storage: Paras CurrentCodeHash (r:0 w:100) + // Storage: Paras UpcomingParasGenesis (r:0 w:100) + fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight { + (609_820_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(304 as Weight)) + } } From a1e6ebfa5c7d5900d0901b586282e641589a3811 Mon Sep 17 00:00:00 2001 From: Lldenaurois Date: Wed, 23 Mar 2022 18:01:22 +0100 Subject: [PATCH 6/6] Fix import error --- runtime/parachains/src/paras/benchmarking/pvf_check.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/parachains/src/paras/benchmarking/pvf_check.rs b/runtime/parachains/src/paras/benchmarking/pvf_check.rs index 0e1fdd7189ff..a89315c2857b 100644 --- a/runtime/parachains/src/paras/benchmarking/pvf_check.rs +++ b/runtime/parachains/src/paras/benchmarking/pvf_check.rs @@ -18,7 +18,7 @@ use crate::{configuration, paras::*, shared::Pallet as ParasShared}; use frame_system::RawOrigin; -use primitives::v1::{HeadData, Id as ParaId, ValidationCode, ValidatorId, ValidatorIndex}; +use primitives::v2::{HeadData, Id as ParaId, ValidationCode, ValidatorId, ValidatorIndex}; use sp_application_crypto::RuntimeAppPublic; // Constants for the benchmarking @@ -179,7 +179,7 @@ where { let validators = ParasShared::::active_validator_keys(); - let required_votes = primitives::v1::supermajority_threshold(validators.len()); + let required_votes = primitives::v2::supermajority_threshold(validators.len()); (0..required_votes).map(move |validator_index| { let stmt = PvfCheckStatement { accept: vote_outcome == VoteOutcome::Accept,