Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

paras: include_pvf_check_statement rt bench #4938

Merged
merged 8 commits into from
Mar 24, 2022
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 79 additions & 13 deletions runtime/kusama/src/weights/runtime_parachains_paras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,17 +45,20 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_parachains::paras::WeightInfo for WeightInfo<T> {
// 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))
Expand All @@ -74,23 +77,24 @@ impl<T: frame_system::Config> 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))
}
Expand All @@ -99,15 +103,77 @@ impl<T: frame_system::Config> 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))
}
// 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))
}
}
2 changes: 2 additions & 0 deletions runtime/parachains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -96,6 +97,7 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"primitives/runtime-benchmarks",
"static_assertions",
"sp-application-crypto",
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
48 changes: 47 additions & 1 deletion runtime/parachains/src/paras/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

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
Expand Down Expand Up @@ -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::<T>();
}: {
let _ = Pallet::<T>::include_pvf_check_statement(RawOrigin::None.into(), stmt, signature);
}

include_pvf_check_statement_finalize_upgrade_accept {
let (stmt, signature) = pvf_check::prepare_finalization_bench::<T>(
VoteCause::Upgrade,
VoteOutcome::Accept,
);
}: {
let _ = Pallet::<T>::include_pvf_check_statement(RawOrigin::None.into(), stmt, signature);
}

include_pvf_check_statement_finalize_upgrade_reject {
let (stmt, signature) = pvf_check::prepare_finalization_bench::<T>(
VoteCause::Upgrade,
VoteOutcome::Reject,
);
}: {
let _ = Pallet::<T>::include_pvf_check_statement(RawOrigin::None.into(), stmt, signature);
}

include_pvf_check_statement_finalize_onboarding_accept {
let (stmt, signature) = pvf_check::prepare_finalization_bench::<T>(
VoteCause::Onboarding,
VoteOutcome::Accept,
);
}: {
let _ = Pallet::<T>::include_pvf_check_statement(RawOrigin::None.into(), stmt, signature);
}

include_pvf_check_statement_finalize_onboarding_reject {
let (stmt, signature) = pvf_check::prepare_finalization_bench::<T>(
VoteCause::Onboarding,
VoteOutcome::Reject,
);
}: {
let _ = Pallet::<T>::include_pvf_check_statement(RawOrigin::None.into(), stmt, signature);
}

impl_benchmark_test_suite!(
Pallet,
crate::mock::new_test_ext(Default::default()),
Expand Down
Loading