From 9606ae6fc24e8d12627df4ebed155dded300b855 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Mon, 31 Jan 2022 18:15:45 +0100 Subject: [PATCH] fix: Preimage registrar and Scheduler integration Scheduler: https://github.com/paritytech/substrate/pull/10356 OriginPriviligeCmp: https://github.com/paritytech/polkadot/pull/4166 --- Cargo.lock | 2 + runtimes/peregrine/Cargo.toml | 3 + runtimes/peregrine/src/lib.rs | 94 +++++++++++- .../peregrine/src/weights/pallet_preimage.rs | 134 ++++++++++++++++++ runtimes/spiritnet/Cargo.toml | 4 + runtimes/spiritnet/src/lib.rs | 94 +++++++++++- .../spiritnet/src/weights/pallet_preimage.rs | 134 ++++++++++++++++++ 7 files changed, 451 insertions(+), 14 deletions(-) create mode 100644 runtimes/peregrine/src/weights/pallet_preimage.rs create mode 100644 runtimes/spiritnet/src/weights/pallet_preimage.rs diff --git a/Cargo.lock b/Cargo.lock index 4f8f026fb..77195f438 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6589,6 +6589,7 @@ dependencies = [ "pallet-indices", "pallet-inflation", "pallet-membership", + "pallet-preimage", "pallet-randomness-collective-flip", "pallet-scheduler", "pallet-session", @@ -10868,6 +10869,7 @@ dependencies = [ "pallet-indices", "pallet-inflation", "pallet-membership", + "pallet-preimage", "pallet-randomness-collective-flip", "pallet-scheduler", "pallet-session", diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index 9e5d274da..86ffb8a2f 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -59,6 +59,7 @@ pallet-collective = {git = "https://github.com/paritytech/substrate", default-fe pallet-democracy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} pallet-indices = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} +pallet-preimage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} pallet-randomness-collective-flip = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} @@ -117,6 +118,7 @@ runtime-benchmarks = [ "pallet-indices/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", "pallet-membership/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", @@ -156,6 +158,7 @@ std = [ "pallet-indices/std", "pallet-inflation/std", "pallet-membership/std", + "pallet-preimage/try-runtime", "pallet-randomness-collective-flip/std", "pallet-scheduler/std", "pallet-session/std", diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 0f8241f73..f1a4591a7 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -27,10 +27,10 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use frame_support::{ construct_runtime, parameter_types, - traits::EqualPrivilegeOnly, + traits::{EnsureOneOf, EqualPrivilegeOnly, OnRuntimeUpgrade}, weights::{constants::RocksDbWeight, Weight}, }; -use frame_system::{EnsureOneOf, EnsureRoot}; +use frame_system::EnsureRoot; use sp_api::impl_runtime_apis; use sp_core::{ u32_trait::{_1, _2, _3, _5}, @@ -42,7 +42,7 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, Perbill, Permill, Perquintill, }; -use sp_std::prelude::*; +use sp_std::{cmp::Ordering, prelude::*}; use sp_version::RuntimeVersion; use runtime_common::{ @@ -288,9 +288,55 @@ impl kilt_launch::Config for Runtime { type PalletId = pallet_id::Launch; } +parameter_types! { + pub const PreimageMaxSize: u32 = 4096 * 1024; + // FIXME: Handle together with other deposits + pub const PreimageBaseDeposit: Balance = KILT; + pub const PreimageByteDeposit: Balance = KILT; +} + +impl pallet_preimage::Config for Runtime { + type WeightInfo = weights::pallet_preimage::WeightInfo; + type Event = Event; + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type MaxSize = PreimageMaxSize; + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; +} + parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; pub const MaxScheduledPerBlock: u32 = 50; + pub const NoPreimagePostponement: Option = Some(10); +} + +type ScheduleOrigin = EnsureOneOf< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>, +>; + +/// Used the compare the privilege of an origin inside the scheduler. +pub struct OriginPrivilegeCmp; + +impl PrivilegeCmp for OriginPrivilegeCmp { + fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option { + if left == right { + return Some(Ordering::Equal); + } + + match (left, right) { + // Root is greater than anything. + (OriginCaller::system(frame_system::RawOrigin::Root), _) => Some(Ordering::Greater), + // Check which one has more yes votes. + ( + OriginCaller::Council(pallet_collective::RawOrigin::Members(l_yes_votes, l_count)), + OriginCaller::Council(pallet_collective::RawOrigin::Members(r_yes_votes, r_count)), + ) => Some((l_yes_votes * r_count).cmp(&(r_yes_votes * l_count))), + // For every other origin we don't care, as they are not used for `ScheduleOrigin`. + _ => None, + } + } } impl pallet_scheduler::Config for Runtime { @@ -299,10 +345,12 @@ impl pallet_scheduler::Config for Runtime { type PalletsOrigin = OriginCaller; type Call = Call; type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureRoot; + type ScheduleOrigin = ScheduleOrigin; type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = weights::pallet_scheduler::WeightInfo; - type OriginPrivilegeCmp = EqualPrivilegeOnly; + type OriginPrivilegeCmp = OriginPrivilegeCmp; + type PreimageProvider = Preimage; + type NoPreimagePostponement = NoPreimagePostponement; } parameter_types! { @@ -727,6 +775,11 @@ construct_runtime! { // System scheduler. Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 42, + // Proxy pallet = 43 + + // Preimage registrar + Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, + // KILT Pallets. Start indices 60 to leave room KiltLaunch: kilt_launch = 60, Ctype: ctype = 61, @@ -813,8 +866,33 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. -pub type Executive = - frame_executive::Executive, Runtime, AllPalletsWithSystem>; +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, + SchedulerMigrationV3, +>; + +// Migration for scheduler pallet to move from a plain Call to a CallOrHash. +pub struct SchedulerMigrationV3; + +impl OnRuntimeUpgrade for SchedulerMigrationV3 { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + Scheduler::migrate_v2_to_v3() + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + Scheduler::pre_migrate_to_v3() + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + Scheduler::post_migrate_to_v3() + } +} impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -943,6 +1021,7 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_democracy, Democracy); list_benchmark!(list, extra, pallet_indices, Indices); list_benchmark!(list, extra, pallet_membership, TechnicalMembership); + list_benchmark!(list, extra, pallet_preimage, Preimage); list_benchmark!(list, extra, pallet_scheduler, Scheduler); list_benchmark!(list, extra, pallet_timestamp, Timestamp); list_benchmark!(list, extra, pallet_treasury, Treasury); @@ -1006,6 +1085,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_democracy, Democracy); add_benchmark!(params, batches, pallet_indices, Indices); add_benchmark!(params, batches, pallet_membership, TechnicalMembership); + add_benchmark!(params, batches, pallet_preimage, Preimage); add_benchmark!(params, batches, pallet_scheduler, Scheduler); add_benchmark!(params, batches, pallet_session, SessionBench::); add_benchmark!(params, batches, frame_system, SystemBench::); diff --git a/runtimes/peregrine/src/weights/pallet_preimage.rs b/runtimes/peregrine/src/weights/pallet_preimage.rs new file mode 100644 index 000000000..cfb61a15c --- /dev/null +++ b/runtimes/peregrine/src/weights/pallet_preimage.rs @@ -0,0 +1,134 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2022 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_preimage` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-01-29, 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 +// benchmark +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_preimage +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/pallet_preimage.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_preimage`. +pub struct WeightInfo(PhantomData); +impl pallet_preimage::WeightInfo for WeightInfo { + // Storage: Preimage PreimageFor (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + fn note_preimage(s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Preimage PreimageFor (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:0) + fn note_requested_preimage(s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage PreimageFor (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:0) + fn note_no_deposit_preimage(s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unnote_preimage() -> Weight { + (53_005_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unnote_no_deposit_preimage() -> Weight { + (34_770_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_preimage() -> Weight { + (49_075_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_no_deposit_preimage() -> Weight { + (32_039_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_unnoted_preimage() -> Weight { + (19_571_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_requested_preimage() -> Weight { + (6_704_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unrequest_preimage() -> Weight { + (34_923_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unrequest_unnoted_preimage() -> Weight { + (19_088_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn unrequest_multi_referenced_preimage() -> Weight { + (6_633_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/runtimes/spiritnet/Cargo.toml b/runtimes/spiritnet/Cargo.toml index ec1bb40ca..64b055e17 100644 --- a/runtimes/spiritnet/Cargo.toml +++ b/runtimes/spiritnet/Cargo.toml @@ -59,6 +59,7 @@ pallet-collective = {git = "https://github.com/paritytech/substrate", default-fe pallet-democracy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} pallet-indices = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} +pallet-preimage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} pallet-randomness-collective-flip = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16"} @@ -116,6 +117,7 @@ runtime-benchmarks = [ "pallet-indices/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", "pallet-membership/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", @@ -155,6 +157,7 @@ std = [ "pallet-indices/std", "pallet-inflation/std", "pallet-membership/std", + "pallet-preimage/std", "pallet-randomness-collective-flip/std", "pallet-scheduler/std", "pallet-session/std", @@ -203,6 +206,7 @@ try-runtime = [ "pallet-democracy/try-runtime", "pallet-indices/try-runtime", "pallet-membership/try-runtime", + "pallet-preimage/try-runtime", "pallet-randomness-collective-flip/try-runtime", "pallet-scheduler/try-runtime", "pallet-session/try-runtime", diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 248320e0b..284d7b87b 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -27,10 +27,10 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use frame_support::{ construct_runtime, parameter_types, - traits::{Contains, EqualPrivilegeOnly}, + traits::{Contains, EnsureOneOf, OnRuntimeUpgrade}, weights::{constants::RocksDbWeight, Weight}, }; -use frame_system::{EnsureOneOf, EnsureRoot}; +use frame_system::EnsureRoot; use sp_api::impl_runtime_apis; use sp_core::{ u32_trait::{_1, _2, _3, _5}, @@ -42,7 +42,7 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, Perbill, Permill, Perquintill, }; -use sp_std::prelude::*; +use sp_std::{cmp::Ordering, prelude::*}; use sp_version::RuntimeVersion; use runtime_common::{ @@ -293,9 +293,55 @@ impl kilt_launch::Config for Runtime { type PalletId = pallet_id::Launch; } +parameter_types! { + pub const PreimageMaxSize: u32 = 4096 * 1024; + // FIXME: Handle together with other deposits + pub const PreimageBaseDeposit: Balance = KILT; + pub const PreimageByteDeposit: Balance = KILT; +} + +impl pallet_preimage::Config for Runtime { + type WeightInfo = weights::pallet_preimage::WeightInfo; + type Event = Event; + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type MaxSize = PreimageMaxSize; + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; +} + parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; pub const MaxScheduledPerBlock: u32 = 50; + pub const NoPreimagePostponement: Option = Some(10); +} + +type ScheduleOrigin = EnsureOneOf< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>, +>; + +/// Used the compare the privilege of an origin inside the scheduler. +pub struct OriginPrivilegeCmp; + +impl PrivilegeCmp for OriginPrivilegeCmp { + fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option { + if left == right { + return Some(Ordering::Equal); + } + + match (left, right) { + // Root is greater than anything. + (OriginCaller::system(frame_system::RawOrigin::Root), _) => Some(Ordering::Greater), + // Check which one has more yes votes. + ( + OriginCaller::Council(pallet_collective::RawOrigin::Members(l_yes_votes, l_count)), + OriginCaller::Council(pallet_collective::RawOrigin::Members(r_yes_votes, r_count)), + ) => Some((l_yes_votes * r_count).cmp(&(r_yes_votes * l_count))), + // For every other origin we don't care, as they are not used for `ScheduleOrigin`. + _ => None, + } + } } impl pallet_scheduler::Config for Runtime { @@ -304,10 +350,12 @@ impl pallet_scheduler::Config for Runtime { type PalletsOrigin = OriginCaller; type Call = Call; type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureRoot; + type ScheduleOrigin = ScheduleOrigin; type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = weights::pallet_scheduler::WeightInfo; - type OriginPrivilegeCmp = EqualPrivilegeOnly; + type OriginPrivilegeCmp = OriginPrivilegeCmp; + type PreimageProvider = Preimage; + type NoPreimagePostponement = NoPreimagePostponement; } parameter_types! { @@ -731,6 +779,11 @@ construct_runtime! { // System scheduler. Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 42, + // Proxy pallet = 43 + + // Preimage registrar + Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, + // KILT Pallets. Start indices 60 to leave room KiltLaunch: kilt_launch = 60, Ctype: ctype = 61, @@ -817,8 +870,33 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. -pub type Executive = - frame_executive::Executive, Runtime, AllPalletsWithSystem>; +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, + SchedulerMigrationV3, +>; + +// Migration for scheduler pallet to move from a plain Call to a CallOrHash. +pub struct SchedulerMigrationV3; + +impl OnRuntimeUpgrade for SchedulerMigrationV3 { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + Scheduler::migrate_v2_to_v3() + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + Scheduler::pre_migrate_to_v3() + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + Scheduler::post_migrate_to_v3() + } +} impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -947,6 +1025,7 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_democracy, Democracy); list_benchmark!(list, extra, pallet_indices, Indices); list_benchmark!(list, extra, pallet_membership, TechnicalMembership); + list_benchmark!(list, extra, pallet_preimage, Preimage); list_benchmark!(list, extra, pallet_scheduler, Scheduler); list_benchmark!(list, extra, pallet_timestamp, Timestamp); list_benchmark!(list, extra, pallet_treasury, Treasury); @@ -1010,6 +1089,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_democracy, Democracy); add_benchmark!(params, batches, pallet_indices, Indices); add_benchmark!(params, batches, pallet_membership, TechnicalMembership); + add_benchmark!(params, batches, pallet_preimage, Preimage); add_benchmark!(params, batches, pallet_scheduler, Scheduler); add_benchmark!(params, batches, pallet_session, SessionBench::); add_benchmark!(params, batches, frame_system, SystemBench::); diff --git a/runtimes/spiritnet/src/weights/pallet_preimage.rs b/runtimes/spiritnet/src/weights/pallet_preimage.rs new file mode 100644 index 000000000..cfb61a15c --- /dev/null +++ b/runtimes/spiritnet/src/weights/pallet_preimage.rs @@ -0,0 +1,134 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2022 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_preimage` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-01-29, 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 +// benchmark +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_preimage +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/pallet_preimage.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_preimage`. +pub struct WeightInfo(PhantomData); +impl pallet_preimage::WeightInfo for WeightInfo { + // Storage: Preimage PreimageFor (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + fn note_preimage(s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Preimage PreimageFor (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:0) + fn note_requested_preimage(s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage PreimageFor (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:0) + fn note_no_deposit_preimage(s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 0 + .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unnote_preimage() -> Weight { + (53_005_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unnote_no_deposit_preimage() -> Weight { + (34_770_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_preimage() -> Weight { + (49_075_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_no_deposit_preimage() -> Weight { + (32_039_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_unnoted_preimage() -> Weight { + (19_571_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_requested_preimage() -> Weight { + (6_704_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unrequest_preimage() -> Weight { + (34_923_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unrequest_unnoted_preimage() -> Weight { + (19_088_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn unrequest_multi_referenced_preimage() -> Weight { + (6_633_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +}