diff --git a/.maintain/frame-weight-template.hbs b/.maintain/frame-weight-template.hbs index 593da06f4a7c0..c6df85194ac99 100644 --- a/.maintain/frame-weight-template.hbs +++ b/.maintain/frame-weight-template.hbs @@ -31,7 +31,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for {{pallet}}. @@ -64,22 +64,22 @@ impl WeightInfo for SubstrateWeight { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - ({{underscore benchmark.base_weight}} as Weight) + Weight::from_ref_time({{underscore benchmark.base_weight}} as RefTimeWeight) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + .saturating_add(Weight::from_ref_time({{underscore cw.slope}} as RefTimeWeight).scalar_saturating_mul({{cw.name}} as RefTimeWeight)) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as RefTimeWeight)) {{/if}} {{#each benchmark.component_reads as |cr|}} - .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as RefTimeWeight).saturating_mul({{cr.name}} as RefTimeWeight))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight)) + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as RefTimeWeight)) {{/if}} {{#each benchmark.component_writes as |cw|}} - .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as RefTimeWeight).saturating_mul({{cw.name}} as RefTimeWeight))) {{/each}} } {{/each}} @@ -99,22 +99,22 @@ impl WeightInfo for () { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - ({{underscore benchmark.base_weight}} as Weight) + Weight::from_ref_time({{underscore benchmark.base_weight}} as RefTimeWeight) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + .saturating_add(Weight::from_ref_time({{underscore cw.slope}} as RefTimeWeight).scalar_saturating_mul({{cw.name}} as RefTimeWeight)) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}} as Weight)) + .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}} as RefTimeWeight)) {{/if}} {{#each benchmark.component_reads as |cr|}} - .saturating_add(RocksDbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + .saturating_add(RocksDbWeight::get().reads(({{cr.slope}} as RefTimeWeight).saturating_mul({{cr.name}} as RefTimeWeight))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}} as Weight)) + .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}} as RefTimeWeight)) {{/if}} {{#each benchmark.component_writes as |cw|}} - .saturating_add(RocksDbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + .saturating_add(RocksDbWeight::get().writes(({{cw.slope}} as RefTimeWeight).saturating_mul({{cw.name}} as RefTimeWeight))) {{/each}} } {{/each}} diff --git a/bin/node-template/pallets/template/src/lib.rs b/bin/node-template/pallets/template/src/lib.rs index f1519efe062bd..a9209a9040b6d 100644 --- a/bin/node-template/pallets/template/src/lib.rs +++ b/bin/node-template/pallets/template/src/lib.rs @@ -64,7 +64,7 @@ pub mod pallet { impl Pallet { /// An example dispatchable that takes a singles value as a parameter, writes the value to /// storage and emits an event. This function must be dispatched by a signed extrinsic. - #[pallet::weight(10_000 + T::DbWeight::get().writes(1))] + #[pallet::weight(10_000 + T::DbWeight::get().writes(1).ref_time())] pub fn do_something(origin: OriginFor, something: u32) -> DispatchResult { // Check that the extrinsic was signed and get the signer. // This function will return an error if the extrinsic is not signed. @@ -81,7 +81,7 @@ pub mod pallet { } /// An example dispatchable that may throw a custom error. - #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))] + #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1).ref_time())] pub fn cause_error(origin: OriginFor) -> DispatchResult { let _who = ensure_signed(origin)?; diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index 468b9c8ac4c1b..3426df5872c35 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -18,7 +18,7 @@ use codec::{Decode, Encode, Joiner}; use frame_support::{ traits::Currency, - weights::{DispatchClass, DispatchInfo, GetDispatchInfo}, + weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Weight}, }; use frame_system::{self, AccountInfo, EventRecord, Phase}; use sp_core::{storage::well_known_keys, traits::Externalities, NeverNativeValue}; @@ -733,7 +733,7 @@ fn deploying_wasm_contract_should_work() { function: Call::Contracts( pallet_contracts::Call::instantiate_with_code:: { value: 0, - gas_limit: 500_000_000, + gas_limit: Weight::from_ref_time(500_000_000), storage_deposit_limit: None, code: transfer_code, data: Vec::new(), @@ -746,7 +746,7 @@ fn deploying_wasm_contract_should_work() { function: Call::Contracts(pallet_contracts::Call::call:: { dest: sp_runtime::MultiAddress::Id(addr.clone()), value: 10, - gas_limit: 500_000_000, + gas_limit: Weight::from_ref_time(500_000_000), storage_deposit_limit: None, data: vec![0x00, 0x01, 0x02, 0x03], }), diff --git a/bin/node/executor/tests/fees.rs b/bin/node/executor/tests/fees.rs index 296d1d8e28798..dd1318254d9b7 100644 --- a/bin/node/executor/tests/fees.rs +++ b/bin/node/executor/tests/fees.rs @@ -208,7 +208,7 @@ fn transaction_fee_is_correct() { // we know that weight to fee multiplier is effect-less in block 1. // current weight of transfer = 200_000_000 // Linear weight to fee is 1:1 right now (1 weight = 1 unit of balance) - assert_eq!(weight_fee, weight as Balance); + assert_eq!(weight_fee, weight.ref_time() as Balance); balance_alice -= base_fee; balance_alice -= weight_fee; balance_alice -= tip; diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index eaf872d6f3fec..510955a5b7b3e 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -163,13 +163,13 @@ mod multiplier_tests { let previous_float = previous_float.max(min_multiplier().into_inner() as f64 / accuracy); // maximum tx weight - let m = max_normal() as f64; + let m = max_normal().ref_time() as f64; // block weight always truncated to max weight - let block_weight = (block_weight as f64).min(m); + let block_weight = (block_weight.ref_time() as f64).min(m); let v: f64 = AdjustmentVariable::get().to_float(); // Ideal saturation in terms of weight - let ss = target() as f64; + let ss = target().ref_time() as f64; // Current saturation in terms of weight let s = block_weight; @@ -197,9 +197,9 @@ mod multiplier_tests { fn truth_value_update_poc_works() { let fm = Multiplier::saturating_from_rational(1, 2); let test_set = vec![ - (0, fm), - (100, fm), - (1000, fm), + (Weight::zero(), fm), + (Weight::from_ref_time(100), fm), + (Weight::from_ref_time(1000), fm), (target(), fm), (max_normal() / 2, fm), (max_normal(), fm), @@ -229,7 +229,7 @@ mod multiplier_tests { #[test] fn multiplier_cannot_go_below_limit() { // will not go any further below even if block is empty. - run_with_system_weight(0, || { + run_with_system_weight(Weight::new(), || { let next = runtime_multiplier_update(min_multiplier()); assert_eq!(next, min_multiplier()); }) @@ -247,7 +247,7 @@ mod multiplier_tests { // 1 < 0.00001 * k * 0.1875 // 10^9 / 1875 < k // k > 533_333 ~ 18,5 days. - run_with_system_weight(0, || { + run_with_system_weight(Weight::new(), || { // start from 1, the default. let mut fm = Multiplier::one(); let mut iterations: u64 = 0; @@ -283,7 +283,8 @@ mod multiplier_tests { // `cargo test congested_chain_simulation -- --nocapture` to get some insight. // almost full. The entire quota of normal transactions is taken. - let block_weight = BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap() - 100; + let block_weight = BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap() - + Weight::from_ref_time(100); // Default substrate weight. let tx_weight = frame_support::weights::constants::ExtrinsicBaseWeight::get(); @@ -407,27 +408,27 @@ mod multiplier_tests { #[test] fn weight_to_fee_should_not_overflow_on_large_weights() { - let kb = 1024 as Weight; + let kb = Weight::from_ref_time(1024); let mb = kb * kb; let max_fm = Multiplier::saturating_from_integer(i128::MAX); // check that for all values it can compute, correctly. vec![ - 0, - 1, - 10, - 1000, + Weight::zero(), + Weight::one(), + Weight::from_ref_time(10), + Weight::from_ref_time(1000), kb, 10 * kb, 100 * kb, mb, 10 * mb, - 2147483647, - 4294967295, + Weight::from_ref_time(2147483647), + Weight::from_ref_time(4294967295), BlockWeights::get().max_block / 2, BlockWeights::get().max_block, - Weight::max_value() / 2, - Weight::max_value(), + Weight::MAX / 2, + Weight::MAX, ] .into_iter() .for_each(|i| { @@ -440,7 +441,7 @@ mod multiplier_tests { // Some values that are all above the target and will cause an increase. let t = target(); - vec![t + 100, t * 2, t * 4].into_iter().for_each(|i| { + vec![t + Weight::from_ref_time(100), t * 2, t * 4].into_iter().for_each(|i| { run_with_system_weight(i, || { let fm = runtime_multiplier_update(max_fm); // won't grow. The convert saturates everything. diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index f8ea312d1a496..5d4a21cea09b2 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -170,7 +170,7 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); /// by Operational extrinsics. const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); /// We allow for 2 seconds of compute with a 6 second average block time. -const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND; +const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.scalar_saturating_mul(2); parameter_types! { pub const BlockHashCount: BlockNumber = 2400; @@ -1936,7 +1936,7 @@ impl_runtime_apis! { storage_deposit_limit: Option, input_data: Vec, ) -> pallet_contracts_primitives::ContractExecResult { - Contracts::bare_call(origin, dest, value, gas_limit, storage_deposit_limit, input_data, true) + Contracts::bare_call(origin, dest, value, Weight::from_ref_time(gas_limit), storage_deposit_limit, input_data, true) } fn instantiate( @@ -1949,7 +1949,7 @@ impl_runtime_apis! { salt: Vec, ) -> pallet_contracts_primitives::ContractInstantiateResult { - Contracts::bare_instantiate(origin, value, gas_limit, storage_deposit_limit, code, data, salt, true) + Contracts::bare_instantiate(origin, value, Weight::from_ref_time(gas_limit), storage_deposit_limit, code, data, salt, true) } fn upload_code( diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index 25dcb18b175ef..33cf933aba421 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -332,7 +332,7 @@ benchmarks_instance_pallet! { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); - }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::max_value(), bytes_in_storage) + }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. assert_eq!(T::ProposalProvider::proposal_of(last_hash), None); @@ -417,7 +417,7 @@ benchmarks_instance_pallet! { index, true, )?; - }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::max_value(), bytes_in_storage) + }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. assert_eq!(T::ProposalProvider::proposal_of(last_hash), None); @@ -489,7 +489,7 @@ benchmarks_instance_pallet! { System::::set_block_number(T::BlockNumber::max_value()); - }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::max_value(), bytes_in_storage) + }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. assert_eq!(T::ProposalProvider::proposal_of(last_hash), None); @@ -562,7 +562,7 @@ benchmarks_instance_pallet! { // caller is prime, prime already votes aye by creating the proposal System::::set_block_number(T::BlockNumber::max_value()); - }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::max_value(), bytes_in_storage) + }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. assert_eq!(T::ProposalProvider::proposal_of(last_hash), None); diff --git a/frame/alliance/src/migration.rs b/frame/alliance/src/migration.rs index cd54eed7a9a75..010603902f0fd 100644 --- a/frame/alliance/src/migration.rs +++ b/frame/alliance/src/migration.rs @@ -25,7 +25,7 @@ pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); /// Wrapper for all migrations of this pallet. pub fn migrate, I: 'static>() -> Weight { let onchain_version = Pallet::::on_chain_storage_version(); - let mut weight: Weight = 0; + let mut weight: Weight = Weight::new(); if onchain_version < 1 { weight = weight.saturating_add(v0_to_v1::migrate::()); diff --git a/frame/alliance/src/weights.rs b/frame/alliance/src/weights.rs index aa9ebde528683..048bea3d1e5a4 100644 --- a/frame/alliance/src/weights.rs +++ b/frame/alliance/src/weights.rs @@ -41,7 +41,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_alliance. @@ -80,30 +80,30 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[0, 90]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (22_575_000 as Weight) + Weight::from_ref_time(22_575_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((11_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(11_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 23_000 - .saturating_add((158_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(158_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((90_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(90_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((216_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(216_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Alliance Members (r:2 w:0) // Storage: AllianceMotion Voting (r:1 w:1) /// The range of component `x` is `[3, 10]`. /// The range of component `y` is `[2, 90]`. fn vote(x: u32, y: u32, ) -> Weight { - (45_486_000 as Weight) + Weight::from_ref_time(45_486_000 as RefTimeWeight) // Standard Error: 29_000 - .saturating_add((78_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(78_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((128_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(128_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion ProposalOf (r:1 w:1) @@ -111,11 +111,11 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Voting (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn veto(p: u32, ) -> Weight { - (35_296_000 as Weight) + Weight::from_ref_time(35_296_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((171_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(171_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion Voting (r:1 w:1) @@ -126,15 +126,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(x: u32, y: u32, p: u32, ) -> Weight { - (39_252_000 as Weight) + Weight::from_ref_time(39_252_000 as RefTimeWeight) // Standard Error: 18_000 - .saturating_add((75_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(75_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((107_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(107_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((170_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(170_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion Voting (r:1 w:1) @@ -146,13 +146,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (50_357_000 as Weight) + Weight::from_ref_time(50_357_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((103_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(103_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((204_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(204_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion Voting (r:1 w:1) @@ -164,13 +164,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (41_258_000 as Weight) + Weight::from_ref_time(41_258_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((111_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(111_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((186_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(186_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion Voting (r:1 w:1) @@ -183,15 +183,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_approved(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (40_490_000 as Weight) + Weight::from_ref_time(40_490_000 as RefTimeWeight) // Standard Error: 16_000 - .saturating_add((119_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(119_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((93_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(93_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((195_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(195_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:2 w:3) // Storage: AllianceMotion Members (r:1 w:1) @@ -199,55 +199,55 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[0, 90]`. /// The range of component `z` is `[0, 100]`. fn init_members(_x: u32, y: u32, z: u32, ) -> Weight { - (35_186_000 as Weight) + Weight::from_ref_time(35_186_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((161_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(161_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((127_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(127_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Alliance Rule (r:0 w:1) fn set_rule() -> Weight { - (18_189_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_189_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Alliance Announcements (r:1 w:1) fn announce() -> Weight { - (21_106_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_106_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Alliance Announcements (r:1 w:1) fn remove_announcement() -> Weight { - (22_208_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_208_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: Alliance DepositOf (r:0 w:1) fn join_alliance() -> Weight { - (53_771_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(53_771_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) fn nominate_ally() -> Weight { - (41_912_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(41_912_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Alliance Members (r:3 w:2) // Storage: AllianceMotion Proposals (r:1 w:0) // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn elevate_ally() -> Weight { - (36_811_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(36_811_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Alliance Members (r:4 w:2) // Storage: AllianceMotion Proposals (r:1 w:0) @@ -255,18 +255,18 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Prime (r:0 w:1) // Storage: Alliance RetiringMembers (r:0 w:1) fn give_retirement_notice() -> Weight { - (41_079_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(41_079_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Alliance RetiringMembers (r:1 w:1) // Storage: Alliance Members (r:1 w:1) // Storage: Alliance DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn retire() -> Weight { - (42_703_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(42_703_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Alliance Members (r:3 w:1) // Storage: AllianceMotion Proposals (r:1 w:0) @@ -275,35 +275,35 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn kick_member() -> Weight { - (61_370_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(61_370_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Alliance UnscrupulousAccounts (r:1 w:1) // Storage: Alliance UnscrupulousWebsites (r:1 w:1) /// The range of component `n` is `[1, 100]`. /// The range of component `l` is `[1, 255]`. fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_385_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(1_385_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((119_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(119_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Alliance UnscrupulousAccounts (r:1 w:1) // Storage: Alliance UnscrupulousWebsites (r:1 w:1) /// The range of component `n` is `[1, 100]`. /// The range of component `l` is `[1, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 153_000 - .saturating_add((21_484_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(21_484_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 59_000 - .saturating_add((3_772_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(3_772_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } } @@ -319,30 +319,30 @@ impl WeightInfo for () { /// The range of component `y` is `[0, 90]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (22_575_000 as Weight) + Weight::from_ref_time(22_575_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((11_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(11_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 23_000 - .saturating_add((158_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(158_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((90_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(90_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((216_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(216_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Alliance Members (r:2 w:0) // Storage: AllianceMotion Voting (r:1 w:1) /// The range of component `x` is `[3, 10]`. /// The range of component `y` is `[2, 90]`. fn vote(x: u32, y: u32, ) -> Weight { - (45_486_000 as Weight) + Weight::from_ref_time(45_486_000 as RefTimeWeight) // Standard Error: 29_000 - .saturating_add((78_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(78_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((128_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(128_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion ProposalOf (r:1 w:1) @@ -350,11 +350,11 @@ impl WeightInfo for () { // Storage: AllianceMotion Voting (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn veto(p: u32, ) -> Weight { - (35_296_000 as Weight) + Weight::from_ref_time(35_296_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((171_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(171_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion Voting (r:1 w:1) @@ -365,15 +365,15 @@ impl WeightInfo for () { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(x: u32, y: u32, p: u32, ) -> Weight { - (39_252_000 as Weight) + Weight::from_ref_time(39_252_000 as RefTimeWeight) // Standard Error: 18_000 - .saturating_add((75_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(75_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((107_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(107_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((170_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(170_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion Voting (r:1 w:1) @@ -385,13 +385,13 @@ impl WeightInfo for () { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (50_357_000 as Weight) + Weight::from_ref_time(50_357_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((103_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(103_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((204_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(204_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion Voting (r:1 w:1) @@ -403,13 +403,13 @@ impl WeightInfo for () { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (41_258_000 as Weight) + Weight::from_ref_time(41_258_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((111_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(111_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((186_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(186_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion Voting (r:1 w:1) @@ -422,15 +422,15 @@ impl WeightInfo for () { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_approved(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (40_490_000 as Weight) + Weight::from_ref_time(40_490_000 as RefTimeWeight) // Standard Error: 16_000 - .saturating_add((119_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(119_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((93_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(93_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((195_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(195_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:2 w:3) // Storage: AllianceMotion Members (r:1 w:1) @@ -438,55 +438,55 @@ impl WeightInfo for () { /// The range of component `y` is `[0, 90]`. /// The range of component `z` is `[0, 100]`. fn init_members(_x: u32, y: u32, z: u32, ) -> Weight { - (35_186_000 as Weight) + Weight::from_ref_time(35_186_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((161_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(Weight::from_ref_time(161_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((127_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(127_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Alliance Rule (r:0 w:1) fn set_rule() -> Weight { - (18_189_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_189_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Alliance Announcements (r:1 w:1) fn announce() -> Weight { - (21_106_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_106_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Alliance Announcements (r:1 w:1) fn remove_announcement() -> Weight { - (22_208_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_208_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: Alliance DepositOf (r:0 w:1) fn join_alliance() -> Weight { - (53_771_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(53_771_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) fn nominate_ally() -> Weight { - (41_912_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(41_912_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Alliance Members (r:3 w:2) // Storage: AllianceMotion Proposals (r:1 w:0) // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn elevate_ally() -> Weight { - (36_811_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(36_811_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Alliance Members (r:4 w:2) // Storage: AllianceMotion Proposals (r:1 w:0) @@ -494,18 +494,18 @@ impl WeightInfo for () { // Storage: AllianceMotion Prime (r:0 w:1) // Storage: Alliance RetiringMembers (r:0 w:1) fn give_retirement_notice() -> Weight { - (41_079_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(41_079_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Alliance RetiringMembers (r:1 w:1) // Storage: Alliance Members (r:1 w:1) // Storage: Alliance DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn retire() -> Weight { - (42_703_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(42_703_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Alliance Members (r:3 w:1) // Storage: AllianceMotion Proposals (r:1 w:0) @@ -514,34 +514,34 @@ impl WeightInfo for () { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn kick_member() -> Weight { - (61_370_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(61_370_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Alliance UnscrupulousAccounts (r:1 w:1) // Storage: Alliance UnscrupulousWebsites (r:1 w:1) /// The range of component `n` is `[1, 100]`. /// The range of component `l` is `[1, 255]`. fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_385_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(1_385_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((119_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(119_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Alliance UnscrupulousAccounts (r:1 w:1) // Storage: Alliance UnscrupulousWebsites (r:1 w:1) /// The range of component `n` is `[1, 100]`. /// The range of component `l` is `[1, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 153_000 - .saturating_add((21_484_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(21_484_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 59_000 - .saturating_add((3_772_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(3_772_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } } diff --git a/frame/assets/src/weights.rs b/frame/assets/src/weights.rs index e8f1184cf570f..971728df46c24 100644 --- a/frame/assets/src/weights.rs +++ b/frame/assets/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_assets. @@ -74,15 +74,15 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Assets Asset (r:1 w:1) fn create() -> Weight { - (27_167_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(27_167_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) fn force_create() -> Weight { - (15_473_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(15_473_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:5002 w:5001) @@ -90,168 +90,168 @@ impl WeightInfo for SubstrateWeight { // Storage: Assets Metadata (r:1 w:0) // Storage: Assets Approvals (r:501 w:500) fn destroy(c: u32, s: u32, a: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 37_000 - .saturating_add((17_145_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(Weight::from_ref_time(17_145_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) // Standard Error: 37_000 - .saturating_add((19_333_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(19_333_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 375_000 - .saturating_add((17_046_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(a as Weight))) + .saturating_add(Weight::from_ref_time(17_046_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((2 as RefTimeWeight).saturating_mul(c as RefTimeWeight))) + .saturating_add(T::DbWeight::get().reads((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(a as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((2 as RefTimeWeight).saturating_mul(c as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(a as RefTimeWeight))) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:1 w:1) fn mint() -> Weight { - (30_819_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(30_819_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:1 w:1) fn burn() -> Weight { - (35_212_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(35_212_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:2 w:2) // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (47_401_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(47_401_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:2 w:2) // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (42_300_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(42_300_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:2 w:2) // Storage: System Account (r:1 w:1) fn force_transfer() -> Weight { - (47_946_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(47_946_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Account (r:1 w:1) fn freeze() -> Weight { - (21_670_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_670_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Account (r:1 w:1) fn thaw() -> Weight { - (21_503_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_503_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) fn freeze_asset() -> Weight { - (18_158_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_158_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) fn thaw_asset() -> Weight { - (18_525_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_525_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Metadata (r:1 w:0) fn transfer_ownership() -> Weight { - (19_858_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_858_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) fn set_team() -> Weight { - (18_045_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_045_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Metadata (r:1 w:1) fn set_metadata(n: u32, s: u32, ) -> Weight { - (32_395_000 as Weight) + Weight::from_ref_time(32_395_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(5_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 0 - .saturating_add((2_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)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Metadata (r:1 w:1) fn clear_metadata() -> Weight { - (32_893_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(32_893_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Metadata (r:1 w:1) fn force_set_metadata(_n: u32, s: u32, ) -> Weight { - (19_586_000 as Weight) + Weight::from_ref_time(19_586_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_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)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Metadata (r:1 w:1) fn force_clear_metadata() -> Weight { - (32_478_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(32_478_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) fn force_asset_status() -> Weight { - (17_143_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(17_143_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Approvals (r:1 w:1) fn approve_transfer() -> Weight { - (36_389_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(36_389_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Assets Approvals (r:1 w:1) // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:2 w:2) // Storage: System Account (r:1 w:1) fn transfer_approved() -> Weight { - (61_854_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(61_854_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Approvals (r:1 w:1) fn cancel_approval() -> Weight { - (36_759_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(36_759_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Approvals (r:1 w:1) fn force_cancel_approval() -> Weight { - (37_753_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(37_753_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } } @@ -259,15 +259,15 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: Assets Asset (r:1 w:1) fn create() -> Weight { - (27_167_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(27_167_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) fn force_create() -> Weight { - (15_473_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(15_473_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:5002 w:5001) @@ -275,167 +275,167 @@ impl WeightInfo for () { // Storage: Assets Metadata (r:1 w:0) // Storage: Assets Approvals (r:501 w:500) fn destroy(c: u32, s: u32, a: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 37_000 - .saturating_add((17_145_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(Weight::from_ref_time(17_145_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) // Standard Error: 37_000 - .saturating_add((19_333_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(19_333_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 375_000 - .saturating_add((17_046_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(c as Weight))) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(a as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(a as Weight))) + .saturating_add(Weight::from_ref_time(17_046_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((2 as RefTimeWeight).saturating_mul(c as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().reads((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(a as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((2 as RefTimeWeight).saturating_mul(c as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(a as RefTimeWeight))) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:1 w:1) fn mint() -> Weight { - (30_819_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(30_819_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:1 w:1) fn burn() -> Weight { - (35_212_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(35_212_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:2 w:2) // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (47_401_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(47_401_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:2 w:2) // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (42_300_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(42_300_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:2 w:2) // Storage: System Account (r:1 w:1) fn force_transfer() -> Weight { - (47_946_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(47_946_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Account (r:1 w:1) fn freeze() -> Weight { - (21_670_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_670_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Account (r:1 w:1) fn thaw() -> Weight { - (21_503_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_503_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) fn freeze_asset() -> Weight { - (18_158_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_158_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) fn thaw_asset() -> Weight { - (18_525_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_525_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Metadata (r:1 w:0) fn transfer_ownership() -> Weight { - (19_858_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_858_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) fn set_team() -> Weight { - (18_045_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_045_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Metadata (r:1 w:1) fn set_metadata(n: u32, s: u32, ) -> Weight { - (32_395_000 as Weight) + Weight::from_ref_time(32_395_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(5_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Metadata (r:1 w:1) fn clear_metadata() -> Weight { - (32_893_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(32_893_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Metadata (r:1 w:1) fn force_set_metadata(_n: u32, s: u32, ) -> Weight { - (19_586_000 as Weight) + Weight::from_ref_time(19_586_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:0) // Storage: Assets Metadata (r:1 w:1) fn force_clear_metadata() -> Weight { - (32_478_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(32_478_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) fn force_asset_status() -> Weight { - (17_143_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(17_143_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Approvals (r:1 w:1) fn approve_transfer() -> Weight { - (36_389_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(36_389_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Assets Approvals (r:1 w:1) // Storage: Assets Asset (r:1 w:1) // Storage: Assets Account (r:2 w:2) // Storage: System Account (r:1 w:1) fn transfer_approved() -> Weight { - (61_854_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(61_854_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Approvals (r:1 w:1) fn cancel_approval() -> Weight { - (36_759_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(36_759_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Assets Asset (r:1 w:1) // Storage: Assets Approvals (r:1 w:1) fn force_cancel_approval() -> Weight { - (37_753_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(37_753_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } } diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index 54643001ad6fc..1b6c62c55ee20 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -243,7 +243,7 @@ pub mod pallet { /// - `duration`: Locked duration of the atomic swap. For safety reasons, it is recommended /// that the revealer uses a shorter duration than the counterparty, to prevent the /// situation where the revealer reveals the proof too late around the end block. - #[pallet::weight(T::DbWeight::get().reads_writes(1, 1).saturating_add(40_000_000))] + #[pallet::weight(T::DbWeight::get().reads_writes(1, 1).ref_time().saturating_add(40_000_000))] pub fn create_swap( origin: OriginFor, target: T::AccountId, @@ -280,9 +280,10 @@ pub mod pallet { /// the operation fails. This is used for weight calculation. #[pallet::weight( T::DbWeight::get().reads_writes(1, 1) - .saturating_add(40_000_000) - .saturating_add((proof.len() as Weight).saturating_mul(100)) .saturating_add(action.weight()) + .ref_time() + .saturating_add(40_000_000) + .saturating_add((proof.len() as u64).saturating_mul(100)) )] pub fn claim_swap( origin: OriginFor, @@ -317,7 +318,7 @@ pub mod pallet { /// /// - `target`: Target of the original atomic swap. /// - `hashed_proof`: Hashed proof of the original atomic swap. - #[pallet::weight(T::DbWeight::get().reads_writes(1, 1).saturating_add(40_000_000))] + #[pallet::weight(T::DbWeight::get().reads_writes(1, 1).ref_time().saturating_add(40_000_000))] pub fn cancel_swap( origin: OriginFor, target: T::AccountId, diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 688d3ff17f786..ffb548a1f29ed 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -30,7 +30,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 636a28692ba28..5023feeaf8aea 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -49,7 +49,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index a56d8e785f6ac..d5f9783f153c8 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -227,7 +227,7 @@ mod tests { pub const Period: BlockNumber = 1; pub const Offset: BlockNumber = 0; pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 8ddccfd9cf939..ff18e047db048 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -190,7 +190,7 @@ pub mod pallet { T::EventHandler::note_author(author); } - 0 + Weight::zero() } fn on_finalize(_: T::BlockNumber) { @@ -460,7 +460,7 @@ mod tests { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { diff --git a/frame/babe/src/default_weights.rs b/frame/babe/src/default_weights.rs index 57c74323b7932..cc1d11108b2e1 100644 --- a/frame/babe/src/default_weights.rs +++ b/frame/babe/src/default_weights.rs @@ -38,8 +38,8 @@ impl crate::WeightInfo for () { const MAX_NOMINATORS: u64 = 200; // checking membership proof - (35 * WEIGHT_PER_MICROS) - .saturating_add((175 * WEIGHT_PER_NANOS).saturating_mul(validator_count)) + let ref_time_weight = (35 * WEIGHT_PER_MICROS) + .saturating_add((175 * WEIGHT_PER_NANOS).scalar_saturating_mul(validator_count)) .saturating_add(DbWeight::get().reads(5)) // check equivocation proof .saturating_add(110 * WEIGHT_PER_MICROS) @@ -47,6 +47,8 @@ impl crate::WeightInfo for () { .saturating_add(110 * WEIGHT_PER_MICROS) .saturating_add(25 * WEIGHT_PER_MICROS * MAX_NOMINATORS) .saturating_add(DbWeight::get().reads(14 + 3 * MAX_NOMINATORS)) - .saturating_add(DbWeight::get().writes(10 + 3 * MAX_NOMINATORS)) + .saturating_add(DbWeight::get().writes(10 + 3 * MAX_NOMINATORS)); + + ref_time_weight } } diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 1effc2c1989fa..48ca62a5b1a09 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -336,7 +336,7 @@ pub mod pallet { /// Initialization fn on_initialize(now: BlockNumberFor) -> Weight { Self::initialize(now); - 0 + Weight::zero() } /// Block finalization @@ -1008,6 +1008,6 @@ pub mod migrations { writes += 3; - T::DbWeight::get().writes(writes) + T::DbWeight::get().reads(reads) + T::DbWeight::get().reads_writes(reads, writes) } } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index c2ba3c2be06d8..3a6348404b9a7 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -66,7 +66,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { diff --git a/frame/babe/src/tests.rs b/frame/babe/src/tests.rs index ece0883387709..2f967b658e396 100644 --- a/frame/babe/src/tests.rs +++ b/frame/babe/src/tests.rs @@ -852,7 +852,7 @@ fn valid_equivocation_reports_dont_pay_fees() { .get_dispatch_info(); // it should have non-zero weight and the fee has to be paid. - assert!(info.weight > 0); + assert!(info.weight > Weight::zero()); assert_eq!(info.pays_fee, Pays::Yes); // report the equivocation. diff --git a/frame/bags-list/src/migrations.rs b/frame/bags-list/src/migrations.rs index a77beb23bd667..49b7d136125e2 100644 --- a/frame/bags-list/src/migrations.rs +++ b/frame/bags-list/src/migrations.rs @@ -21,7 +21,6 @@ use codec::{Decode, Encode}; use core::marker::PhantomData; use frame_election_provider_support::ScoreProvider; use frame_support::traits::OnRuntimeUpgrade; -use sp_runtime::traits::Zero; #[cfg(feature = "try-runtime")] use frame_support::ensure; diff --git a/frame/bags-list/src/weights.rs b/frame/bags-list/src/weights.rs index a554a9bd4ad1a..049967e3024c0 100644 --- a/frame/bags-list/src/weights.rs +++ b/frame/bags-list/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_bags_list. @@ -57,18 +57,18 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList ListNodes (r:4 w:4) // Storage: BagsList ListBags (r:1 w:1) fn rebag_non_terminal() -> Weight { - (55_040_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(55_040_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(7 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) // Storage: BagsList ListNodes (r:3 w:3) // Storage: BagsList ListBags (r:2 w:2) fn rebag_terminal() -> Weight { - (53_671_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(53_671_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(7 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: BagsList ListNodes (r:4 w:4) // Storage: Staking Bonded (r:2 w:0) @@ -76,9 +76,9 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList CounterForListNodes (r:1 w:1) // Storage: BagsList ListBags (r:1 w:1) fn put_in_front_of() -> Weight { - (56_410_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(56_410_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(10 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } } @@ -89,18 +89,18 @@ impl WeightInfo for () { // Storage: BagsList ListNodes (r:4 w:4) // Storage: BagsList ListBags (r:1 w:1) fn rebag_non_terminal() -> Weight { - (55_040_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(55_040_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(7 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) // Storage: BagsList ListNodes (r:3 w:3) // Storage: BagsList ListBags (r:2 w:2) fn rebag_terminal() -> Weight { - (53_671_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(53_671_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(7 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: BagsList ListNodes (r:4 w:4) // Storage: Staking Bonded (r:2 w:0) @@ -108,8 +108,8 @@ impl WeightInfo for () { // Storage: BagsList CounterForListNodes (r:1 w:1) // Storage: BagsList ListBags (r:1 w:1) fn put_in_front_of() -> Weight { - (56_410_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(56_410_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(10 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } } diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index a9e44f085977a..6605af530563d 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -188,14 +188,14 @@ macro_rules! decl_tests { ChargeTransactionPayment::from(1), &1, CALL, - &info_from_weight(1), + &info_from_weight(Weight::one()), 1, ).is_err()); assert_ok!( as SignedExtension>::pre_dispatch( ChargeTransactionPayment::from(0), &1, CALL, - &info_from_weight(1), + &info_from_weight(Weight::one()), 1, )); @@ -206,14 +206,14 @@ macro_rules! decl_tests { ChargeTransactionPayment::from(1), &1, CALL, - &info_from_weight(1), + &info_from_weight(Weight::one()), 1, ).is_err()); assert!( as SignedExtension>::pre_dispatch( ChargeTransactionPayment::from(0), &1, CALL, - &info_from_weight(1), + &info_from_weight(Weight::one()), 1, ).is_err()); }); diff --git a/frame/balances/src/tests_composite.rs b/frame/balances/src/tests_composite.rs index 4ab913cf1411a..266c37063d2f8 100644 --- a/frame/balances/src/tests_composite.rs +++ b/frame/balances/src/tests_composite.rs @@ -46,7 +46,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index 48c6574c3b39f..ebb82f41a545c 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -47,7 +47,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index 4c028840d553c..fbfd62eb63259 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -51,7 +51,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index f612d31997996..17b2541e0a998 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_balances. @@ -58,45 +58,45 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (41_860_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(41_860_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (32_760_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(32_760_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (22_279_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_279_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (25_488_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_488_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (42_190_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(42_190_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (37_789_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(37_789_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn force_unreserve() -> Weight { - (20_056_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(20_056_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } } @@ -104,44 +104,44 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (41_860_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(41_860_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (32_760_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(32_760_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (22_279_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_279_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (25_488_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_488_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (42_190_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(42_190_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (37_789_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(37_789_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn force_unreserve() -> Weight { - (20_056_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(20_056_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } } diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 8c642f74358db..b483208e3ef69 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -127,7 +127,7 @@ pub struct BenchmarkResult { impl BenchmarkResult { pub fn from_weight(w: Weight) -> Self { - Self { extrinsic_time: (w as u128) / 1_000, ..Default::default() } + Self { extrinsic_time: (w.ref_time() / 1_000) as u128, ..Default::default() } } } diff --git a/frame/benchmarking/src/weights.rs b/frame/benchmarking/src/weights.rs index 8b36601940cf3..dc2ca26e1af02 100644 --- a/frame/benchmarking/src/weights.rs +++ b/frame/benchmarking/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for frame_benchmarking. @@ -58,75 +58,75 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn addition(_i: u32, ) -> Weight { - (103_000 as Weight) + Weight::from_ref_time(103_000 as RefTimeWeight) } fn subtraction(_i: u32, ) -> Weight { - (105_000 as Weight) + Weight::from_ref_time(105_000 as RefTimeWeight) } fn multiplication(_i: u32, ) -> Weight { - (113_000 as Weight) + Weight::from_ref_time(113_000 as RefTimeWeight) } fn division(_i: u32, ) -> Weight { - (102_000 as Weight) + Weight::from_ref_time(102_000 as RefTimeWeight) } fn hashing(_i: u32, ) -> Weight { - (20_865_902_000 as Weight) + Weight::from_ref_time(20_865_902_000 as RefTimeWeight) } fn sr25519_verification(i: u32, ) -> Weight { - (319_000 as Weight) + Weight::from_ref_time(319_000 as RefTimeWeight) // Standard Error: 8_000 - .saturating_add((47_171_000 as Weight).saturating_mul(i as Weight)) + .saturating_add(Weight::from_ref_time(47_171_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) fn storage_read(i: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((2_110_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight))) + .saturating_add(Weight::from_ref_time(2_110_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) fn storage_write(i: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((372_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + .saturating_add(Weight::from_ref_time(372_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) } } // For backwards compatibility and tests impl WeightInfo for () { fn addition(_i: u32, ) -> Weight { - (103_000 as Weight) + Weight::from_ref_time(103_000 as RefTimeWeight) } fn subtraction(_i: u32, ) -> Weight { - (105_000 as Weight) + Weight::from_ref_time(105_000 as RefTimeWeight) } fn multiplication(_i: u32, ) -> Weight { - (113_000 as Weight) + Weight::from_ref_time(113_000 as RefTimeWeight) } fn division(_i: u32, ) -> Weight { - (102_000 as Weight) + Weight::from_ref_time(102_000 as RefTimeWeight) } fn hashing(_i: u32, ) -> Weight { - (20_865_902_000 as Weight) + Weight::from_ref_time(20_865_902_000 as RefTimeWeight) } fn sr25519_verification(i: u32, ) -> Weight { - (319_000 as Weight) + Weight::from_ref_time(319_000 as RefTimeWeight) // Standard Error: 8_000 - .saturating_add((47_171_000 as Weight).saturating_mul(i as Weight)) + .saturating_add(Weight::from_ref_time(47_171_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) fn storage_read(i: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((2_110_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(i as Weight))) + .saturating_add(Weight::from_ref_time(2_110_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) fn storage_write(i: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((372_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + .saturating_add(Weight::from_ref_time(372_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) } } diff --git a/frame/bounties/src/migrations/v4.rs b/frame/bounties/src/migrations/v4.rs index 8f5f3ebe55bf4..2f81c97127bcd 100644 --- a/frame/bounties/src/migrations/v4.rs +++ b/frame/bounties/src/migrations/v4.rs @@ -54,7 +54,7 @@ pub fn migrate< target: "runtime::bounties", "New pallet name is equal to the old prefix. No migration needs to be done.", ); - return 0 + return Weight::zero() } let on_chain_storage_version =

::on_chain_storage_version(); @@ -105,7 +105,7 @@ pub fn migrate< "Attempted to apply migration to v4 but failed because storage version is {:?}", on_chain_storage_version, ); - 0 + Weight::zero() } } diff --git a/frame/bounties/src/weights.rs b/frame/bounties/src/weights.rs index d3e054cfc6351..27a23cb4ffeae 100644 --- a/frame/bounties/src/weights.rs +++ b/frame/bounties/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_bounties. @@ -65,88 +65,88 @@ impl WeightInfo for SubstrateWeight { // Storage: Bounties BountyDescriptions (r:0 w:1) // Storage: Bounties Bounties (r:0 w:1) fn propose_bounty(_d: u32, ) -> Weight { - (28_903_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(28_903_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: Bounties BountyApprovals (r:1 w:1) fn approve_bounty() -> Weight { - (10_997_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(10_997_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) fn propose_curator() -> Weight { - (8_967_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(8_967_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn unassign_curator() -> Weight { - (28_665_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(28_665_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn accept_curator() -> Weight { - (25_141_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(25_141_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) fn award_bounty() -> Weight { - (21_295_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_295_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:3 w:3) // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) // Storage: Bounties BountyDescriptions (r:0 w:1) fn claim_bounty() -> Weight { - (67_951_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(67_951_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: Bounties BountyDescriptions (r:0 w:1) fn close_bounty_proposed() -> Weight { - (33_654_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(33_654_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) // Storage: System Account (r:2 w:2) // Storage: Bounties BountyDescriptions (r:0 w:1) fn close_bounty_active() -> Weight { - (50_582_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(50_582_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) fn extend_bounty_expiry() -> Weight { - (18_322_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_322_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Bounties BountyApprovals (r:1 w:1) // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:2 w:2) fn spend_funds(b: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 17_000 - .saturating_add((29_233_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(b as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight))) + .saturating_add(Weight::from_ref_time(29_233_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((3 as RefTimeWeight).saturating_mul(b as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((3 as RefTimeWeight).saturating_mul(b as RefTimeWeight))) } } @@ -157,87 +157,87 @@ impl WeightInfo for () { // Storage: Bounties BountyDescriptions (r:0 w:1) // Storage: Bounties Bounties (r:0 w:1) fn propose_bounty(_d: u32, ) -> Weight { - (28_903_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(28_903_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: Bounties BountyApprovals (r:1 w:1) fn approve_bounty() -> Weight { - (10_997_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(10_997_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) fn propose_curator() -> Weight { - (8_967_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(8_967_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn unassign_curator() -> Weight { - (28_665_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(28_665_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn accept_curator() -> Weight { - (25_141_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(25_141_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) fn award_bounty() -> Weight { - (21_295_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_295_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:3 w:3) // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) // Storage: Bounties BountyDescriptions (r:0 w:1) fn claim_bounty() -> Weight { - (67_951_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(67_951_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: Bounties BountyDescriptions (r:0 w:1) fn close_bounty_proposed() -> Weight { - (33_654_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(33_654_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) // Storage: System Account (r:2 w:2) // Storage: Bounties BountyDescriptions (r:0 w:1) fn close_bounty_active() -> Weight { - (50_582_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(50_582_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:1) fn extend_bounty_expiry() -> Weight { - (18_322_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_322_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Bounties BountyApprovals (r:1 w:1) // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:2 w:2) fn spend_funds(b: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 17_000 - .saturating_add((29_233_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(b as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight))) + .saturating_add(Weight::from_ref_time(29_233_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((3 as RefTimeWeight).saturating_mul(b as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((3 as RefTimeWeight).saturating_mul(b as RefTimeWeight))) } } diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 2584445071471..f42715f14bbee 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -60,7 +60,7 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const MaximumBlockWeight: Weight = 1024; + pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/child-bounties/src/weights.rs b/frame/child-bounties/src/weights.rs index ad08e00149a30..c5d00d6ed0bd4 100644 --- a/frame/child-bounties/src/weights.rs +++ b/frame/child-bounties/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_child_bounties. @@ -64,51 +64,51 @@ impl WeightInfo for SubstrateWeight { // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) // Storage: ChildBounties ChildBounties (r:0 w:1) fn add_child_bounty(d: u32, ) -> Weight { - (51_064_000 as Weight) + Weight::from_ref_time(51_064_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) fn propose_curator() -> Weight { - (15_286_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(15_286_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn accept_curator() -> Weight { - (29_929_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(29_929_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: Bounties Bounties (r:1 w:0) // Storage: System Account (r:1 w:1) fn unassign_curator() -> Weight { - (32_449_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_449_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) fn award_child_bounty() -> Weight { - (23_793_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(23_793_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: System Account (r:3 w:3) // Storage: ChildBounties ParentChildBounties (r:1 w:1) // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) fn claim_child_bounty() -> Weight { - (67_529_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(67_529_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) @@ -117,9 +117,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:2 w:2) // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) fn close_child_bounty_added() -> Weight { - (48_436_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(48_436_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) @@ -128,9 +128,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ChildBounties ParentChildBounties (r:1 w:1) // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) fn close_child_bounty_active() -> Weight { - (58_044_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(58_044_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(7 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(7 as RefTimeWeight)) } } @@ -143,51 +143,51 @@ impl WeightInfo for () { // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) // Storage: ChildBounties ChildBounties (r:0 w:1) fn add_child_bounty(d: u32, ) -> Weight { - (51_064_000 as Weight) + Weight::from_ref_time(51_064_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) fn propose_curator() -> Weight { - (15_286_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(15_286_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn accept_curator() -> Weight { - (29_929_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(29_929_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: Bounties Bounties (r:1 w:0) // Storage: System Account (r:1 w:1) fn unassign_curator() -> Weight { - (32_449_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_449_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) fn award_child_bounty() -> Weight { - (23_793_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(23_793_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: System Account (r:3 w:3) // Storage: ChildBounties ParentChildBounties (r:1 w:1) // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) fn claim_child_bounty() -> Weight { - (67_529_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(67_529_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) @@ -196,9 +196,9 @@ impl WeightInfo for () { // Storage: System Account (r:2 w:2) // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) fn close_child_bounty_added() -> Weight { - (48_436_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(48_436_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) @@ -207,8 +207,8 @@ impl WeightInfo for () { // Storage: ChildBounties ParentChildBounties (r:1 w:1) // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) fn close_child_bounty_active() -> Weight { - (58_044_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(58_044_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(7 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(7 as RefTimeWeight)) } } diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 076afcd203030..b80a4aef28d38 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -355,7 +355,7 @@ benchmarks_instance_pallet! { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); - }: close(SystemOrigin::Signed(voter), last_hash, index, Weight::max_value(), bytes_in_storage) + }: close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. assert_eq!(Collective::::proposals().len(), (p - 1) as usize); @@ -436,7 +436,7 @@ benchmarks_instance_pallet! { index, approve, )?; - }: close(SystemOrigin::Signed(caller), last_hash, index, Weight::max_value(), bytes_in_storage) + }: close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. assert_eq!(Collective::::proposals().len(), (p - 1) as usize); @@ -511,7 +511,7 @@ benchmarks_instance_pallet! { assert_eq!(Collective::::proposals().len(), p as usize); // Prime nay will close it as disapproved - }: close(SystemOrigin::Signed(caller), last_hash, index, Weight::max_value(), bytes_in_storage) + }: close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); @@ -583,7 +583,7 @@ benchmarks_instance_pallet! { assert_eq!(Collective::::proposals().len(), p as usize); // Prime aye will close it as approved - }: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::max_value(), bytes_in_storage) + }: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::MAX, bytes_in_storage) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); diff --git a/frame/collective/src/migrations/v4.rs b/frame/collective/src/migrations/v4.rs index 4e6cd05584138..483c3f9fa9e69 100644 --- a/frame/collective/src/migrations/v4.rs +++ b/frame/collective/src/migrations/v4.rs @@ -45,7 +45,7 @@ pub fn migrate::on_chain_storage_version(); @@ -70,7 +70,7 @@ pub fn migrate::WrongProposalWeight ); assert_ok!(Collective::close(Origin::signed(4), hash, 0, proposal_weight, proposal_len)); @@ -301,7 +307,7 @@ fn proposal_weight_limit_ignored_on_disapprove() { Origin::signed(4), hash, 0, - proposal_weight - 100, + proposal_weight - Weight::from_ref_time(100), proposal_len )); }) @@ -687,7 +693,11 @@ fn correct_validate_and_get_proposal() { Error::::WrongProposalLength ); assert_noop!( - Collective::validate_and_get_proposal(&hash, length, weight - 10), + Collective::validate_and_get_proposal( + &hash, + length, + weight - Weight::from_ref_time(10) + ), Error::::WrongProposalWeight ); let res = Collective::validate_and_get_proposal(&hash, length, weight); @@ -1196,18 +1206,18 @@ fn close_disapprove_does_not_care_about_weight_or_len() { assert_ok!(Collective::vote(Origin::signed(2), hash, 0, true)); // It will not close with bad weight/len information assert_noop!( - Collective::close(Origin::signed(2), hash, 0, 0, 0), + Collective::close(Origin::signed(2), hash, 0, Weight::zero(), 0), Error::::WrongProposalLength, ); assert_noop!( - Collective::close(Origin::signed(2), hash, 0, 0, proposal_len), + Collective::close(Origin::signed(2), hash, 0, Weight::zero(), proposal_len), Error::::WrongProposalWeight, ); // Now we make the proposal fail assert_ok!(Collective::vote(Origin::signed(1), hash, 0, false)); assert_ok!(Collective::vote(Origin::signed(2), hash, 0, false)); // It can close even if the weight/len information is bad - assert_ok!(Collective::close(Origin::signed(2), hash, 0, 0, 0)); + assert_ok!(Collective::close(Origin::signed(2), hash, 0, Weight::zero(), 0)); }) } diff --git a/frame/collective/src/weights.rs b/frame/collective/src/weights.rs index 2f5c6f590a999..a0cc64cc2408d 100644 --- a/frame/collective/src/weights.rs +++ b/frame/collective/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_collective. @@ -64,36 +64,36 @@ impl WeightInfo for SubstrateWeight { // Storage: Council Voting (r:100 w:100) // Storage: Council Prime (r:0 w:1) fn set_members(m: u32, n: u32, p: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 12_000 - .saturating_add((10_280_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(10_280_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 12_000 - .saturating_add((126_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(126_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 12_000 - .saturating_add((13_310_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + .saturating_add(Weight::from_ref_time(13_310_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) } // Storage: Council Members (r:1 w:0) fn execute(b: u32, m: u32, ) -> Weight { - (16_819_000 as Weight) + Weight::from_ref_time(16_819_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 0 - .saturating_add((33_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(Weight::from_ref_time(33_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) } // Storage: Council Members (r:1 w:0) // Storage: Council ProposalOf (r:1 w:0) fn propose_execute(b: u32, m: u32, ) -> Weight { - (18_849_000 as Weight) + Weight::from_ref_time(18_849_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 0 - .saturating_add((56_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(Weight::from_ref_time(56_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) } // Storage: Council Members (r:1 w:0) // Storage: Council ProposalOf (r:1 w:1) @@ -101,52 +101,52 @@ impl WeightInfo for SubstrateWeight { // Storage: Council ProposalCount (r:1 w:1) // Storage: Council Voting (r:0 w:1) fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (22_204_000 as Weight) + Weight::from_ref_time(22_204_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((8_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(8_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((49_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(49_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((180_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(180_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Council Members (r:1 w:0) // Storage: Council Voting (r:1 w:1) fn vote(m: u32, ) -> Weight { - (30_941_000 as Weight) + Weight::from_ref_time(30_941_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((77_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(77_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Council Voting (r:1 w:1) // Storage: Council Members (r:1 w:0) // Storage: Council Proposals (r:1 w:1) // Storage: Council ProposalOf (r:0 w:1) fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (32_485_000 as Weight) + Weight::from_ref_time(32_485_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((39_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(39_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((124_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(124_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Council Voting (r:1 w:1) // Storage: Council Members (r:1 w:0) // Storage: Council ProposalOf (r:1 w:1) // Storage: Council Proposals (r:1 w:1) fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (33_487_000 as Weight) + Weight::from_ref_time(33_487_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(5_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((66_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(66_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((157_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(157_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Council Voting (r:1 w:1) // Storage: Council Members (r:1 w:0) @@ -154,13 +154,13 @@ impl WeightInfo for SubstrateWeight { // Storage: Council Proposals (r:1 w:1) // Storage: Council ProposalOf (r:0 w:1) fn close_disapproved(m: u32, p: u32, ) -> Weight { - (33_494_000 as Weight) + Weight::from_ref_time(33_494_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((58_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(58_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((124_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(124_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Council Voting (r:1 w:1) // Storage: Council Members (r:1 w:0) @@ -168,25 +168,25 @@ impl WeightInfo for SubstrateWeight { // Storage: Council ProposalOf (r:1 w:1) // Storage: Council Proposals (r:1 w:1) fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (36_566_000 as Weight) + Weight::from_ref_time(36_566_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(5_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((63_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(63_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((158_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(158_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Council Proposals (r:1 w:1) // Storage: Council Voting (r:0 w:1) // Storage: Council ProposalOf (r:0 w:1) fn disapprove_proposal(p: u32, ) -> Weight { - (20_159_000 as Weight) + Weight::from_ref_time(20_159_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((173_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(173_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } } @@ -197,36 +197,36 @@ impl WeightInfo for () { // Storage: Council Voting (r:100 w:100) // Storage: Council Prime (r:0 w:1) fn set_members(m: u32, n: u32, p: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 12_000 - .saturating_add((10_280_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(10_280_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 12_000 - .saturating_add((126_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(126_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 12_000 - .saturating_add((13_310_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + .saturating_add(Weight::from_ref_time(13_310_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) } // Storage: Council Members (r:1 w:0) fn execute(b: u32, m: u32, ) -> Weight { - (16_819_000 as Weight) + Weight::from_ref_time(16_819_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 0 - .saturating_add((33_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(Weight::from_ref_time(33_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) } // Storage: Council Members (r:1 w:0) // Storage: Council ProposalOf (r:1 w:0) fn propose_execute(b: u32, m: u32, ) -> Weight { - (18_849_000 as Weight) + Weight::from_ref_time(18_849_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 0 - .saturating_add((56_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(Weight::from_ref_time(56_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) } // Storage: Council Members (r:1 w:0) // Storage: Council ProposalOf (r:1 w:1) @@ -234,52 +234,52 @@ impl WeightInfo for () { // Storage: Council ProposalCount (r:1 w:1) // Storage: Council Voting (r:0 w:1) fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (22_204_000 as Weight) + Weight::from_ref_time(22_204_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((8_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(8_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((49_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(49_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((180_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(180_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Council Members (r:1 w:0) // Storage: Council Voting (r:1 w:1) fn vote(m: u32, ) -> Weight { - (30_941_000 as Weight) + Weight::from_ref_time(30_941_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((77_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(77_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Council Voting (r:1 w:1) // Storage: Council Members (r:1 w:0) // Storage: Council Proposals (r:1 w:1) // Storage: Council ProposalOf (r:0 w:1) fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (32_485_000 as Weight) + Weight::from_ref_time(32_485_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((39_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(39_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((124_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(124_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Council Voting (r:1 w:1) // Storage: Council Members (r:1 w:0) // Storage: Council ProposalOf (r:1 w:1) // Storage: Council Proposals (r:1 w:1) fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (33_487_000 as Weight) + Weight::from_ref_time(33_487_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(5_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((66_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(66_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((157_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(157_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Council Voting (r:1 w:1) // Storage: Council Members (r:1 w:0) @@ -287,13 +287,13 @@ impl WeightInfo for () { // Storage: Council Proposals (r:1 w:1) // Storage: Council ProposalOf (r:0 w:1) fn close_disapproved(m: u32, p: u32, ) -> Weight { - (33_494_000 as Weight) + Weight::from_ref_time(33_494_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((58_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(58_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((124_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(124_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Council Voting (r:1 w:1) // Storage: Council Members (r:1 w:0) @@ -301,24 +301,24 @@ impl WeightInfo for () { // Storage: Council ProposalOf (r:1 w:1) // Storage: Council Proposals (r:1 w:1) fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (36_566_000 as Weight) + Weight::from_ref_time(36_566_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(5_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((63_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(63_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((158_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(158_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Council Proposals (r:1 w:1) // Storage: Council Voting (r:0 w:1) // Storage: Council ProposalOf (r:0 w:1) fn disapprove_proposal(p: u32, ) -> Weight { - (20_159_000 as Weight) + Weight::from_ref_time(20_159_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((173_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(173_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } } diff --git a/frame/contracts/rpc/src/lib.rs b/frame/contracts/rpc/src/lib.rs index 0df8f90237ed3..1df7a5753f77e 100644 --- a/frame/contracts/rpc/src/lib.rs +++ b/frame/contracts/rpc/src/lib.rs @@ -229,7 +229,7 @@ where call_request; let value: Balance = decode_hex(value, "balance")?; - let gas_limit: Weight = decode_hex(gas_limit, "weight")?; + let gas_limit: u64 = decode_hex(gas_limit, "weight")?; let storage_deposit_limit: Option = storage_deposit_limit.map(|l| decode_hex(l, "balance")).transpose()?; limit_gas(gas_limit)?; @@ -259,7 +259,7 @@ where } = instantiate_request; let value: Balance = decode_hex(value, "balance")?; - let gas_limit: Weight = decode_hex(gas_limit, "weight")?; + let gas_limit: u64 = decode_hex(gas_limit, "weight")?; let storage_deposit_limit: Option = storage_deposit_limit.map(|l| decode_hex(l, "balance")).transpose()?; limit_gas(gas_limit)?; diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 1a0b735ac76ce..e29cb51728e1e 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -2853,8 +2853,8 @@ benchmarks! { println!("{:#?}", Schedule::::default()); println!("###############################################"); println!("Lazy deletion throughput per block (empty queue, full queue): {}, {}", - weight_limit / weight_per_key, - (weight_limit - weight_per_queue_item * queue_depth) / weight_per_key, + weight_limit / weight_per_key.ref_time(), + (weight_limit - weight_per_queue_item * queue_depth) / weight_per_key.ref_time(), ); } #[cfg(not(feature = "std"))] diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index 29f8ad44a56ac..d0e0cf5cf95cb 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -238,7 +238,7 @@ where /// /// Weight is synonymous with gas in substrate. pub fn charge_weight(&mut self, amount: Weight) -> Result { - self.inner.runtime.charge_gas(RuntimeCosts::ChainExtension(amount)) + self.inner.runtime.charge_gas(RuntimeCosts::ChainExtension(amount.ref_time())) } /// Adjust a previously charged amount down to its actual amount. @@ -248,7 +248,7 @@ where pub fn adjust_weight(&mut self, charged: ChargedAmount, actual_weight: Weight) { self.inner .runtime - .adjust_gas(charged, RuntimeCosts::ChainExtension(actual_weight)) + .adjust_gas(charged, RuntimeCosts::ChainExtension(actual_weight.ref_time())) } /// Grants access to the execution environment of the current contract call. @@ -411,7 +411,8 @@ where buffer, allow_skip, |len| { - weight_per_byte.map(|w| RuntimeCosts::ChainExtension(w.saturating_mul(len.into()))) + weight_per_byte + .map(|w| RuntimeCosts::ChainExtension(w.ref_time().saturating_mul(len.into()))) }, ) } diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 3b186236dd0fa..81e1aef92cbfc 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -664,7 +664,7 @@ where debug_message: Option<&'a mut Vec>, ) -> Result<(Self, E), ExecError> { let (first_frame, executable, nonce) = - Self::new_frame(args, value, gas_meter, storage_meter, 0, schedule)?; + Self::new_frame(args, value, gas_meter, storage_meter, Weight::zero(), schedule)?; let stack = Self { origin, schedule, @@ -1089,7 +1089,7 @@ where delegated_call: Some(DelegatedCall { executable, caller: self.caller().clone() }), }, value, - 0, + Weight::zero(), )?; self.run(executable, input_data) } @@ -1825,7 +1825,7 @@ mod tests { let value = Default::default(); let recurse_ch = MockLoader::insert(Call, |ctx, _| { // Try to call into yourself. - let r = ctx.ext.call(0, BOB, 0, vec![], true); + let r = ctx.ext.call(Weight::zero(), BOB, 0, vec![], true); REACHED_BOTTOM.with(|reached_bottom| { let mut reached_bottom = reached_bottom.borrow_mut(); @@ -1880,7 +1880,7 @@ mod tests { .with(|caller| *caller.borrow_mut() = Some(ctx.ext.caller().clone())); // Call into CHARLIE contract. - assert_matches!(ctx.ext.call(0, CHARLIE, 0, vec![], true), Ok(_)); + assert_matches!(ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], true), Ok(_)); exec_success() }); let charlie_ch = MockLoader::insert(Call, |ctx, _| { @@ -2011,7 +2011,7 @@ mod tests { // ALICE is the origin of the call stack assert!(ctx.ext.caller_is_origin()); // BOB calls CHARLIE - ctx.ext.call(0, CHARLIE, 0, vec![], true) + ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], true) }); ExtBuilder::default().build().execute_with(|| { @@ -2041,7 +2041,7 @@ mod tests { assert_eq!(*ctx.ext.address(), BOB); // Call into charlie contract. - assert_matches!(ctx.ext.call(0, CHARLIE, 0, vec![], true), Ok(_)); + assert_matches!(ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], true), Ok(_)); exec_success() }); let charlie_ch = MockLoader::insert(Call, |ctx, _| { @@ -2190,7 +2190,7 @@ mod tests { let (address, output) = ctx .ext .instantiate( - 0, + Weight::zero(), dummy_ch, ::Currency::minimum_balance(), vec![], @@ -2250,7 +2250,7 @@ mod tests { // Instantiate a contract and save it's address in `instantiated_contract_address`. assert_matches!( ctx.ext.instantiate( - 0, + Weight::zero(), dummy_ch, ::Currency::minimum_balance(), vec![], @@ -2342,13 +2342,13 @@ mod tests { let info = ctx.ext.contract_info(); assert_eq!(info.storage_deposit, 0); info.storage_deposit = 42; - assert_eq!(ctx.ext.call(0, CHARLIE, 0, vec![], true), exec_trapped()); + assert_eq!(ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], true), exec_trapped()); assert_eq!(ctx.ext.contract_info().storage_deposit, 42); } exec_success() }); let code_charlie = MockLoader::insert(Call, |ctx, _| { - assert!(ctx.ext.call(0, BOB, 0, vec![99], true).is_ok()); + assert!(ctx.ext.call(Weight::zero(), BOB, 0, vec![99], true).is_ok()); exec_trapped() }); @@ -2377,7 +2377,7 @@ mod tests { fn recursive_call_during_constructor_fails() { let code = MockLoader::insert(Constructor, |ctx, _| { assert_matches!( - ctx.ext.call(0, ctx.ext.address().clone(), 0, vec![], true), + ctx.ext.call(Weight::zero(), ctx.ext.address().clone(), 0, vec![], true), Err(ExecError{error, ..}) if error == >::ContractNotFound.into() ); exec_success() @@ -2479,7 +2479,7 @@ mod tests { // call the contract passed as input with disabled reentry let code_bob = MockLoader::insert(Call, |ctx, _| { let dest = Decode::decode(&mut ctx.input_data.as_ref()).unwrap(); - ctx.ext.call(0, dest, 0, vec![], false) + ctx.ext.call(Weight::zero(), dest, 0, vec![], false) }); let code_charlie = MockLoader::insert(Call, |_, _| exec_success()); @@ -2524,7 +2524,7 @@ mod tests { fn call_deny_reentry() { let code_bob = MockLoader::insert(Call, |ctx, _| { if ctx.input_data[0] == 0 { - ctx.ext.call(0, CHARLIE, 0, vec![], false) + ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], false) } else { exec_success() } @@ -2532,7 +2532,7 @@ mod tests { // call BOB with input set to '1' let code_charlie = - MockLoader::insert(Call, |ctx, _| ctx.ext.call(0, BOB, 0, vec![1], true)); + MockLoader::insert(Call, |ctx, _| ctx.ext.call(Weight::zero(), BOB, 0, vec![1], true)); ExtBuilder::default().build().execute_with(|| { let schedule = ::Schedule::get(); @@ -2695,18 +2695,30 @@ mod tests { let success_code = MockLoader::insert(Constructor, |_, _| exec_success()); let succ_fail_code = MockLoader::insert(Constructor, move |ctx, _| { ctx.ext - .instantiate(0, fail_code, ctx.ext.minimum_balance() * 100, vec![], &[]) + .instantiate( + Weight::zero(), + fail_code, + ctx.ext.minimum_balance() * 100, + vec![], + &[], + ) .ok(); exec_success() }); let succ_succ_code = MockLoader::insert(Constructor, move |ctx, _| { let (account_id, _) = ctx .ext - .instantiate(0, success_code, ctx.ext.minimum_balance() * 100, vec![], &[]) + .instantiate( + Weight::zero(), + success_code, + ctx.ext.minimum_balance() * 100, + vec![], + &[], + ) .unwrap(); // a plain call should not influence the account counter - ctx.ext.call(0, account_id, 0, vec![], false).unwrap(); + ctx.ext.call(Weight::zero(), account_id, 0, vec![], false).unwrap(); exec_success() }); diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index 41df125da0170..ae20e4eeb0def 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -107,7 +107,7 @@ where /// /// Passing `0` as amount is interpreted as "all remaining gas". pub fn nested(&mut self, amount: Weight) -> Result { - let amount = if amount == 0 { self.gas_left } else { amount }; + let amount = if amount == Weight::zero() { self.gas_left } else { amount }; // NOTE that it is ok to allocate all available gas since it still ensured // by `charge` that it doesn't reach zero. @@ -121,7 +121,7 @@ where /// Absorb the remaining gas of a nested meter after we are done using it. pub fn absorb_nested(&mut self, nested: Self) { - if self.gas_left == 0 { + if self.gas_left == Weight::zero() { // All of the remaining gas was inherited by the nested gas meter. When absorbing // we can therefore safely inherit the lowest gas that the nested gas meter experienced // as long as it is lower than the lowest gas that was experienced by the parent. @@ -157,7 +157,7 @@ where } let amount = token.weight(); - let new_value = self.gas_left.checked_sub(amount); + let new_value = self.gas_left.checked_sub(&amount); // We always consume the gas even if there is not enough gas. self.gas_left = new_value.unwrap_or_else(Zero::zero); @@ -227,7 +227,7 @@ where #[cfg(test)] mod tests { - use super::{GasMeter, Token}; + use super::{GasMeter, Token, Weight}; use crate::tests::Test; /// A simple utility macro that helps to match against a @@ -271,20 +271,20 @@ mod tests { #[derive(Copy, Clone, PartialEq, Eq, Debug)] struct SimpleToken(u64); impl Token for SimpleToken { - fn weight(&self) -> u64 { - self.0 + fn weight(&self) -> Weight { + Weight::from_ref_time(self.0) } } #[test] fn it_works() { - let gas_meter = GasMeter::::new(50000); - assert_eq!(gas_meter.gas_left(), 50000); + let gas_meter = GasMeter::::new(Weight::from_ref_time(50000)); + assert_eq!(gas_meter.gas_left(), Weight::from_ref_time(50000)); } #[test] fn tracing() { - let mut gas_meter = GasMeter::::new(50000); + let mut gas_meter = GasMeter::::new(Weight::from_ref_time(50000)); assert!(!gas_meter.charge(SimpleToken(1)).is_err()); let mut tokens = gas_meter.tokens().iter(); @@ -294,7 +294,7 @@ mod tests { // This test makes sure that nothing can be executed if there is no gas. #[test] fn refuse_to_execute_anything_if_zero() { - let mut gas_meter = GasMeter::::new(0); + let mut gas_meter = GasMeter::::new(Weight::zero()); assert!(gas_meter.charge(SimpleToken(1)).is_err()); } @@ -305,7 +305,7 @@ mod tests { // if the gas meter runs out of gas. However, this is just a nice property to have. #[test] fn overcharge_is_unrecoverable() { - let mut gas_meter = GasMeter::::new(200); + let mut gas_meter = GasMeter::::new(Weight::from_ref_time(200)); // The first charge is should lead to OOG. assert!(gas_meter.charge(SimpleToken(300)).is_err()); @@ -318,7 +318,7 @@ mod tests { // possible. #[test] fn charge_exact_amount() { - let mut gas_meter = GasMeter::::new(25); + let mut gas_meter = GasMeter::::new(Weight::from_ref_time(25)); assert!(!gas_meter.charge(SimpleToken(25)).is_err()); } } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 06fd419d88bf3..ee0db17ade95b 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -110,7 +110,7 @@ use frame_support::{ dispatch::Dispatchable, ensure, traits::{ConstU32, Contains, Currency, Get, Randomness, ReservableCurrency, Time}, - weights::{DispatchClass, GetDispatchInfo, Pays, PostDispatchInfo, Weight}, + weights::{DispatchClass, GetDispatchInfo, Pays, PostDispatchInfo, RefTimeWeight, Weight}, BoundedVec, }; use frame_system::{limits::BlockWeights, Pallet as System}; @@ -214,7 +214,7 @@ impl, const P: u32> Get for DefaultContractAccessWe .get(DispatchClass::Normal) .max_total .unwrap_or(block_weights.max_block) / - Weight::from(P) + RefTimeWeight::from(P) } } @@ -873,8 +873,8 @@ where ); ContractExecResult { result: output.result.map_err(|r| r.error), - gas_consumed: output.gas_meter.gas_consumed(), - gas_required: output.gas_meter.gas_required(), + gas_consumed: output.gas_meter.gas_consumed().ref_time(), + gas_required: output.gas_meter.gas_required().ref_time(), storage_deposit: output.storage_deposit, debug_message: debug_message.unwrap_or_default(), } @@ -918,8 +918,8 @@ where .result .map(|(account_id, result)| InstantiateReturnValue { result, account_id }) .map_err(|e| e.error), - gas_consumed: output.gas_meter.gas_consumed(), - gas_required: output.gas_meter.gas_required(), + gas_consumed: output.gas_meter.gas_consumed().ref_time(), + gas_required: output.gas_meter.gas_required().ref_time(), storage_deposit: output.storage_deposit, debug_message: debug_message.unwrap_or_default(), } diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index 19e699a855461..9d90cf38269b1 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -26,7 +26,7 @@ use sp_std::{marker::PhantomData, prelude::*}; /// Wrapper for all migrations of this pallet, based on `StorageVersion`. pub fn migrate() -> Weight { let version = StorageVersion::get::>(); - let mut weight: Weight = 0; + let mut weight = Weight::new(); if version < 4 { weight = weight.saturating_add(v4::migrate::()); @@ -127,7 +127,7 @@ mod v5 { type DeletionQueue = StorageValue, Vec>; pub fn migrate() -> Weight { - let mut weight: Weight = 0; + let mut weight = Weight::new(); >::translate(|_key, old: OldContractInfo| { weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); @@ -216,7 +216,7 @@ mod v6 { type OwnerInfoOf = StorageMap, Identity, CodeHash, OwnerInfo>; pub fn migrate() -> Weight { - let mut weight: Weight = 0; + let mut weight = Weight::new(); >::translate(|_key, old: OldContractInfo| { weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index 907ce9e088648..b5c80642a5356 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -21,7 +21,7 @@ use crate::{weights::WeightInfo, Config}; use codec::{Decode, Encode}; -use frame_support::{weights::Weight, DefaultNoBound}; +use frame_support::{weights::RefTimeWeight, DefaultNoBound}; use pallet_contracts_proc_macro::{ScheduleDebug, WeightDebug}; use scale_info::TypeInfo; #[cfg(feature = "std")] @@ -255,166 +255,166 @@ pub struct InstructionWeights { #[scale_info(skip_type_params(T))] pub struct HostFnWeights { /// Weight of calling `seal_caller`. - pub caller: Weight, + pub caller: RefTimeWeight, /// Weight of calling `seal_is_contract`. - pub is_contract: Weight, + pub is_contract: RefTimeWeight, /// Weight of calling `seal_code_hash`. - pub code_hash: Weight, + pub code_hash: RefTimeWeight, /// Weight of calling `seal_own_code_hash`. - pub own_code_hash: Weight, + pub own_code_hash: RefTimeWeight, /// Weight of calling `seal_caller_is_origin`. - pub caller_is_origin: Weight, + pub caller_is_origin: RefTimeWeight, /// Weight of calling `seal_address`. - pub address: Weight, + pub address: RefTimeWeight, /// Weight of calling `seal_gas_left`. - pub gas_left: Weight, + pub gas_left: RefTimeWeight, /// Weight of calling `seal_balance`. - pub balance: Weight, + pub balance: RefTimeWeight, /// Weight of calling `seal_value_transferred`. - pub value_transferred: Weight, + pub value_transferred: RefTimeWeight, /// Weight of calling `seal_minimum_balance`. - pub minimum_balance: Weight, + pub minimum_balance: RefTimeWeight, /// Weight of calling `seal_block_number`. - pub block_number: Weight, + pub block_number: RefTimeWeight, /// Weight of calling `seal_now`. - pub now: Weight, + pub now: RefTimeWeight, /// Weight of calling `seal_weight_to_fee`. - pub weight_to_fee: Weight, + pub weight_to_fee: RefTimeWeight, /// Weight of calling `gas`. - pub gas: Weight, + pub gas: RefTimeWeight, /// Weight of calling `seal_input`. - pub input: Weight, + pub input: RefTimeWeight, /// Weight per input byte copied to contract memory by `seal_input`. - pub input_per_byte: Weight, + pub input_per_byte: RefTimeWeight, /// Weight of calling `seal_return`. - pub r#return: Weight, + pub r#return: RefTimeWeight, /// Weight per byte returned through `seal_return`. - pub return_per_byte: Weight, + pub return_per_byte: RefTimeWeight, /// Weight of calling `seal_terminate`. - pub terminate: Weight, + pub terminate: RefTimeWeight, /// Weight of calling `seal_random`. - pub random: Weight, + pub random: RefTimeWeight, /// Weight of calling `seal_reposit_event`. - pub deposit_event: Weight, + pub deposit_event: RefTimeWeight, /// Weight per topic supplied to `seal_deposit_event`. - pub deposit_event_per_topic: Weight, + pub deposit_event_per_topic: RefTimeWeight, /// Weight per byte of an event deposited through `seal_deposit_event`. - pub deposit_event_per_byte: Weight, + pub deposit_event_per_byte: RefTimeWeight, /// Weight of calling `seal_debug_message`. - pub debug_message: Weight, + pub debug_message: RefTimeWeight, /// Weight of calling `seal_set_storage`. - pub set_storage: Weight, + pub set_storage: RefTimeWeight, /// Weight per written byten of an item stored with `seal_set_storage`. - pub set_storage_per_new_byte: Weight, + pub set_storage_per_new_byte: RefTimeWeight, /// Weight per overwritten byte of an item stored with `seal_set_storage`. - pub set_storage_per_old_byte: Weight, + pub set_storage_per_old_byte: RefTimeWeight, /// Weight of calling `seal_set_code_hash`. - pub set_code_hash: Weight, + pub set_code_hash: RefTimeWeight, /// Weight of calling `seal_clear_storage`. - pub clear_storage: Weight, + pub clear_storage: RefTimeWeight, /// Weight of calling `seal_clear_storage` per byte of the stored item. - pub clear_storage_per_byte: Weight, + pub clear_storage_per_byte: RefTimeWeight, /// Weight of calling `seal_contains_storage`. - pub contains_storage: Weight, + pub contains_storage: RefTimeWeight, /// Weight of calling `seal_contains_storage` per byte of the stored item. - pub contains_storage_per_byte: Weight, + pub contains_storage_per_byte: RefTimeWeight, /// Weight of calling `seal_get_storage`. - pub get_storage: Weight, + pub get_storage: RefTimeWeight, /// Weight per byte of an item received via `seal_get_storage`. - pub get_storage_per_byte: Weight, + pub get_storage_per_byte: RefTimeWeight, /// Weight of calling `seal_take_storage`. - pub take_storage: Weight, + pub take_storage: RefTimeWeight, /// Weight per byte of an item received via `seal_take_storage`. - pub take_storage_per_byte: Weight, + pub take_storage_per_byte: RefTimeWeight, /// Weight of calling `seal_transfer`. - pub transfer: Weight, + pub transfer: RefTimeWeight, /// Weight of calling `seal_call`. - pub call: Weight, + pub call: RefTimeWeight, /// Weight of calling `seal_delegate_call`. - pub delegate_call: Weight, + pub delegate_call: RefTimeWeight, /// Weight surcharge that is claimed if `seal_call` does a balance transfer. - pub call_transfer_surcharge: Weight, + pub call_transfer_surcharge: RefTimeWeight, /// Weight per byte that is cloned by supplying the `CLONE_INPUT` flag. - pub call_per_cloned_byte: Weight, + pub call_per_cloned_byte: RefTimeWeight, /// Weight of calling `seal_instantiate`. - pub instantiate: Weight, + pub instantiate: RefTimeWeight, /// Weight surcharge that is claimed if `seal_instantiate` does a balance transfer. - pub instantiate_transfer_surcharge: Weight, + pub instantiate_transfer_surcharge: RefTimeWeight, /// Weight per salt byte supplied to `seal_instantiate`. - pub instantiate_per_salt_byte: Weight, + pub instantiate_per_salt_byte: RefTimeWeight, /// Weight of calling `seal_hash_sha_256`. - pub hash_sha2_256: Weight, + pub hash_sha2_256: RefTimeWeight, /// Weight per byte hashed by `seal_hash_sha_256`. - pub hash_sha2_256_per_byte: Weight, + pub hash_sha2_256_per_byte: RefTimeWeight, /// Weight of calling `seal_hash_keccak_256`. - pub hash_keccak_256: Weight, + pub hash_keccak_256: RefTimeWeight, /// Weight per byte hashed by `seal_hash_keccak_256`. - pub hash_keccak_256_per_byte: Weight, + pub hash_keccak_256_per_byte: RefTimeWeight, /// Weight of calling `seal_hash_blake2_256`. - pub hash_blake2_256: Weight, + pub hash_blake2_256: RefTimeWeight, /// Weight per byte hashed by `seal_hash_blake2_256`. - pub hash_blake2_256_per_byte: Weight, + pub hash_blake2_256_per_byte: RefTimeWeight, /// Weight of calling `seal_hash_blake2_128`. - pub hash_blake2_128: Weight, + pub hash_blake2_128: RefTimeWeight, /// Weight per byte hashed by `seal_hash_blake2_128`. - pub hash_blake2_128_per_byte: Weight, + pub hash_blake2_128_per_byte: RefTimeWeight, /// Weight of calling `seal_ecdsa_recover`. - pub ecdsa_recover: Weight, + pub ecdsa_recover: RefTimeWeight, /// Weight of calling `seal_ecdsa_to_eth_address`. - pub ecdsa_to_eth_address: Weight, + pub ecdsa_to_eth_address: RefTimeWeight, /// The type parameter is used in the default implementation. #[codec(skip)] @@ -435,19 +435,19 @@ macro_rules! call_zero { macro_rules! cost_args { ($name:ident, $( $arg: expr ),+) => { - (T::WeightInfo::$name($( $arg ),+).saturating_sub(call_zero!($name, $( $arg ),+))) + (T::WeightInfo::$name($( $arg ),+).saturating_sub(call_zero!($name, $( $arg ),+))).ref_time() } } macro_rules! cost_batched_args { ($name:ident, $( $arg: expr ),+) => { - cost_args!($name, $( $arg ),+) / Weight::from(API_BENCHMARK_BATCH_SIZE) + cost_args!($name, $( $arg ),+) / RefTimeWeight::from(API_BENCHMARK_BATCH_SIZE) } } macro_rules! cost_instr_no_params_with_batch_size { ($name:ident, $batch_size:expr) => { - (cost_args!($name, 1) / Weight::from($batch_size)) as u32 + (cost_args!($name, 1) / RefTimeWeight::from($batch_size)) as u32 }; } diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 01c809da8675e..76e2d74f3d887 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -28,7 +28,7 @@ use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ dispatch::{DispatchError, DispatchResult}, storage::child::{self, ChildInfo}, - weights::Weight, + weights::{RefTimeWeight, Weight}, }; use scale_info::TypeInfo; use sp_core::crypto::UncheckedFrom; @@ -227,9 +227,11 @@ where let base_weight = T::WeightInfo::on_process_deletion_queue_batch(); let weight_per_queue_item = T::WeightInfo::on_initialize_per_queue_item(1) - T::WeightInfo::on_initialize_per_queue_item(0); - let weight_per_key = T::WeightInfo::on_initialize_per_trie_key(1) - - T::WeightInfo::on_initialize_per_trie_key(0); - let decoding_weight = weight_per_queue_item.saturating_mul(queue_len as Weight); + let weight_per_key = (T::WeightInfo::on_initialize_per_trie_key(1) - + T::WeightInfo::on_initialize_per_trie_key(0)) + .ref_time(); + let decoding_weight = + weight_per_queue_item.scalar_saturating_mul(queue_len as RefTimeWeight); // `weight_per_key` being zero makes no sense and would constitute a failure to // benchmark properly. We opt for not removing any keys at all in this case. @@ -237,7 +239,8 @@ where .saturating_sub(base_weight) .saturating_sub(decoding_weight) .checked_div(weight_per_key) - .unwrap_or(0) as u32; + .unwrap_or(Weight::zero()) + .ref_time() as u32; (weight_per_key, key_budget) } @@ -248,7 +251,7 @@ where pub fn process_deletion_queue_batch(weight_limit: Weight) -> Weight { let queue_len = >::decode_len().unwrap_or(0); if queue_len == 0 { - return 0 + return Weight::zero() } let (weight_per_key, mut remaining_key_budget) = @@ -282,7 +285,10 @@ where } >::put(queue); - weight_limit.saturating_sub(weight_per_key.saturating_mul(remaining_key_budget as Weight)) + let ref_time_weight = weight_limit + .ref_time() + .saturating_sub(weight_per_key.saturating_mul(remaining_key_budget as RefTimeWeight)); + Weight::from_ref_time(ref_time_weight) } /// Generates a unique trie id by returning `hash(account_id ++ nonce)`. diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 204908cc4a989..3571434bb823b 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -175,7 +175,7 @@ impl ChainExtension for TestExtension { }, 0x8002 => { let mut env = env.buf_in_buf_out(); - let weight = env.read(5)?[4].into(); + let weight = Weight::from_ref_time(env.read(5)?[4].into()); env.charge_weight(weight)?; Ok(RetVal::Converging(id)) }, @@ -332,7 +332,7 @@ parameter_types! { impl Convert> for Test { fn convert(w: Weight) -> BalanceOf { - w + w.ref_time() } } @@ -355,6 +355,10 @@ impl Contains for TestFilter { } } +parameter_types! { + pub const DeletionWeightLimit: Weight = Weight::from_ref_time(500_000_000_000); +} + impl Config for Test { type Time = Timestamp; type Randomness = Randomness; @@ -368,7 +372,7 @@ impl Config for Test { type ChainExtension = (TestExtension, DisabledExtension, RevertingExtension, TempStorageExtension); type DeletionQueueDepth = ConstU32<1024>; - type DeletionWeightLimit = ConstU64<500_000_000_000>; + type DeletionWeightLimit = DeletionWeightLimit; type Schedule = MySchedule; type DepositPerByte = DepositPerByte; type DepositPerItem = DepositPerItem; @@ -384,7 +388,7 @@ pub const BOB: AccountId32 = AccountId32::new([2u8; 32]); pub const CHARLIE: AccountId32 = AccountId32::new([3u8; 32]); pub const DJANGO: AccountId32 = AccountId32::new([4u8; 32]); -pub const GAS_LIMIT: Weight = 100_000_000_000; +pub const GAS_LIMIT: Weight = Weight::from_ref_time(100_000_000_000); pub struct ExtBuilder { existential_deposit: u64, @@ -642,7 +646,7 @@ fn run_out_of_gas() { Origin::signed(ALICE), addr, // newly created account 0, - 1_000_000_000_000, + Weight::from_ref_time(1_000_000_000_000), None, vec![], ), @@ -1826,7 +1830,7 @@ fn lazy_removal_works() { assert_matches!(child::get(trie, &[99]), Some(42)); // Run the lazy removal - Contracts::on_idle(System::block_number(), Weight::max_value()); + Contracts::on_idle(System::block_number(), Weight::MAX); // Value should be gone now assert_matches!(child::get::(trie, &[99]), None); @@ -1896,7 +1900,7 @@ fn lazy_batch_removal_works() { } // Run single lazy removal - Contracts::on_idle(System::block_number(), Weight::max_value()); + Contracts::on_idle(System::block_number(), Weight::MAX); // The single lazy removal should have removed all queued tries for trie in tries.iter() { @@ -1911,7 +1915,7 @@ fn lazy_removal_partial_remove_works() { // We create a contract with some extra keys above the weight limit let extra_keys = 7u32; - let weight_limit = 5_000_000_000; + let weight_limit = Weight::from_ref_time(5_000_000_000); let (_, max_keys) = Storage::::deletion_budget(1, weight_limit); let vals: Vec<_> = (0..max_keys + extra_keys) .map(|i| (blake2_256(&i.encode()), (i as u32), (i as u32).encode())) @@ -2085,7 +2089,7 @@ fn lazy_removal_does_no_run_on_low_remaining_weight() { assert_matches!(child::get::(trie, &[99]), Some(42)); // Run on_idle with max remaining weight, this should remove the value - Contracts::on_idle(System::block_number(), Weight::max_value()); + Contracts::on_idle(System::block_number(), Weight::MAX); // Value should be gone assert_matches!(child::get::(trie, &[99]), None); @@ -2096,7 +2100,7 @@ fn lazy_removal_does_no_run_on_low_remaining_weight() { fn lazy_removal_does_not_use_all_weight() { let (code, hash) = compile_module::("self_destruct").unwrap(); - let weight_limit = 5_000_000_000; + let weight_limit = Weight::from_ref_time(5_000_000_000); let mut ext = ExtBuilder::default().existential_deposit(50).build(); let (trie, vals, weight_per_key) = ext.execute_with(|| { @@ -2167,7 +2171,7 @@ fn lazy_removal_does_not_use_all_weight() { let weight_used = Storage::::process_deletion_queue_batch(weight_limit); // We have one less key in our trie than our weight limit suffices for - assert_eq!(weight_used, weight_limit - weight_per_key); + assert_eq!(weight_used, weight_limit - Weight::from_ref_time(weight_per_key)); // All the keys are removed for val in vals { @@ -2322,7 +2326,7 @@ fn reinstrument_does_charge() { assert!(result2.gas_consumed > result1.gas_consumed); assert_eq!( result2.gas_consumed, - result1.gas_consumed + ::WeightInfo::reinstrument(code_len), + result1.gas_consumed + ::WeightInfo::reinstrument(code_len).ref_time(), ); }); } @@ -2430,7 +2434,7 @@ fn gas_estimation_nested_call_fixed_limit() { let input: Vec = AsRef::<[u8]>::as_ref(&addr_callee) .iter() .cloned() - .chain((GAS_LIMIT / 5).to_le_bytes()) + .chain((GAS_LIMIT / 5).ref_time().to_le_bytes()) .collect(); // Call in order to determine the gas that is required for this call @@ -2454,7 +2458,7 @@ fn gas_estimation_nested_call_fixed_limit() { ALICE, addr_caller, 0, - result.gas_required, + Weight::from_ref_time(result.gas_required), Some(result.storage_deposit.charge_or_zero()), input, false, @@ -2524,7 +2528,7 @@ fn gas_estimation_call_runtime() { ALICE, addr_caller, 0, - result.gas_required, + Weight::from_ref_time(result.gas_required), None, call.encode(), false, diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 61826c7c323aa..659caafa7f0b0 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -218,14 +218,16 @@ impl Token for CodeToken { // contract code. This is why we subtract `T::*::(0)`. We need to do this at this // point because when charging the general weight for calling the contract we not know the // size of the contract. - match *self { + let ref_time_weight = match *self { Reinstrument(len) => T::WeightInfo::reinstrument(len), Load(len) => { let computation = T::WeightInfo::call_with_code_per_byte(len) .saturating_sub(T::WeightInfo::call_with_code_per_byte(0)); - let bandwidth = T::ContractAccessWeight::get().saturating_mul(len.into()); + let bandwidth = T::ContractAccessWeight::get().scalar_saturating_mul(len as u64); computation.max(bandwidth) }, - } + }; + + ref_time_weight } } diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 02a360fe86b45..f989c21b00ffc 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -365,7 +365,7 @@ mod tests { events: Default::default(), runtime_calls: Default::default(), schedule: Default::default(), - gas_meter: GasMeter::new(10_000_000_000), + gas_meter: GasMeter::new(Weight::from_ref_time(10_000_000_000)), debug_buffer: Default::default(), ecdsa_recover: Default::default(), } @@ -406,7 +406,7 @@ mod tests { code_hash, value, data: data.to_vec(), - gas_left: gas_limit, + gas_left: gas_limit.ref_time(), salt: salt.to_vec(), }); Ok(( @@ -520,7 +520,7 @@ mod tests { 16_384 } fn get_weight_price(&self, weight: Weight) -> BalanceOf { - BalanceOf::::from(1312_u32).saturating_mul(weight.into()) + BalanceOf::::from(1312_u32).saturating_mul(weight.ref_time().into()) } fn schedule(&self) -> &Schedule { &self.schedule @@ -1911,7 +1911,7 @@ mod tests { )] ); - assert!(mock_ext.gas_meter.gas_left() > 0); + assert!(mock_ext.gas_meter.gas_left() > Weight::zero()); } const CODE_DEPOSIT_EVENT_MAX_TOPICS: &str = r#" diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 1d5478a5277cd..296f322f494d0 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -327,14 +327,14 @@ impl RuntimeCosts { EcdsaRecovery => s.ecdsa_recover, ChainExtension(amount) => amount, #[cfg(feature = "unstable-interface")] - CallRuntime(weight) => weight, + CallRuntime(weight) => weight.ref_time(), SetCodeHash => s.set_code_hash, EcdsaToEthAddress => s.ecdsa_to_eth_address, }; RuntimeToken { #[cfg(test)] _created_from: *self, - weight, + weight: Weight::from_ref_time(weight), } } } @@ -857,7 +857,7 @@ where self.charge_gas(RuntimeCosts::CallSurchargeTransfer)?; } self.ext.call( - gas, + Weight::from_ref_time(gas), callee, value, input_data, @@ -906,6 +906,7 @@ where salt_ptr: u32, salt_len: u32, ) -> Result { + let gas = Weight::from_ref_time(gas); self.charge_gas(RuntimeCosts::InstantiateBase { input_data_len, salt_len })?; let value: BalanceOf<::T> = self.read_sandbox_memory_as(value_ptr)?; if value > 0u32.into() { @@ -1704,6 +1705,7 @@ pub mod env { out_ptr: u32, out_len_ptr: u32, ) -> Result<(), TrapReason> { + let gas = Weight::from_ref_time(gas); ctx.charge_gas(RuntimeCosts::WeightToFee)?; Ok(ctx.write_sandbox_output( out_ptr, diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 3c90579e65d53..17be3c3da0138 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -41,7 +41,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_contracts. @@ -166,37 +166,37 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Contracts DeletionQueue (r:1 w:0) fn on_process_deletion_queue_batch() -> Weight { - (1_654_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(1_654_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { - (8_564_000 as Weight) + Weight::from_ref_time(8_564_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((868_000 as Weight).saturating_mul(k 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((1 as Weight).saturating_mul(k as Weight))) + .saturating_add(Weight::from_ref_time(868_000 as RefTimeWeight).scalar_saturating_mul(k as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(k as RefTimeWeight))) } // Storage: Contracts DeletionQueue (r:1 w:0) /// The range of component `q` is `[0, 1024]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((1_944_000 as Weight).saturating_mul(q as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_944_000 as RefTimeWeight).scalar_saturating_mul(q as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Contracts PristineCode (r:1 w:0) // Storage: Contracts CodeStorage (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn reinstrument(c: u32, ) -> Weight { - (19_016_000 as Weight) + Weight::from_ref_time(19_016_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((49_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(49_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts CodeStorage (r:1 w:0) @@ -204,11 +204,11 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `c` is `[0, 131072]`. fn call_with_code_per_byte(c: u32, ) -> Weight { - (205_194_000 as Weight) + Weight::from_ref_time(205_194_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((53_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(53_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Contracts CodeStorage (r:1 w:1) // Storage: Contracts Nonce (r:1 w:1) @@ -220,13 +220,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 64226]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, s: u32, ) -> Weight { - (288_487_000 as Weight) + Weight::from_ref_time(288_487_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((124_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(Weight::from_ref_time(124_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Contracts CodeStorage (r:1 w:1) // Storage: Contracts Nonce (r:1 w:1) @@ -236,46 +236,46 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:1 w:1) /// The range of component `s` is `[0, 1048576]`. fn instantiate(s: u32, ) -> Weight { - (186_136_000 as Weight) + Weight::from_ref_time(186_136_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts CodeStorage (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) // Storage: System Account (r:1 w:1) fn call() -> Weight { - (149_232_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(149_232_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Contracts CodeStorage (r:1 w:1) // Storage: Contracts PristineCode (r:0 w:1) // Storage: Contracts OwnerInfoOf (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn upload_code(c: u32, ) -> Weight { - (51_721_000 as Weight) + Weight::from_ref_time(51_721_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((48_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(48_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Contracts OwnerInfoOf (r:1 w:1) // Storage: Contracts CodeStorage (r:0 w:1) // Storage: Contracts PristineCode (r:0 w:1) fn remove_code() -> Weight { - (30_016_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(30_016_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts OwnerInfoOf (r:2 w:2) fn set_code() -> Weight { - (27_192_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(27_192_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -283,11 +283,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_caller(r: u32, ) -> Weight { - (206_405_000 as Weight) + Weight::from_ref_time(206_405_000 as RefTimeWeight) // Standard Error: 112_000 - .saturating_add((40_987_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_987_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -295,12 +295,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_is_contract(r: u32, ) -> Weight { - (106_220_000 as Weight) + Weight::from_ref_time(106_220_000 as RefTimeWeight) // Standard Error: 710_000 - .saturating_add((307_648_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(307_648_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -308,12 +308,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_code_hash(r: u32, ) -> Weight { - (104_498_000 as Weight) + Weight::from_ref_time(104_498_000 as RefTimeWeight) // Standard Error: 633_000 - .saturating_add((368_901_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(368_901_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -321,11 +321,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_own_code_hash(r: u32, ) -> Weight { - (208_696_000 as Weight) + Weight::from_ref_time(208_696_000 as RefTimeWeight) // Standard Error: 101_000 - .saturating_add((44_445_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(44_445_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -333,11 +333,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_caller_is_origin(r: u32, ) -> Weight { - (205_612_000 as Weight) + Weight::from_ref_time(205_612_000 as RefTimeWeight) // Standard Error: 68_000 - .saturating_add((17_145_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(17_145_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -345,11 +345,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_address(r: u32, ) -> Weight { - (206_947_000 as Weight) + Weight::from_ref_time(206_947_000 as RefTimeWeight) // Standard Error: 107_000 - .saturating_add((40_789_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_789_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -357,11 +357,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_gas_left(r: u32, ) -> Weight { - (208_692_000 as Weight) + Weight::from_ref_time(208_692_000 as RefTimeWeight) // Standard Error: 109_000 - .saturating_add((40_600_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_600_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -369,11 +369,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_balance(r: u32, ) -> Weight { - (209_811_000 as Weight) + Weight::from_ref_time(209_811_000 as RefTimeWeight) // Standard Error: 208_000 - .saturating_add((116_831_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(116_831_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -381,11 +381,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_value_transferred(r: u32, ) -> Weight { - (207_406_000 as Weight) + Weight::from_ref_time(207_406_000 as RefTimeWeight) // Standard Error: 117_000 - .saturating_add((40_702_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_702_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -393,11 +393,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_minimum_balance(r: u32, ) -> Weight { - (209_260_000 as Weight) + Weight::from_ref_time(209_260_000 as RefTimeWeight) // Standard Error: 130_000 - .saturating_add((40_479_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_479_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -405,11 +405,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_block_number(r: u32, ) -> Weight { - (206_448_000 as Weight) + Weight::from_ref_time(206_448_000 as RefTimeWeight) // Standard Error: 95_000 - .saturating_add((40_134_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_134_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -417,11 +417,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_now(r: u32, ) -> Weight { - (206_969_000 as Weight) + Weight::from_ref_time(206_969_000 as RefTimeWeight) // Standard Error: 116_000 - .saturating_add((40_251_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_251_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -430,11 +430,11 @@ impl WeightInfo for SubstrateWeight { // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_weight_to_fee(r: u32, ) -> Weight { - (211_611_000 as Weight) + Weight::from_ref_time(211_611_000 as RefTimeWeight) // Standard Error: 175_000 - .saturating_add((98_675_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(98_675_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -442,11 +442,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_gas(r: u32, ) -> Weight { - (134_484_000 as Weight) + Weight::from_ref_time(134_484_000 as RefTimeWeight) // Standard Error: 57_000 - .saturating_add((19_329_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(19_329_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -454,11 +454,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_input(r: u32, ) -> Weight { - (208_556_000 as Weight) + Weight::from_ref_time(208_556_000 as RefTimeWeight) // Standard Error: 125_000 - .saturating_add((40_328_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_328_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -466,11 +466,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_input_per_kb(n: u32, ) -> Weight { - (268_886_000 as Weight) + Weight::from_ref_time(268_886_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((9_627_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(9_627_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -478,9 +478,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 1]`. fn seal_return(_r: u32, ) -> Weight { - (203_591_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(203_591_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -488,11 +488,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_return_per_kb(n: u32, ) -> Weight { - (204_258_000 as Weight) + Weight::from_ref_time(204_258_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((183_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(183_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -502,13 +502,13 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:1 w:1) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { - (206_625_000 as Weight) + Weight::from_ref_time(206_625_000 as RefTimeWeight) // Standard Error: 672_000 - .saturating_add((59_377_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(59_377_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((4 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((5 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -517,11 +517,11 @@ impl WeightInfo for SubstrateWeight { // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_random(r: u32, ) -> Weight { - (208_866_000 as Weight) + Weight::from_ref_time(208_866_000 as RefTimeWeight) // Standard Error: 164_000 - .saturating_add((133_438_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(133_438_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -529,11 +529,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_deposit_event(r: u32, ) -> Weight { - (220_860_000 as Weight) + Weight::from_ref_time(220_860_000 as RefTimeWeight) // Standard Error: 209_000 - .saturating_add((239_951_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(239_951_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -543,15 +543,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 16]`. fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - (439_782_000 as Weight) + Weight::from_ref_time(439_782_000 as RefTimeWeight) // Standard Error: 1_643_000 - .saturating_add((264_687_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(264_687_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 323_000 - .saturating_add((67_636_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(t as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((80 as Weight).saturating_mul(t as Weight))) + .saturating_add(Weight::from_ref_time(67_636_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((80 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((80 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -559,128 +559,128 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_debug_message(r: u32, ) -> Weight { - (140_280_000 as Weight) + Weight::from_ref_time(140_280_000 as RefTimeWeight) // Standard Error: 82_000 - .saturating_add((32_717_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(32_717_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_set_storage(r: u32, ) -> Weight { - (161_247_000 as Weight) + Weight::from_ref_time(161_247_000 as RefTimeWeight) // Standard Error: 883_000 - .saturating_add((423_997_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((80 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(423_997_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { - (529_247_000 as Weight) + Weight::from_ref_time(529_247_000 as RefTimeWeight) // Standard Error: 2_745_000 - .saturating_add((85_282_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(55 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(53 as Weight)) - .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(85_282_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(55 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(53 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { - (529_812_000 as Weight) + Weight::from_ref_time(529_812_000 as RefTimeWeight) // Standard Error: 2_513_000 - .saturating_add((74_554_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(55 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(53 as Weight)) - .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(74_554_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(55 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(53 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_clear_storage(r: u32, ) -> Weight { - (184_803_000 as Weight) + Weight::from_ref_time(184_803_000 as RefTimeWeight) // Standard Error: 733_000 - .saturating_add((404_933_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((80 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(404_933_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_clear_storage_per_kb(n: u32, ) -> Weight { - (500_958_000 as Weight) + Weight::from_ref_time(500_958_000 as RefTimeWeight) // Standard Error: 2_980_000 - .saturating_add((75_996_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(55 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(52 as Weight)) - .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(75_996_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(55 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(52 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_get_storage(r: u32, ) -> Weight { - (177_682_000 as Weight) + Weight::from_ref_time(177_682_000 as RefTimeWeight) // Standard Error: 743_000 - .saturating_add((338_172_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(338_172_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_get_storage_per_kb(n: u32, ) -> Weight { - (465_285_000 as Weight) + Weight::from_ref_time(465_285_000 as RefTimeWeight) // Standard Error: 2_599_000 - .saturating_add((155_106_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(55 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(155_106_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(55 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_contains_storage(r: u32, ) -> Weight { - (179_118_000 as Weight) + Weight::from_ref_time(179_118_000 as RefTimeWeight) // Standard Error: 572_000 - .saturating_add((311_083_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(311_083_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_contains_storage_per_kb(n: u32, ) -> Weight { - (423_056_000 as Weight) + Weight::from_ref_time(423_056_000 as RefTimeWeight) // Standard Error: 2_037_000 - .saturating_add((69_665_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(54 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(69_665_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(54 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_take_storage(r: u32, ) -> Weight { - (188_884_000 as Weight) + Weight::from_ref_time(188_884_000 as RefTimeWeight) // Standard Error: 761_000 - .saturating_add((432_781_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((80 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(432_781_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_take_storage_per_kb(n: u32, ) -> Weight { - (532_408_000 as Weight) + Weight::from_ref_time(532_408_000 as RefTimeWeight) // Standard Error: 3_348_000 - .saturating_add((164_943_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(55 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(53 as Weight)) - .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(164_943_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(55 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(53 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -688,13 +688,13 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_transfer(r: u32, ) -> Weight { - (127_181_000 as Weight) + Weight::from_ref_time(127_181_000 as RefTimeWeight) // Standard Error: 1_495_000 - .saturating_add((1_500_589_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((80 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(1_500_589_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -702,13 +702,13 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_call(r: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 3_803_000 - .saturating_add((14_860_909_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((80 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(14_860_909_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -716,11 +716,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_delegate_call(r: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 6_045_000 - .saturating_add((14_797_140_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads((79 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(14_797_140_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((79 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:81 w:81) @@ -729,15 +729,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `t` is `[0, 1]`. /// The range of component `c` is `[0, 1024]`. fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { - (9_196_444_000 as Weight) + Weight::from_ref_time(9_196_444_000 as RefTimeWeight) // Standard Error: 20_486_000 - .saturating_add((1_458_153_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(1_458_153_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 8_000 - .saturating_add((9_718_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(85 as Weight)) - .saturating_add(T::DbWeight::get().reads((81 as Weight).saturating_mul(t as Weight))) - .saturating_add(T::DbWeight::get().writes(81 as Weight)) - .saturating_add(T::DbWeight::get().writes((81 as Weight).saturating_mul(t as Weight))) + .saturating_add(Weight::from_ref_time(9_718_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(85 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((81 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(81 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((81 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -747,13 +747,13 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:80 w:80) /// The range of component `r` is `[0, 20]`. fn seal_instantiate(r: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 36_253_000 - .saturating_add((21_201_529_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().reads((320 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((320 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(21_201_529_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((320 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((320 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: System Account (r:81 w:81) // Storage: Contracts ContractInfoOf (r:81 w:81) @@ -764,15 +764,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `t` is `[0, 1]`. /// The range of component `s` is `[0, 960]`. fn seal_instantiate_per_transfer_salt_kb(t: u32, s: u32, ) -> Weight { - (12_282_498_000 as Weight) + Weight::from_ref_time(12_282_498_000 as RefTimeWeight) // Standard Error: 48_112_000 - .saturating_add((720_795_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(720_795_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 22_000 - .saturating_add((124_274_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(167 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(t as Weight))) - .saturating_add(T::DbWeight::get().writes(165 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(t as Weight))) + .saturating_add(Weight::from_ref_time(124_274_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(167 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(165 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -780,11 +780,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { - (203_959_000 as Weight) + Weight::from_ref_time(203_959_000 as RefTimeWeight) // Standard Error: 142_000 - .saturating_add((61_311_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(61_311_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -792,11 +792,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - (349_915_000 as Weight) + Weight::from_ref_time(349_915_000 as RefTimeWeight) // Standard Error: 40_000 - .saturating_add((320_652_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(320_652_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -804,11 +804,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { - (209_219_000 as Weight) + Weight::from_ref_time(209_219_000 as RefTimeWeight) // Standard Error: 157_000 - .saturating_add((73_728_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(73_728_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -816,11 +816,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - (208_860_000 as Weight) + Weight::from_ref_time(208_860_000 as RefTimeWeight) // Standard Error: 25_000 - .saturating_add((245_718_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(245_718_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -828,11 +828,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { - (206_165_000 as Weight) + Weight::from_ref_time(206_165_000 as RefTimeWeight) // Standard Error: 138_000 - .saturating_add((51_644_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(51_644_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -840,11 +840,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - (255_955_000 as Weight) + Weight::from_ref_time(255_955_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((95_090_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(95_090_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -852,11 +852,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { - (208_153_000 as Weight) + Weight::from_ref_time(208_153_000 as RefTimeWeight) // Standard Error: 140_000 - .saturating_add((51_264_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(51_264_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -864,11 +864,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - (278_368_000 as Weight) + Weight::from_ref_time(278_368_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((95_006_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(95_006_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -876,11 +876,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { - (331_955_000 as Weight) + Weight::from_ref_time(331_955_000 as RefTimeWeight) // Standard Error: 1_155_000 - .saturating_add((3_069_955_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(3_069_955_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -888,11 +888,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { - (207_838_000 as Weight) + Weight::from_ref_time(207_838_000 as RefTimeWeight) // Standard Error: 783_000 - .saturating_add((2_058_503_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_058_503_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -901,317 +901,317 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:16 w:16) /// The range of component `r` is `[0, 20]`. fn seal_set_code_hash(r: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 1_567_000 - .saturating_add((774_380_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads((79 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes((79 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(774_380_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((79 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes((79 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } /// The range of component `r` is `[0, 50]`. fn instr_i64const(r: u32, ) -> Weight { - (73_955_000 as Weight) + Weight::from_ref_time(73_955_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((612_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(612_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64load(r: u32, ) -> Weight { - (74_057_000 as Weight) + Weight::from_ref_time(74_057_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((1_324_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_324_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64store(r: u32, ) -> Weight { - (74_137_000 as Weight) + Weight::from_ref_time(74_137_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((1_427_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_427_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_select(r: u32, ) -> Weight { - (73_844_000 as Weight) + Weight::from_ref_time(73_844_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_773_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_773_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_if(r: u32, ) -> Weight { - (73_979_000 as Weight) + Weight::from_ref_time(73_979_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((1_952_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_952_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_br(r: u32, ) -> Weight { - (73_924_000 as Weight) + Weight::from_ref_time(73_924_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((941_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(941_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_br_if(r: u32, ) -> Weight { - (73_574_000 as Weight) + Weight::from_ref_time(73_574_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((1_439_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_439_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_br_table(r: u32, ) -> Weight { - (73_343_000 as Weight) + Weight::from_ref_time(73_343_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((1_603_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_603_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `e` is `[1, 256]`. fn instr_br_table_per_entry(e: u32, ) -> Weight { - (76_267_000 as Weight) + Weight::from_ref_time(76_267_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(e as Weight)) + .saturating_add(Weight::from_ref_time(4_000 as RefTimeWeight).scalar_saturating_mul(e as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_call(r: u32, ) -> Weight { - (74_877_000 as Weight) + Weight::from_ref_time(74_877_000 as RefTimeWeight) // Standard Error: 12_000 - .saturating_add((7_144_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(7_144_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_call_indirect(r: u32, ) -> Weight { - (88_665_000 as Weight) + Weight::from_ref_time(88_665_000 as RefTimeWeight) // Standard Error: 20_000 - .saturating_add((9_142_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(9_142_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `p` is `[0, 128]`. fn instr_call_indirect_per_param(p: u32, ) -> Weight { - (98_600_000 as Weight) + Weight::from_ref_time(98_600_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((469_000 as Weight).saturating_mul(p as Weight)) + .saturating_add(Weight::from_ref_time(469_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_get(r: u32, ) -> Weight { - (74_555_000 as Weight) + Weight::from_ref_time(74_555_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((624_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(624_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_set(r: u32, ) -> Weight { - (74_329_000 as Weight) + Weight::from_ref_time(74_329_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((688_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(688_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_tee(r: u32, ) -> Weight { - (74_612_000 as Weight) + Weight::from_ref_time(74_612_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((909_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(909_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_global_get(r: u32, ) -> Weight { - (76_906_000 as Weight) + Weight::from_ref_time(76_906_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_192_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_192_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_global_set(r: u32, ) -> Weight { - (76_979_000 as Weight) + Weight::from_ref_time(76_979_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_361_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_361_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_memory_current(r: u32, ) -> Weight { - (74_370_000 as Weight) + Weight::from_ref_time(74_370_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((661_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(661_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 1]`. fn instr_memory_grow(r: u32, ) -> Weight { - (73_584_000 as Weight) + Weight::from_ref_time(73_584_000 as RefTimeWeight) // Standard Error: 353_000 - .saturating_add((187_114_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(187_114_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64clz(r: u32, ) -> Weight { - (74_206_000 as Weight) + Weight::from_ref_time(74_206_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((884_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(884_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ctz(r: u32, ) -> Weight { - (73_992_000 as Weight) + Weight::from_ref_time(73_992_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((893_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(893_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64popcnt(r: u32, ) -> Weight { - (73_985_000 as Weight) + Weight::from_ref_time(73_985_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((891_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(891_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64eqz(r: u32, ) -> Weight { - (74_117_000 as Weight) + Weight::from_ref_time(74_117_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((901_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(901_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendsi32(r: u32, ) -> Weight { - (73_981_000 as Weight) + Weight::from_ref_time(73_981_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((866_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(866_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendui32(r: u32, ) -> Weight { - (74_104_000 as Weight) + Weight::from_ref_time(74_104_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((868_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(868_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i32wrapi64(r: u32, ) -> Weight { - (74_293_000 as Weight) + Weight::from_ref_time(74_293_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((878_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(878_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64eq(r: u32, ) -> Weight { - (74_055_000 as Weight) + Weight::from_ref_time(74_055_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_350_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_350_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ne(r: u32, ) -> Weight { - (73_710_000 as Weight) + Weight::from_ref_time(73_710_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_360_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64lts(r: u32, ) -> Weight { - (73_917_000 as Weight) + Weight::from_ref_time(73_917_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_355_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_355_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ltu(r: u32, ) -> Weight { - (74_048_000 as Weight) + Weight::from_ref_time(74_048_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_360_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64gts(r: u32, ) -> Weight { - (74_029_000 as Weight) + Weight::from_ref_time(74_029_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_349_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_349_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64gtu(r: u32, ) -> Weight { - (74_267_000 as Weight) + Weight::from_ref_time(74_267_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_353_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_353_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64les(r: u32, ) -> Weight { - (73_952_000 as Weight) + Weight::from_ref_time(73_952_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_350_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_350_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64leu(r: u32, ) -> Weight { - (73_851_000 as Weight) + Weight::from_ref_time(73_851_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_368_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_368_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ges(r: u32, ) -> Weight { - (74_034_000 as Weight) + Weight::from_ref_time(74_034_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_348_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_348_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64geu(r: u32, ) -> Weight { - (73_979_000 as Weight) + Weight::from_ref_time(73_979_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((1_353_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_353_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64add(r: u32, ) -> Weight { - (74_000_000 as Weight) + Weight::from_ref_time(74_000_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_328_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_328_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64sub(r: u32, ) -> Weight { - (73_883_000 as Weight) + Weight::from_ref_time(73_883_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_331_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_331_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64mul(r: u32, ) -> Weight { - (74_216_000 as Weight) + Weight::from_ref_time(74_216_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((1_324_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_324_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64divs(r: u32, ) -> Weight { - (73_989_000 as Weight) + Weight::from_ref_time(73_989_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_998_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_998_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64divu(r: u32, ) -> Weight { - (73_857_000 as Weight) + Weight::from_ref_time(73_857_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((2_073_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(2_073_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rems(r: u32, ) -> Weight { - (73_801_000 as Weight) + Weight::from_ref_time(73_801_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((2_027_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(2_027_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64remu(r: u32, ) -> Weight { - (74_130_000 as Weight) + Weight::from_ref_time(74_130_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((2_064_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(2_064_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64and(r: u32, ) -> Weight { - (74_071_000 as Weight) + Weight::from_ref_time(74_071_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_327_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_327_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64or(r: u32, ) -> Weight { - (74_201_000 as Weight) + Weight::from_ref_time(74_201_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((1_330_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_330_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64xor(r: u32, ) -> Weight { - (74_241_000 as Weight) + Weight::from_ref_time(74_241_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_321_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_321_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shl(r: u32, ) -> Weight { - (74_331_000 as Weight) + Weight::from_ref_time(74_331_000 as RefTimeWeight) // Standard Error: 6_000 - .saturating_add((1_347_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_347_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shrs(r: u32, ) -> Weight { - (73_674_000 as Weight) + Weight::from_ref_time(73_674_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_359_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_359_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shru(r: u32, ) -> Weight { - (73_807_000 as Weight) + Weight::from_ref_time(73_807_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_358_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_358_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotl(r: u32, ) -> Weight { - (73_725_000 as Weight) + Weight::from_ref_time(73_725_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_358_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_358_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotr(r: u32, ) -> Weight { - (73_755_000 as Weight) + Weight::from_ref_time(73_755_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_360_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } } @@ -1219,37 +1219,37 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: Contracts DeletionQueue (r:1 w:0) fn on_process_deletion_queue_batch() -> Weight { - (1_654_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(1_654_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { - (8_564_000 as Weight) + Weight::from_ref_time(8_564_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((868_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) + .saturating_add(Weight::from_ref_time(868_000 as RefTimeWeight).scalar_saturating_mul(k as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(k as RefTimeWeight))) } // Storage: Contracts DeletionQueue (r:1 w:0) /// The range of component `q` is `[0, 1024]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((1_944_000 as Weight).saturating_mul(q as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_944_000 as RefTimeWeight).scalar_saturating_mul(q as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Contracts PristineCode (r:1 w:0) // Storage: Contracts CodeStorage (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn reinstrument(c: u32, ) -> Weight { - (19_016_000 as Weight) + Weight::from_ref_time(19_016_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((49_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(49_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts CodeStorage (r:1 w:0) @@ -1257,11 +1257,11 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `c` is `[0, 131072]`. fn call_with_code_per_byte(c: u32, ) -> Weight { - (205_194_000 as Weight) + Weight::from_ref_time(205_194_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((53_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(53_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Contracts CodeStorage (r:1 w:1) // Storage: Contracts Nonce (r:1 w:1) @@ -1273,13 +1273,13 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 64226]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, s: u32, ) -> Weight { - (288_487_000 as Weight) + Weight::from_ref_time(288_487_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((124_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(Weight::from_ref_time(124_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Contracts CodeStorage (r:1 w:1) // Storage: Contracts Nonce (r:1 w:1) @@ -1289,46 +1289,46 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:1 w:1) /// The range of component `s` is `[0, 1048576]`. fn instantiate(s: u32, ) -> Weight { - (186_136_000 as Weight) + Weight::from_ref_time(186_136_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts CodeStorage (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) // Storage: System Account (r:1 w:1) fn call() -> Weight { - (149_232_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(149_232_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Contracts CodeStorage (r:1 w:1) // Storage: Contracts PristineCode (r:0 w:1) // Storage: Contracts OwnerInfoOf (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn upload_code(c: u32, ) -> Weight { - (51_721_000 as Weight) + Weight::from_ref_time(51_721_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((48_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(48_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Contracts OwnerInfoOf (r:1 w:1) // Storage: Contracts CodeStorage (r:0 w:1) // Storage: Contracts PristineCode (r:0 w:1) fn remove_code() -> Weight { - (30_016_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(30_016_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts OwnerInfoOf (r:2 w:2) fn set_code() -> Weight { - (27_192_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(27_192_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1336,11 +1336,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_caller(r: u32, ) -> Weight { - (206_405_000 as Weight) + Weight::from_ref_time(206_405_000 as RefTimeWeight) // Standard Error: 112_000 - .saturating_add((40_987_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_987_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1348,12 +1348,12 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_is_contract(r: u32, ) -> Weight { - (106_220_000 as Weight) + Weight::from_ref_time(106_220_000 as RefTimeWeight) // Standard Error: 710_000 - .saturating_add((307_648_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(307_648_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1361,12 +1361,12 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_code_hash(r: u32, ) -> Weight { - (104_498_000 as Weight) + Weight::from_ref_time(104_498_000 as RefTimeWeight) // Standard Error: 633_000 - .saturating_add((368_901_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(368_901_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1374,11 +1374,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_own_code_hash(r: u32, ) -> Weight { - (208_696_000 as Weight) + Weight::from_ref_time(208_696_000 as RefTimeWeight) // Standard Error: 101_000 - .saturating_add((44_445_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(44_445_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1386,11 +1386,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_caller_is_origin(r: u32, ) -> Weight { - (205_612_000 as Weight) + Weight::from_ref_time(205_612_000 as RefTimeWeight) // Standard Error: 68_000 - .saturating_add((17_145_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(17_145_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1398,11 +1398,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_address(r: u32, ) -> Weight { - (206_947_000 as Weight) + Weight::from_ref_time(206_947_000 as RefTimeWeight) // Standard Error: 107_000 - .saturating_add((40_789_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_789_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1410,11 +1410,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_gas_left(r: u32, ) -> Weight { - (208_692_000 as Weight) + Weight::from_ref_time(208_692_000 as RefTimeWeight) // Standard Error: 109_000 - .saturating_add((40_600_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_600_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1422,11 +1422,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_balance(r: u32, ) -> Weight { - (209_811_000 as Weight) + Weight::from_ref_time(209_811_000 as RefTimeWeight) // Standard Error: 208_000 - .saturating_add((116_831_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(116_831_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1434,11 +1434,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_value_transferred(r: u32, ) -> Weight { - (207_406_000 as Weight) + Weight::from_ref_time(207_406_000 as RefTimeWeight) // Standard Error: 117_000 - .saturating_add((40_702_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_702_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1446,11 +1446,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_minimum_balance(r: u32, ) -> Weight { - (209_260_000 as Weight) + Weight::from_ref_time(209_260_000 as RefTimeWeight) // Standard Error: 130_000 - .saturating_add((40_479_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_479_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1458,11 +1458,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_block_number(r: u32, ) -> Weight { - (206_448_000 as Weight) + Weight::from_ref_time(206_448_000 as RefTimeWeight) // Standard Error: 95_000 - .saturating_add((40_134_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_134_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1470,11 +1470,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_now(r: u32, ) -> Weight { - (206_969_000 as Weight) + Weight::from_ref_time(206_969_000 as RefTimeWeight) // Standard Error: 116_000 - .saturating_add((40_251_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_251_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1483,11 +1483,11 @@ impl WeightInfo for () { // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_weight_to_fee(r: u32, ) -> Weight { - (211_611_000 as Weight) + Weight::from_ref_time(211_611_000 as RefTimeWeight) // Standard Error: 175_000 - .saturating_add((98_675_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(98_675_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1495,11 +1495,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_gas(r: u32, ) -> Weight { - (134_484_000 as Weight) + Weight::from_ref_time(134_484_000 as RefTimeWeight) // Standard Error: 57_000 - .saturating_add((19_329_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(19_329_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1507,11 +1507,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_input(r: u32, ) -> Weight { - (208_556_000 as Weight) + Weight::from_ref_time(208_556_000 as RefTimeWeight) // Standard Error: 125_000 - .saturating_add((40_328_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(40_328_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1519,11 +1519,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_input_per_kb(n: u32, ) -> Weight { - (268_886_000 as Weight) + Weight::from_ref_time(268_886_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((9_627_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(9_627_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1531,9 +1531,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 1]`. fn seal_return(_r: u32, ) -> Weight { - (203_591_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(203_591_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1541,11 +1541,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_return_per_kb(n: u32, ) -> Weight { - (204_258_000 as Weight) + Weight::from_ref_time(204_258_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((183_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(183_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1555,13 +1555,13 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:1 w:1) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { - (206_625_000 as Weight) + Weight::from_ref_time(206_625_000 as RefTimeWeight) // Standard Error: 672_000 - .saturating_add((59_377_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((5 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(59_377_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((4 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((5 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1570,11 +1570,11 @@ impl WeightInfo for () { // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_random(r: u32, ) -> Weight { - (208_866_000 as Weight) + Weight::from_ref_time(208_866_000 as RefTimeWeight) // Standard Error: 164_000 - .saturating_add((133_438_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(133_438_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1582,11 +1582,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_deposit_event(r: u32, ) -> Weight { - (220_860_000 as Weight) + Weight::from_ref_time(220_860_000 as RefTimeWeight) // Standard Error: 209_000 - .saturating_add((239_951_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(239_951_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1596,15 +1596,15 @@ impl WeightInfo for () { /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 16]`. fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - (439_782_000 as Weight) + Weight::from_ref_time(439_782_000 as RefTimeWeight) // Standard Error: 1_643_000 - .saturating_add((264_687_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(264_687_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 323_000 - .saturating_add((67_636_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(t as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((80 as Weight).saturating_mul(t as Weight))) + .saturating_add(Weight::from_ref_time(67_636_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((80 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((80 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1612,128 +1612,128 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_debug_message(r: u32, ) -> Weight { - (140_280_000 as Weight) + Weight::from_ref_time(140_280_000 as RefTimeWeight) // Standard Error: 82_000 - .saturating_add((32_717_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(32_717_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_set_storage(r: u32, ) -> Weight { - (161_247_000 as Weight) + Weight::from_ref_time(161_247_000 as RefTimeWeight) // Standard Error: 883_000 - .saturating_add((423_997_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((80 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(423_997_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { - (529_247_000 as Weight) + Weight::from_ref_time(529_247_000 as RefTimeWeight) // Standard Error: 2_745_000 - .saturating_add((85_282_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(55 as Weight)) - .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(53 as Weight)) - .saturating_add(RocksDbWeight::get().writes((5 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(85_282_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(55 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(53 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { - (529_812_000 as Weight) + Weight::from_ref_time(529_812_000 as RefTimeWeight) // Standard Error: 2_513_000 - .saturating_add((74_554_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(55 as Weight)) - .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(53 as Weight)) - .saturating_add(RocksDbWeight::get().writes((5 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(74_554_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(55 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(53 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_clear_storage(r: u32, ) -> Weight { - (184_803_000 as Weight) + Weight::from_ref_time(184_803_000 as RefTimeWeight) // Standard Error: 733_000 - .saturating_add((404_933_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((80 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(404_933_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_clear_storage_per_kb(n: u32, ) -> Weight { - (500_958_000 as Weight) + Weight::from_ref_time(500_958_000 as RefTimeWeight) // Standard Error: 2_980_000 - .saturating_add((75_996_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(55 as Weight)) - .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(52 as Weight)) - .saturating_add(RocksDbWeight::get().writes((5 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(75_996_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(55 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(52 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_get_storage(r: u32, ) -> Weight { - (177_682_000 as Weight) + Weight::from_ref_time(177_682_000 as RefTimeWeight) // Standard Error: 743_000 - .saturating_add((338_172_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(338_172_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_get_storage_per_kb(n: u32, ) -> Weight { - (465_285_000 as Weight) + Weight::from_ref_time(465_285_000 as RefTimeWeight) // Standard Error: 2_599_000 - .saturating_add((155_106_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(55 as Weight)) - .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(155_106_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(55 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_contains_storage(r: u32, ) -> Weight { - (179_118_000 as Weight) + Weight::from_ref_time(179_118_000 as RefTimeWeight) // Standard Error: 572_000 - .saturating_add((311_083_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(311_083_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_contains_storage_per_kb(n: u32, ) -> Weight { - (423_056_000 as Weight) + Weight::from_ref_time(423_056_000 as RefTimeWeight) // Standard Error: 2_037_000 - .saturating_add((69_665_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(54 as Weight)) - .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(69_665_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(54 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_take_storage(r: u32, ) -> Weight { - (188_884_000 as Weight) + Weight::from_ref_time(188_884_000 as RefTimeWeight) // Standard Error: 761_000 - .saturating_add((432_781_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((80 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(432_781_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_take_storage_per_kb(n: u32, ) -> Weight { - (532_408_000 as Weight) + Weight::from_ref_time(532_408_000 as RefTimeWeight) // Standard Error: 3_348_000 - .saturating_add((164_943_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(55 as Weight)) - .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(53 as Weight)) - .saturating_add(RocksDbWeight::get().writes((5 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(164_943_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(55 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(53 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1741,13 +1741,13 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_transfer(r: u32, ) -> Weight { - (127_181_000 as Weight) + Weight::from_ref_time(127_181_000 as RefTimeWeight) // Standard Error: 1_495_000 - .saturating_add((1_500_589_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((80 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(1_500_589_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1755,13 +1755,13 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_call(r: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 3_803_000 - .saturating_add((14_860_909_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((80 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(14_860_909_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((80 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1769,11 +1769,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_delegate_call(r: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 6_045_000 - .saturating_add((14_797_140_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads((79 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(14_797_140_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((79 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:81 w:81) @@ -1782,15 +1782,15 @@ impl WeightInfo for () { /// The range of component `t` is `[0, 1]`. /// The range of component `c` is `[0, 1024]`. fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { - (9_196_444_000 as Weight) + Weight::from_ref_time(9_196_444_000 as RefTimeWeight) // Standard Error: 20_486_000 - .saturating_add((1_458_153_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(1_458_153_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 8_000 - .saturating_add((9_718_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(RocksDbWeight::get().reads(85 as Weight)) - .saturating_add(RocksDbWeight::get().reads((81 as Weight).saturating_mul(t as Weight))) - .saturating_add(RocksDbWeight::get().writes(81 as Weight)) - .saturating_add(RocksDbWeight::get().writes((81 as Weight).saturating_mul(t as Weight))) + .saturating_add(Weight::from_ref_time(9_718_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(85 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((81 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(81 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((81 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1800,13 +1800,13 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:80 w:80) /// The range of component `r` is `[0, 20]`. fn seal_instantiate(r: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 36_253_000 - .saturating_add((21_201_529_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().reads((320 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes((320 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(21_201_529_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((320 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((320 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: System Account (r:81 w:81) // Storage: Contracts ContractInfoOf (r:81 w:81) @@ -1817,15 +1817,15 @@ impl WeightInfo for () { /// The range of component `t` is `[0, 1]`. /// The range of component `s` is `[0, 960]`. fn seal_instantiate_per_transfer_salt_kb(t: u32, s: u32, ) -> Weight { - (12_282_498_000 as Weight) + Weight::from_ref_time(12_282_498_000 as RefTimeWeight) // Standard Error: 48_112_000 - .saturating_add((720_795_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(720_795_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 22_000 - .saturating_add((124_274_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(167 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(t as Weight))) - .saturating_add(RocksDbWeight::get().writes(165 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(t as Weight))) + .saturating_add(Weight::from_ref_time(124_274_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(167 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(165 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(t as RefTimeWeight))) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1833,11 +1833,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { - (203_959_000 as Weight) + Weight::from_ref_time(203_959_000 as RefTimeWeight) // Standard Error: 142_000 - .saturating_add((61_311_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(61_311_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1845,11 +1845,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - (349_915_000 as Weight) + Weight::from_ref_time(349_915_000 as RefTimeWeight) // Standard Error: 40_000 - .saturating_add((320_652_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(320_652_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1857,11 +1857,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { - (209_219_000 as Weight) + Weight::from_ref_time(209_219_000 as RefTimeWeight) // Standard Error: 157_000 - .saturating_add((73_728_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(73_728_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1869,11 +1869,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - (208_860_000 as Weight) + Weight::from_ref_time(208_860_000 as RefTimeWeight) // Standard Error: 25_000 - .saturating_add((245_718_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(245_718_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1881,11 +1881,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { - (206_165_000 as Weight) + Weight::from_ref_time(206_165_000 as RefTimeWeight) // Standard Error: 138_000 - .saturating_add((51_644_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(51_644_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1893,11 +1893,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - (255_955_000 as Weight) + Weight::from_ref_time(255_955_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((95_090_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(95_090_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1905,11 +1905,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { - (208_153_000 as Weight) + Weight::from_ref_time(208_153_000 as RefTimeWeight) // Standard Error: 140_000 - .saturating_add((51_264_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(51_264_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1917,11 +1917,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - (278_368_000 as Weight) + Weight::from_ref_time(278_368_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((95_006_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(95_006_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1929,11 +1929,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { - (331_955_000 as Weight) + Weight::from_ref_time(331_955_000 as RefTimeWeight) // Standard Error: 1_155_000 - .saturating_add((3_069_955_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(3_069_955_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1941,11 +1941,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { - (207_838_000 as Weight) + Weight::from_ref_time(207_838_000 as RefTimeWeight) // Standard Error: 783_000 - .saturating_add((2_058_503_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_058_503_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1954,316 +1954,316 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:16 w:16) /// The range of component `r` is `[0, 20]`. fn seal_set_code_hash(r: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 1_567_000 - .saturating_add((774_380_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads((79 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes((79 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(774_380_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((79 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes((79 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } /// The range of component `r` is `[0, 50]`. fn instr_i64const(r: u32, ) -> Weight { - (73_955_000 as Weight) + Weight::from_ref_time(73_955_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((612_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(612_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64load(r: u32, ) -> Weight { - (74_057_000 as Weight) + Weight::from_ref_time(74_057_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((1_324_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_324_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64store(r: u32, ) -> Weight { - (74_137_000 as Weight) + Weight::from_ref_time(74_137_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((1_427_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_427_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_select(r: u32, ) -> Weight { - (73_844_000 as Weight) + Weight::from_ref_time(73_844_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_773_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_773_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_if(r: u32, ) -> Weight { - (73_979_000 as Weight) + Weight::from_ref_time(73_979_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((1_952_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_952_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_br(r: u32, ) -> Weight { - (73_924_000 as Weight) + Weight::from_ref_time(73_924_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((941_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(941_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_br_if(r: u32, ) -> Weight { - (73_574_000 as Weight) + Weight::from_ref_time(73_574_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((1_439_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_439_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_br_table(r: u32, ) -> Weight { - (73_343_000 as Weight) + Weight::from_ref_time(73_343_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((1_603_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_603_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `e` is `[1, 256]`. fn instr_br_table_per_entry(e: u32, ) -> Weight { - (76_267_000 as Weight) + Weight::from_ref_time(76_267_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(e as Weight)) + .saturating_add(Weight::from_ref_time(4_000 as RefTimeWeight).scalar_saturating_mul(e as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_call(r: u32, ) -> Weight { - (74_877_000 as Weight) + Weight::from_ref_time(74_877_000 as RefTimeWeight) // Standard Error: 12_000 - .saturating_add((7_144_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(7_144_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_call_indirect(r: u32, ) -> Weight { - (88_665_000 as Weight) + Weight::from_ref_time(88_665_000 as RefTimeWeight) // Standard Error: 20_000 - .saturating_add((9_142_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(9_142_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `p` is `[0, 128]`. fn instr_call_indirect_per_param(p: u32, ) -> Weight { - (98_600_000 as Weight) + Weight::from_ref_time(98_600_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((469_000 as Weight).saturating_mul(p as Weight)) + .saturating_add(Weight::from_ref_time(469_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_get(r: u32, ) -> Weight { - (74_555_000 as Weight) + Weight::from_ref_time(74_555_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((624_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(624_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_set(r: u32, ) -> Weight { - (74_329_000 as Weight) + Weight::from_ref_time(74_329_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((688_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(688_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_tee(r: u32, ) -> Weight { - (74_612_000 as Weight) + Weight::from_ref_time(74_612_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((909_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(909_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_global_get(r: u32, ) -> Weight { - (76_906_000 as Weight) + Weight::from_ref_time(76_906_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_192_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_192_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_global_set(r: u32, ) -> Weight { - (76_979_000 as Weight) + Weight::from_ref_time(76_979_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_361_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_361_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_memory_current(r: u32, ) -> Weight { - (74_370_000 as Weight) + Weight::from_ref_time(74_370_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((661_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(661_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 1]`. fn instr_memory_grow(r: u32, ) -> Weight { - (73_584_000 as Weight) + Weight::from_ref_time(73_584_000 as RefTimeWeight) // Standard Error: 353_000 - .saturating_add((187_114_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(187_114_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64clz(r: u32, ) -> Weight { - (74_206_000 as Weight) + Weight::from_ref_time(74_206_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((884_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(884_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ctz(r: u32, ) -> Weight { - (73_992_000 as Weight) + Weight::from_ref_time(73_992_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((893_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(893_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64popcnt(r: u32, ) -> Weight { - (73_985_000 as Weight) + Weight::from_ref_time(73_985_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((891_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(891_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64eqz(r: u32, ) -> Weight { - (74_117_000 as Weight) + Weight::from_ref_time(74_117_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((901_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(901_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendsi32(r: u32, ) -> Weight { - (73_981_000 as Weight) + Weight::from_ref_time(73_981_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((866_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(866_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendui32(r: u32, ) -> Weight { - (74_104_000 as Weight) + Weight::from_ref_time(74_104_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((868_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(868_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i32wrapi64(r: u32, ) -> Weight { - (74_293_000 as Weight) + Weight::from_ref_time(74_293_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((878_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(878_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64eq(r: u32, ) -> Weight { - (74_055_000 as Weight) + Weight::from_ref_time(74_055_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_350_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_350_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ne(r: u32, ) -> Weight { - (73_710_000 as Weight) + Weight::from_ref_time(73_710_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_360_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64lts(r: u32, ) -> Weight { - (73_917_000 as Weight) + Weight::from_ref_time(73_917_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_355_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_355_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ltu(r: u32, ) -> Weight { - (74_048_000 as Weight) + Weight::from_ref_time(74_048_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_360_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64gts(r: u32, ) -> Weight { - (74_029_000 as Weight) + Weight::from_ref_time(74_029_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_349_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_349_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64gtu(r: u32, ) -> Weight { - (74_267_000 as Weight) + Weight::from_ref_time(74_267_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_353_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_353_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64les(r: u32, ) -> Weight { - (73_952_000 as Weight) + Weight::from_ref_time(73_952_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_350_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_350_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64leu(r: u32, ) -> Weight { - (73_851_000 as Weight) + Weight::from_ref_time(73_851_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_368_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_368_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ges(r: u32, ) -> Weight { - (74_034_000 as Weight) + Weight::from_ref_time(74_034_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_348_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_348_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64geu(r: u32, ) -> Weight { - (73_979_000 as Weight) + Weight::from_ref_time(73_979_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((1_353_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_353_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64add(r: u32, ) -> Weight { - (74_000_000 as Weight) + Weight::from_ref_time(74_000_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_328_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_328_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64sub(r: u32, ) -> Weight { - (73_883_000 as Weight) + Weight::from_ref_time(73_883_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_331_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_331_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64mul(r: u32, ) -> Weight { - (74_216_000 as Weight) + Weight::from_ref_time(74_216_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((1_324_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_324_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64divs(r: u32, ) -> Weight { - (73_989_000 as Weight) + Weight::from_ref_time(73_989_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_998_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_998_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64divu(r: u32, ) -> Weight { - (73_857_000 as Weight) + Weight::from_ref_time(73_857_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((2_073_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(2_073_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rems(r: u32, ) -> Weight { - (73_801_000 as Weight) + Weight::from_ref_time(73_801_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((2_027_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(2_027_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64remu(r: u32, ) -> Weight { - (74_130_000 as Weight) + Weight::from_ref_time(74_130_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((2_064_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(2_064_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64and(r: u32, ) -> Weight { - (74_071_000 as Weight) + Weight::from_ref_time(74_071_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_327_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_327_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64or(r: u32, ) -> Weight { - (74_201_000 as Weight) + Weight::from_ref_time(74_201_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((1_330_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_330_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64xor(r: u32, ) -> Weight { - (74_241_000 as Weight) + Weight::from_ref_time(74_241_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_321_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_321_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shl(r: u32, ) -> Weight { - (74_331_000 as Weight) + Weight::from_ref_time(74_331_000 as RefTimeWeight) // Standard Error: 6_000 - .saturating_add((1_347_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_347_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shrs(r: u32, ) -> Weight { - (73_674_000 as Weight) + Weight::from_ref_time(73_674_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_359_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_359_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shru(r: u32, ) -> Weight { - (73_807_000 as Weight) + Weight::from_ref_time(73_807_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((1_358_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_358_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotl(r: u32, ) -> Weight { - (73_725_000 as Weight) + Weight::from_ref_time(73_725_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_358_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_358_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotr(r: u32, ) -> Weight { - (73_755_000 as Weight) + Weight::from_ref_time(73_755_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(1_360_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) } } diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 9eb7f679efca3..cbd2b0619ac2b 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -22,6 +22,7 @@ use std::collections::BTreeMap; use frame_support::{ assert_noop, assert_ok, parameter_types, traits::{ConstU32, ConstU64, Contains, Polling, VoteTally}, + weights::Weight, }; use sp_core::H256; use sp_runtime::{ @@ -57,7 +58,7 @@ impl Contains for BaseFilter { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1_000_000); + frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(1_000_000)); } impl frame_system::Config for Test { type BaseCallFilter = BaseFilter; diff --git a/frame/conviction-voting/src/weights.rs b/frame/conviction-voting/src/weights.rs index 330d02755cb8b..10c5c975a81f1 100644 --- a/frame/conviction-voting/src/weights.rs +++ b/frame/conviction-voting/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_conviction_voting. @@ -62,9 +62,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn vote_new() -> Weight { - (148_804_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(148_804_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: ConvictionVoting VotingFor (r:1 w:1) @@ -72,24 +72,24 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn vote_existing() -> Weight { - (313_333_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(313_333_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: ConvictionVoting VotingFor (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn remove_vote() -> Weight { - (300_591_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(300_591_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: ConvictionVoting VotingFor (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:1 w:0) fn remove_other_vote() -> Weight { - (53_887_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(53_887_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: ConvictionVoting VotingFor (r:2 w:2) // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) @@ -97,33 +97,33 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn delegate(r: u32, ) -> Weight { - (51_518_000 as Weight) + Weight::from_ref_time(51_518_000 as RefTimeWeight) // Standard Error: 83_000 - .saturating_add((27_235_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(27_235_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: ConvictionVoting VotingFor (r:2 w:2) // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn undelegate(r: u32, ) -> Weight { - (37_885_000 as Weight) + Weight::from_ref_time(37_885_000 as RefTimeWeight) // Standard Error: 75_000 - .saturating_add((24_395_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(24_395_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: ConvictionVoting VotingFor (r:1 w:1) // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn unlock() -> Weight { - (67_703_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(67_703_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } } @@ -135,9 +135,9 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn vote_new() -> Weight { - (148_804_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(148_804_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: ConvictionVoting VotingFor (r:1 w:1) @@ -145,24 +145,24 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn vote_existing() -> Weight { - (313_333_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(313_333_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: ConvictionVoting VotingFor (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn remove_vote() -> Weight { - (300_591_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(300_591_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: ConvictionVoting VotingFor (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:1 w:0) fn remove_other_vote() -> Weight { - (53_887_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(53_887_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: ConvictionVoting VotingFor (r:2 w:2) // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) @@ -170,32 +170,32 @@ impl WeightInfo for () { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn delegate(r: u32, ) -> Weight { - (51_518_000 as Weight) + Weight::from_ref_time(51_518_000 as RefTimeWeight) // Standard Error: 83_000 - .saturating_add((27_235_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(27_235_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: ConvictionVoting VotingFor (r:2 w:2) // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn undelegate(r: u32, ) -> Weight { - (37_885_000 as Weight) + Weight::from_ref_time(37_885_000 as RefTimeWeight) // Standard Error: 75_000 - .saturating_add((24_395_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(24_395_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: ConvictionVoting VotingFor (r:1 w:1) // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn unlock() -> Weight { - (67_703_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(67_703_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } } diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index a347f47efe121..5bbc97fa16e30 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1765,7 +1765,7 @@ impl Pallet { /// # fn begin_block(now: T::BlockNumber) -> Weight { let max_block_weight = T::BlockWeights::get().max_block; - let mut weight = 0; + let mut weight = Weight::new(); let next = Self::lowest_unbaked(); let last = Self::referendum_count(); diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 0fe83a07610d1..def8f84067909 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -78,7 +78,7 @@ impl Contains for BaseFilter { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1_000_000); + frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(1_000_000)); } impl frame_system::Config for Test { type BaseCallFilter = BaseFilter; diff --git a/frame/democracy/src/weights.rs b/frame/democracy/src/weights.rs index 45686b43f7152..351ed42cca8e9 100644 --- a/frame/democracy/src/weights.rs +++ b/frame/democracy/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_democracy. @@ -80,44 +80,44 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - (48_328_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(48_328_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy DepositOf (r:1 w:1) fn second(s: u32, ) -> Weight { - (30_923_000 as Weight) + Weight::from_ref_time(30_923_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((142_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(Weight::from_ref_time(142_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_new(r: u32, ) -> Weight { - (40_345_000 as Weight) + Weight::from_ref_time(40_345_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((140_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(140_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_existing(r: u32, ) -> Weight { - (39_853_000 as Weight) + Weight::from_ref_time(39_853_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((150_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(150_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy Cancellations (r:1 w:1) fn emergency_cancel() -> Weight { - (19_364_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(19_364_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy NextExternal (r:1 w:1) @@ -126,82 +126,82 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn blacklist(p: u32, ) -> Weight { - (57_708_000 as Weight) + Weight::from_ref_time(57_708_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((192_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(192_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) fn external_propose(v: u32, ) -> Weight { - (10_714_000 as Weight) + Weight::from_ref_time(10_714_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((33_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(33_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - (3_697_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_697_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - (3_831_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_831_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - (20_271_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(20_271_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:1) fn veto_external(v: u32, ) -> Weight { - (21_319_000 as Weight) + Weight::from_ref_time(21_319_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((52_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(52_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn cancel_proposal(p: u32, ) -> Weight { - (43_960_000 as Weight) + Weight::from_ref_time(43_960_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((184_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(184_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - (13_475_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(13_475_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn cancel_queued(r: u32, ) -> Weight { - (24_320_000 as Weight) + Weight::from_ref_time(24_320_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((560_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(560_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) // Storage: Democracy ReferendumInfoOf (r:1 w:0) fn on_initialize_base(r: u32, ) -> Weight { - (3_428_000 as Weight) + Weight::from_ref_time(3_428_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((3_171_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(3_171_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) @@ -210,103 +210,103 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy PublicProps (r:1 w:0) // Storage: Democracy ReferendumInfoOf (r:1 w:0) fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - (7_867_000 as Weight) + Weight::from_ref_time(7_867_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((3_177_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(3_177_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy VotingOf (r:3 w:3) // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn delegate(r: u32, ) -> Weight { - (37_902_000 as Weight) + Weight::from_ref_time(37_902_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((4_335_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(4_335_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: Democracy VotingOf (r:2 w:2) // Storage: Democracy ReferendumInfoOf (r:1 w:1) fn undelegate(r: u32, ) -> Weight { - (21_272_000 as Weight) + Weight::from_ref_time(21_272_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((4_351_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(4_351_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - (4_913_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(4_913_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy Preimages (r:1 w:1) fn note_preimage(b: u32, ) -> Weight { - (27_986_000 as Weight) + Weight::from_ref_time(27_986_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy Preimages (r:1 w:1) fn note_imminent_preimage(b: u32, ) -> Weight { - (20_058_000 as Weight) + Weight::from_ref_time(20_058_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy Preimages (r:1 w:1) // Storage: System Account (r:1 w:0) fn reap_preimage(b: u32, ) -> Weight { - (28_619_000 as Weight) + Weight::from_ref_time(28_619_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn unlock_remove(r: u32, ) -> Weight { - (26_619_000 as Weight) + Weight::from_ref_time(26_619_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((56_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(56_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn unlock_set(r: u32, ) -> Weight { - (25_373_000 as Weight) + Weight::from_ref_time(25_373_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((142_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(142_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) fn remove_vote(r: u32, ) -> Weight { - (15_961_000 as Weight) + Weight::from_ref_time(15_961_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((115_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(115_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) fn remove_other_vote(r: u32, ) -> Weight { - (15_992_000 as Weight) + Weight::from_ref_time(15_992_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((113_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(113_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } } @@ -317,44 +317,44 @@ impl WeightInfo for () { // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - (48_328_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(48_328_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy DepositOf (r:1 w:1) fn second(s: u32, ) -> Weight { - (30_923_000 as Weight) + Weight::from_ref_time(30_923_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((142_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(142_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_new(r: u32, ) -> Weight { - (40_345_000 as Weight) + Weight::from_ref_time(40_345_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((140_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(140_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_existing(r: u32, ) -> Weight { - (39_853_000 as Weight) + Weight::from_ref_time(39_853_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((150_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(150_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy Cancellations (r:1 w:1) fn emergency_cancel() -> Weight { - (19_364_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(19_364_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy NextExternal (r:1 w:1) @@ -363,82 +363,82 @@ impl WeightInfo for () { // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn blacklist(p: u32, ) -> Weight { - (57_708_000 as Weight) + Weight::from_ref_time(57_708_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((192_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(192_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) fn external_propose(v: u32, ) -> Weight { - (10_714_000 as Weight) + Weight::from_ref_time(10_714_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((33_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(33_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - (3_697_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_697_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - (3_831_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_831_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - (20_271_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(20_271_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:1) fn veto_external(v: u32, ) -> Weight { - (21_319_000 as Weight) + Weight::from_ref_time(21_319_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((52_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(52_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn cancel_proposal(p: u32, ) -> Weight { - (43_960_000 as Weight) + Weight::from_ref_time(43_960_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((184_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(184_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - (13_475_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(13_475_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn cancel_queued(r: u32, ) -> Weight { - (24_320_000 as Weight) + Weight::from_ref_time(24_320_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((560_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(560_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) // Storage: Democracy ReferendumInfoOf (r:1 w:0) fn on_initialize_base(r: u32, ) -> Weight { - (3_428_000 as Weight) + Weight::from_ref_time(3_428_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((3_171_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(3_171_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) @@ -447,102 +447,102 @@ impl WeightInfo for () { // Storage: Democracy PublicProps (r:1 w:0) // Storage: Democracy ReferendumInfoOf (r:1 w:0) fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - (7_867_000 as Weight) + Weight::from_ref_time(7_867_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((3_177_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(3_177_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy VotingOf (r:3 w:3) // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn delegate(r: u32, ) -> Weight { - (37_902_000 as Weight) + Weight::from_ref_time(37_902_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((4_335_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(4_335_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: Democracy VotingOf (r:2 w:2) // Storage: Democracy ReferendumInfoOf (r:1 w:1) fn undelegate(r: u32, ) -> Weight { - (21_272_000 as Weight) + Weight::from_ref_time(21_272_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((4_351_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(4_351_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - (4_913_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(4_913_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy Preimages (r:1 w:1) fn note_preimage(b: u32, ) -> Weight { - (27_986_000 as Weight) + Weight::from_ref_time(27_986_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy Preimages (r:1 w:1) fn note_imminent_preimage(b: u32, ) -> Weight { - (20_058_000 as Weight) + Weight::from_ref_time(20_058_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy Preimages (r:1 w:1) // Storage: System Account (r:1 w:0) fn reap_preimage(b: u32, ) -> Weight { - (28_619_000 as Weight) + Weight::from_ref_time(28_619_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn unlock_remove(r: u32, ) -> Weight { - (26_619_000 as Weight) + Weight::from_ref_time(26_619_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((56_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(56_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn unlock_set(r: u32, ) -> Weight { - (25_373_000 as Weight) + Weight::from_ref_time(25_373_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((142_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(142_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) fn remove_vote(r: u32, ) -> Weight { - (15_961_000 as Weight) + Weight::from_ref_time(15_961_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((115_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(115_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) fn remove_other_vote(r: u32, ) -> Weight { - (15_992_000 as Weight) + Weight::from_ref_time(15_992_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((113_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(113_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } } diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index e1d3cb8ed5dee..906de8a6c9d20 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -234,7 +234,6 @@ use frame_election_provider_support::{ ElectionDataProvider, ElectionProvider, InstantElectionProvider, NposSolution, }; use frame_support::{ - dispatch::DispatchResultWithPostInfo, ensure, traits::{Currency, Get, OnUnbalanced, ReservableCurrency}, weights::{DispatchClass, Weight}, @@ -877,7 +876,7 @@ pub mod pallet { origin: OriginFor, raw_solution: Box>>, witness: SolutionOrSnapshotSize, - ) -> DispatchResultWithPostInfo { + ) -> DispatchResult { ensure_none(origin)?; let error_message = "Invalid unsigned submission must produce invalid block and \ deprive validator from their authoring reward."; @@ -905,7 +904,7 @@ pub mod pallet { prev_ejected: ejected_a_solution, }); - Ok(None.into()) + Ok(()) } /// Set a new value for `MinimumUntrustedScore`. @@ -992,7 +991,7 @@ pub mod pallet { let deposit = Self::deposit_for(&raw_solution, size); let call_fee = { let call = Call::submit { raw_solution: raw_solution.clone() }; - T::EstimateCallFee::estimate_call_fee(&call, None.into()) + T::EstimateCallFee::estimate_call_fee(&call, None::.into()) }; let submission = SignedSubmission { diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 7eff70b47eba5..72b3ec9764079 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -349,9 +349,11 @@ impl MinerConfig for Runtime { fn solution_weight(v: u32, t: u32, a: u32, d: u32) -> Weight { match MockWeightInfo::get() { - MockedWeightInfo::Basic => - (10 as Weight).saturating_add((5 as Weight).saturating_mul(a as Weight)), - MockedWeightInfo::Complex => (0 * v + 0 * t + 1000 * a + 0 * d) as Weight, + MockedWeightInfo::Basic => Weight::from_ref_time( + (10 as u64).saturating_add((5 as u64).saturating_mul(a as u64)), + ), + MockedWeightInfo::Complex => + Weight::from_ref_time((0 * v + 0 * t + 1000 * a + 0 * d) as u64), MockedWeightInfo::Real => <() as multi_phase::weights::WeightInfo>::feasibility_check(v, t, a, d), } diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index eca75139f925a..b9abfdfba14fb 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -514,8 +514,8 @@ impl Pallet { let feasibility_weight = Self::solution_weight_of(raw_solution, size); let len_deposit = T::SignedDepositByte::get().saturating_mul(encoded_len); - let weight_deposit = - T::SignedDepositWeight::get().saturating_mul(feasibility_weight.saturated_into()); + let weight_deposit = T::SignedDepositWeight::get() + .saturating_mul(feasibility_weight.ref_time().saturated_into()); T::SignedDepositBase::get() .saturating_add(len_deposit) @@ -957,7 +957,7 @@ mod tests { #[test] fn cannot_consume_too_much_future_weight() { ExtBuilder::default() - .signed_weight(40) + .signed_weight(Weight::from_ref_time(40)) .mock_weight_info(MockedWeightInfo::Basic) .build_and_execute(|| { roll_to(15); @@ -971,13 +971,13 @@ mod tests { raw.solution.unique_targets().len() as u32, ); // default solution will have 5 edges (5 * 5 + 10) - assert_eq!(solution_weight, 35); + assert_eq!(solution_weight, Weight::from_ref_time(35)); assert_eq!(raw.solution.voter_count(), 5); - assert_eq!(::SignedMaxWeight::get(), 40); + assert_eq!(::SignedMaxWeight::get(), Weight::from_ref_time(40)); assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(raw.clone()))); - ::set(30); + ::set(Weight::from_ref_time(30)); // note: resubmitting the same solution is technically okay as long as the queue has // space. diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index de25355f0ca5b..8ef7d87473159 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -699,54 +699,153 @@ mod max_weight { fn find_max_voter_binary_search_works() { let w = SolutionOrSnapshotSize { voters: 10, targets: 0 }; MockWeightInfo::set(crate::mock::MockedWeightInfo::Complex); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 0), 0); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1), 0); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 999), 0); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1000), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1001), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1990), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1999), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2000), 2); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2001), 2); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2010), 2); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2990), 2); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2999), 2); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 3000), 3); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 3333), 3); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 5500), 5); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 7777), 7); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 9999), 9); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 10_000), 10); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 10_999), 10); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 11_000), 10); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 22_000), 10); + assert_eq!(Miner::::maximum_voter_for_weight(0, w, Weight::zero()), 0); + assert_eq!(Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1)), 0); + assert_eq!(Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(999)), 0); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1000)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1001)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1990)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1999)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2000)), + 2 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2001)), + 2 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2010)), + 2 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2990)), + 2 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2999)), + 2 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(3000)), + 3 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(3333)), + 3 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(5500)), + 5 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(7777)), + 7 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(9999)), + 9 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(10_000)), + 10 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(10_999)), + 10 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(11_000)), + 10 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(22_000)), + 10 + ); let w = SolutionOrSnapshotSize { voters: 1, targets: 0 }; - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 0), 0); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1), 0); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 999), 0); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1000), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1001), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1990), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1999), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2000), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2001), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2010), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 3333), 1); + assert_eq!(Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(0)), 0); + assert_eq!(Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1)), 0); + assert_eq!(Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(999)), 0); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1000)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1001)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1990)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1999)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2000)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2001)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2010)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(3333)), + 1 + ); let w = SolutionOrSnapshotSize { voters: 2, targets: 0 }; - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 0), 0); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1), 0); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 999), 0); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1000), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1001), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 1999), 1); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2000), 2); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2001), 2); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 2010), 2); - assert_eq!(Miner::::maximum_voter_for_weight(0, w, 3333), 2); + assert_eq!(Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(0)), 0); + assert_eq!(Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1)), 0); + assert_eq!(Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(999)), 0); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1000)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1001)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(1999)), + 1 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2000)), + 2 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2001)), + 2 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(2010)), + 2 + ); + assert_eq!( + Miner::::maximum_voter_for_weight(0, w, Weight::from_ref_time(3333)), + 2 + ); } } @@ -1024,7 +1123,7 @@ mod tests { #[test] fn miner_trims_weight() { ExtBuilder::default() - .miner_weight(100) + .miner_weight(Weight::from_ref_time(100)) .mock_weight_info(crate::mock::MockedWeightInfo::Basic) .build_and_execute(|| { roll_to(25); @@ -1038,11 +1137,11 @@ mod tests { raw.solution.unique_targets().len() as u32, ); // default solution will have 5 edges (5 * 5 + 10) - assert_eq!(solution_weight, 35); + assert_eq!(solution_weight, Weight::from_ref_time(35)); assert_eq!(raw.solution.voter_count(), 5); // now reduce the max weight - ::set(25); + ::set(Weight::from_ref_time(25)); let (raw, witness) = MultiPhase::mine_solution().unwrap(); let solution_weight = ::solution_weight( @@ -1052,7 +1151,7 @@ mod tests { raw.solution.unique_targets().len() as u32, ); // default solution will have 5 edges (5 * 5 + 10) - assert_eq!(solution_weight, 25); + assert_eq!(solution_weight, Weight::from_ref_time(25)); assert_eq!(raw.solution.voter_count(), 3); }) } diff --git a/frame/election-provider-multi-phase/src/weights.rs b/frame/election-provider-multi-phase/src/weights.rs index 68ce00dd0de32..7ceb4a20e042a 100644 --- a/frame/election-provider-multi-phase/src/weights.rs +++ b/frame/election-provider-multi-phase/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_election_provider_multi_phase. @@ -68,46 +68,46 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking ForceEra (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) fn on_initialize_nothing() -> Weight { - (13_495_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) + Weight::from_ref_time(13_495_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(8 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn on_initialize_open_signed() -> Weight { - (14_114_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(14_114_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn on_initialize_open_unsigned() -> Weight { - (13_756_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(13_756_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) // Storage: ElectionProviderMultiPhase QueuedSolution (r:0 w:1) fn finalize_signed_phase_accept_solution() -> Weight { - (28_467_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(28_467_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn finalize_signed_phase_reject_solution() -> Weight { - (21_991_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_991_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:0 w:1) // Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) fn create_snapshot_internal(v: u32, t: u32, ) -> Weight { - (3_186_000 as Weight) + Weight::from_ref_time(3_186_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((202_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(202_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 3_000 - .saturating_add((60_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(60_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) @@ -119,13 +119,13 @@ impl WeightInfo for SubstrateWeight { // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn elect_queued(a: u32, d: u32, ) -> Weight { - (137_653_000 as Weight) + Weight::from_ref_time(137_653_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((640_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(640_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 6_000 - .saturating_add((48_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + .saturating_add(Weight::from_ref_time(48_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(8 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) @@ -134,9 +134,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) // Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:0 w:1) fn submit() -> Weight { - (49_313_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(49_313_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: ElectionProviderMultiPhase Round (r:1 w:0) @@ -146,33 +146,33 @@ impl WeightInfo for SubstrateWeight { // Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) // Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) fn submit_unsigned(v: u32, t: u32, a: u32, d: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((867_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(867_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 7_000 - .saturating_add((107_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(107_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 12_000 - .saturating_add((6_907_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(6_907_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 18_000 - .saturating_add((1_427_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_427_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(7 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) // Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) // Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) fn feasibility_check(v: u32, t: u32, a: u32, d: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((844_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(844_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 5_000 - .saturating_add((150_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(150_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 8_000 - .saturating_add((5_421_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(5_421_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 13_000 - .saturating_add((1_167_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(Weight::from_ref_time(1_167_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) } } @@ -187,46 +187,46 @@ impl WeightInfo for () { // Storage: Staking ForceEra (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) fn on_initialize_nothing() -> Weight { - (13_495_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) + Weight::from_ref_time(13_495_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(8 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn on_initialize_open_signed() -> Weight { - (14_114_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(14_114_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn on_initialize_open_unsigned() -> Weight { - (13_756_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(13_756_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) // Storage: ElectionProviderMultiPhase QueuedSolution (r:0 w:1) fn finalize_signed_phase_accept_solution() -> Weight { - (28_467_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(28_467_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: System Account (r:1 w:1) fn finalize_signed_phase_reject_solution() -> Weight { - (21_991_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_991_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:0 w:1) // Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) fn create_snapshot_internal(v: u32, t: u32, ) -> Weight { - (3_186_000 as Weight) + Weight::from_ref_time(3_186_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((202_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(202_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 3_000 - .saturating_add((60_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(60_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) @@ -238,13 +238,13 @@ impl WeightInfo for () { // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn elect_queued(a: u32, d: u32, ) -> Weight { - (137_653_000 as Weight) + Weight::from_ref_time(137_653_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((640_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(640_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 6_000 - .saturating_add((48_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(8 as Weight)) + .saturating_add(Weight::from_ref_time(48_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(8 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) @@ -253,9 +253,9 @@ impl WeightInfo for () { // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) // Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:0 w:1) fn submit() -> Weight { - (49_313_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(49_313_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: ElectionProviderMultiPhase Round (r:1 w:0) @@ -265,32 +265,32 @@ impl WeightInfo for () { // Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) // Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) fn submit_unsigned(v: u32, t: u32, a: u32, d: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((867_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(867_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 7_000 - .saturating_add((107_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(107_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 12_000 - .saturating_add((6_907_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(6_907_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 18_000 - .saturating_add((1_427_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_427_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(7 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) // Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) // Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) fn feasibility_check(v: u32, t: u32, a: u32, d: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((844_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(844_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 5_000 - .saturating_add((150_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(150_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 8_000 - .saturating_add((5_421_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(5_421_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 13_000 - .saturating_add((1_167_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) + .saturating_add(Weight::from_ref_time(1_167_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) } } diff --git a/frame/election-provider-support/src/weights.rs b/frame/election-provider-support/src/weights.rs index c603b196519b5..4f9e47b09a4da 100644 --- a/frame/election-provider-support/src/weights.rs +++ b/frame/election-provider-support/src/weights.rs @@ -40,7 +40,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_election_provider_support_benchmarking. @@ -53,43 +53,43 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn phragmen(v: u32, t: u32, d: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 667_000 - .saturating_add((32_973_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(32_973_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 1_334_000 - .saturating_add((1_334_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(1_334_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 60_644_000 - .saturating_add((2_636_364_000 as Weight).saturating_mul(d as Weight)) + .saturating_add(Weight::from_ref_time(2_636_364_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) } fn phragmms(v: u32, t: u32, d: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 73_000 - .saturating_add((21_073_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(21_073_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 146_000 - .saturating_add((65_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(65_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 6_649_000 - .saturating_add((1_711_424_000 as Weight).saturating_mul(d as Weight)) + .saturating_add(Weight::from_ref_time(1_711_424_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) } } // For backwards compatibility and tests impl WeightInfo for () { fn phragmen(v: u32, t: u32, d: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 667_000 - .saturating_add((32_973_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(32_973_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 1_334_000 - .saturating_add((1_334_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(1_334_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 60_644_000 - .saturating_add((2_636_364_000 as Weight).saturating_mul(d as Weight)) + .saturating_add(Weight::from_ref_time(2_636_364_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) } fn phragmms(v: u32, t: u32, d: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 73_000 - .saturating_add((21_073_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(21_073_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 146_000 - .saturating_add((65_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(Weight::from_ref_time(65_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) // Standard Error: 6_649_000 - .saturating_add((1_711_424_000 as Weight).saturating_mul(d as Weight)) + .saturating_add(Weight::from_ref_time(1_711_424_000 as RefTimeWeight).scalar_saturating_mul(d as RefTimeWeight)) } } diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 1076ae77fbdda..539e90d0179ff 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -279,7 +279,7 @@ pub mod pallet { if !term_duration.is_zero() && (n % term_duration).is_zero() { Self::do_phragmen() } else { - 0 + Weight::zero() } } } @@ -363,7 +363,7 @@ pub mod pallet { T::Currency::set_lock(T::PalletId::get(), &who, locked_stake, WithdrawReasons::all()); Voting::::insert(&who, Voter { votes, deposit: new_deposit, stake: locked_stake }); - Ok(None.into()) + Ok(None::.into()) } /// Remove `origin` as a voter. @@ -372,11 +372,11 @@ pub mod pallet { /// /// The dispatch origin of this call must be signed and be a voter. #[pallet::weight(T::WeightInfo::remove_voter())] - pub fn remove_voter(origin: OriginFor) -> DispatchResultWithPostInfo { + pub fn remove_voter(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; ensure!(Self::is_voter(&who), Error::::MustBeVoter); Self::do_remove_voter(&who); - Ok(None.into()) + Ok(()) } /// Submit oneself for candidacy. A fixed amount of deposit is recorded. @@ -398,7 +398,7 @@ pub mod pallet { pub fn submit_candidacy( origin: OriginFor, #[pallet::compact] candidate_count: u32, - ) -> DispatchResultWithPostInfo { + ) -> DispatchResult { let who = ensure_signed(origin)?; let actual_count = >::decode_len().unwrap_or(0) as u32; @@ -417,7 +417,7 @@ pub mod pallet { .map_err(|_| Error::::InsufficientCandidateFunds)?; >::mutate(|c| c.insert(index, (who, T::CandidacyBond::get()))); - Ok(None.into()) + Ok(()) } /// Renounce one's intention to be a candidate for the next election round. 3 potential @@ -443,10 +443,7 @@ pub mod pallet { Renouncing::Member => T::WeightInfo::renounce_candidacy_members(), Renouncing::RunnerUp => T::WeightInfo::renounce_candidacy_runners_up(), })] - pub fn renounce_candidacy( - origin: OriginFor, - renouncing: Renouncing, - ) -> DispatchResultWithPostInfo { + pub fn renounce_candidacy(origin: OriginFor, renouncing: Renouncing) -> DispatchResult { let who = ensure_signed(origin)?; match renouncing { Renouncing::Member => { @@ -482,7 +479,7 @@ pub mod pallet { })?; }, }; - Ok(None.into()) + Ok(()) } /// Remove a particular member from the set. This is effective immediately and the bond of @@ -513,7 +510,7 @@ pub mod pallet { who: AccountIdLookupOf, slash_bond: bool, rerun_election: bool, - ) -> DispatchResultWithPostInfo { + ) -> DispatchResult { ensure_root(origin)?; let who = T::Lookup::lookup(who)?; @@ -525,7 +522,7 @@ pub mod pallet { } // no refund needed. - Ok(None.into()) + Ok(()) } /// Clean all voters who are defunct (i.e. they do not serve any purpose at all). The @@ -543,13 +540,13 @@ pub mod pallet { origin: OriginFor, _num_voters: u32, _num_defunct: u32, - ) -> DispatchResultWithPostInfo { + ) -> DispatchResult { let _ = ensure_root(origin)?; >::iter() .filter(|(_, x)| Self::is_defunct_voter(&x.votes)) .for_each(|(dv, _)| Self::do_remove_voter(&dv)); - Ok(None.into()) + Ok(()) } } @@ -1177,7 +1174,7 @@ mod tests { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { @@ -1488,7 +1485,7 @@ mod tests { ensure_members_has_approval_stake(); } - fn submit_candidacy(origin: Origin) -> DispatchResultWithPostInfo { + fn submit_candidacy(origin: Origin) -> sp_runtime::DispatchResult { Elections::submit_candidacy(origin, Elections::candidates().len() as u32) } diff --git a/frame/elections-phragmen/src/migrations/v3.rs b/frame/elections-phragmen/src/migrations/v3.rs index b1cdd4be98541..9ec9c6e7eea6c 100644 --- a/frame/elections-phragmen/src/migrations/v3.rs +++ b/frame/elections-phragmen/src/migrations/v3.rs @@ -101,14 +101,14 @@ pub fn apply( StorageVersion::new(3).put::>(); - Weight::max_value() + Weight::MAX } else { log::warn!( target: "runtime::elections-phragmen", "Attempted to apply migration to V3 but failed because storage version is {:?}", storage_version, ); - 0 + Weight::zero() } } diff --git a/frame/elections-phragmen/src/migrations/v4.rs b/frame/elections-phragmen/src/migrations/v4.rs index e0fc17ec2a12d..76ef630706c50 100644 --- a/frame/elections-phragmen/src/migrations/v4.rs +++ b/frame/elections-phragmen/src/migrations/v4.rs @@ -38,7 +38,7 @@ pub fn migrate>(new_pallet_name: N) -> Weight { target: "runtime::elections-phragmen", "New pallet name is equal to the old prefix. No migration needs to be done.", ); - return 0 + return Weight::zero() } let storage_version = StorageVersion::get::>(); log::info!( @@ -63,7 +63,7 @@ pub fn migrate>(new_pallet_name: N) -> Weight { "Attempted to apply migration to v4 but failed because storage version is {:?}", storage_version, ); - 0 + Weight::zero() } } diff --git a/frame/elections-phragmen/src/migrations/v5.rs b/frame/elections-phragmen/src/migrations/v5.rs index a9fb018ba0219..eb96d7ddf6a99 100644 --- a/frame/elections-phragmen/src/migrations/v5.rs +++ b/frame/elections-phragmen/src/migrations/v5.rs @@ -8,7 +8,7 @@ use super::super::*; /// situation where they could increase their free balance but still not be able to use their funds /// because they were less than the lock. pub fn migrate(to_migrate: Vec) -> Weight { - let mut weight = 0; + let mut weight = Weight::new(); for who in to_migrate.iter() { if let Ok(mut voter) = Voting::::try_get(who) { diff --git a/frame/elections-phragmen/src/weights.rs b/frame/elections-phragmen/src/weights.rs index 0e067699e5fac..14c69bf16f7f1 100644 --- a/frame/elections-phragmen/src/weights.rs +++ b/frame/elections-phragmen/src/weights.rs @@ -41,7 +41,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_elections_phragmen. @@ -70,11 +70,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[1, 16]`. fn vote_equal(v: u32, ) -> Weight { - (27_011_000 as Weight) + Weight::from_ref_time(27_011_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((214_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(214_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Candidates (r:1 w:0) // Storage: Elections Members (r:1 w:0) @@ -83,11 +83,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[2, 16]`. fn vote_more(v: u32, ) -> Weight { - (40_240_000 as Weight) + Weight::from_ref_time(40_240_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((244_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(244_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Candidates (r:1 w:0) // Storage: Elections Members (r:1 w:0) @@ -96,38 +96,38 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[2, 16]`. fn vote_less(v: u32, ) -> Weight { - (40_394_000 as Weight) + Weight::from_ref_time(40_394_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((217_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(217_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Voting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn remove_voter() -> Weight { - (37_651_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(37_651_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Candidates (r:1 w:1) // Storage: Elections Members (r:1 w:0) // Storage: Elections RunnersUp (r:1 w:0) /// The range of component `c` is `[1, 1000]`. fn submit_candidacy(c: u32, ) -> Weight { - (42_217_000 as Weight) + Weight::from_ref_time(42_217_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((50_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(50_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Elections Candidates (r:1 w:1) /// The range of component `c` is `[1, 1000]`. fn renounce_candidacy_candidate(c: u32, ) -> Weight { - (46_459_000 as Weight) + Weight::from_ref_time(46_459_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((26_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(26_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Elections Members (r:1 w:1) // Storage: Elections RunnersUp (r:1 w:1) @@ -135,19 +135,19 @@ impl WeightInfo for SubstrateWeight { // Storage: Council Proposals (r:1 w:0) // Storage: Council Members (r:0 w:1) fn renounce_candidacy_members() -> Weight { - (45_189_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(45_189_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Elections RunnersUp (r:1 w:1) fn renounce_candidacy_runners_up() -> Weight { - (34_516_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(34_516_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Benchmark Override (r:0 w:0) fn remove_member_without_replacement() -> Weight { - (2_000_000_000_000 as Weight) + Weight::from_ref_time(2_000_000_000_000 as RefTimeWeight) } // Storage: Elections Members (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -156,9 +156,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Council Proposals (r:1 w:0) // Storage: Council Members (r:0 w:1) fn remove_member_with_replacement() -> Weight { - (51_838_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(51_838_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Elections Voting (r:5001 w:5000) // Storage: Elections Members (r:1 w:0) @@ -169,12 +169,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[5000, 10000]`. /// The range of component `d` is `[1, 5000]`. fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 76_000 - .saturating_add((63_721_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(Weight::from_ref_time(63_721_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((3 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes((3 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) } // Storage: Elections Candidates (r:1 w:1) // Storage: Elections Members (r:1 w:1) @@ -189,15 +189,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[1, 10000]`. /// The range of component `e` is `[10000, 160000]`. fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 773_000 - .saturating_add((81_534_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(81_534_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 51_000 - .saturating_add((4_453_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(280 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) + .saturating_add(Weight::from_ref_time(4_453_000 as RefTimeWeight).scalar_saturating_mul(e as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(280 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(c as RefTimeWeight))) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(c as RefTimeWeight))) } } @@ -210,11 +210,11 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[1, 16]`. fn vote_equal(v: u32, ) -> Weight { - (27_011_000 as Weight) + Weight::from_ref_time(27_011_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((214_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(214_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Candidates (r:1 w:0) // Storage: Elections Members (r:1 w:0) @@ -223,11 +223,11 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[2, 16]`. fn vote_more(v: u32, ) -> Weight { - (40_240_000 as Weight) + Weight::from_ref_time(40_240_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((244_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(244_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Candidates (r:1 w:0) // Storage: Elections Members (r:1 w:0) @@ -236,38 +236,38 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[2, 16]`. fn vote_less(v: u32, ) -> Weight { - (40_394_000 as Weight) + Weight::from_ref_time(40_394_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((217_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(217_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Voting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn remove_voter() -> Weight { - (37_651_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(37_651_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Candidates (r:1 w:1) // Storage: Elections Members (r:1 w:0) // Storage: Elections RunnersUp (r:1 w:0) /// The range of component `c` is `[1, 1000]`. fn submit_candidacy(c: u32, ) -> Weight { - (42_217_000 as Weight) + Weight::from_ref_time(42_217_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((50_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(50_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Elections Candidates (r:1 w:1) /// The range of component `c` is `[1, 1000]`. fn renounce_candidacy_candidate(c: u32, ) -> Weight { - (46_459_000 as Weight) + Weight::from_ref_time(46_459_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((26_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(26_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Elections Members (r:1 w:1) // Storage: Elections RunnersUp (r:1 w:1) @@ -275,19 +275,19 @@ impl WeightInfo for () { // Storage: Council Proposals (r:1 w:0) // Storage: Council Members (r:0 w:1) fn renounce_candidacy_members() -> Weight { - (45_189_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(45_189_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Elections RunnersUp (r:1 w:1) fn renounce_candidacy_runners_up() -> Weight { - (34_516_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(34_516_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Benchmark Override (r:0 w:0) fn remove_member_without_replacement() -> Weight { - (2_000_000_000_000 as Weight) + Weight::from_ref_time(2_000_000_000_000 as RefTimeWeight) } // Storage: Elections Members (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -296,9 +296,9 @@ impl WeightInfo for () { // Storage: Council Proposals (r:1 w:0) // Storage: Council Members (r:0 w:1) fn remove_member_with_replacement() -> Weight { - (51_838_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(51_838_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Elections Voting (r:5001 w:5000) // Storage: Elections Members (r:1 w:0) @@ -309,12 +309,12 @@ impl WeightInfo for () { /// The range of component `v` is `[5000, 10000]`. /// The range of component `d` is `[1, 5000]`. fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 76_000 - .saturating_add((63_721_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(Weight::from_ref_time(63_721_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((3 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes((3 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) } // Storage: Elections Candidates (r:1 w:1) // Storage: Elections Members (r:1 w:1) @@ -329,14 +329,14 @@ impl WeightInfo for () { /// The range of component `v` is `[1, 10000]`. /// The range of component `e` is `[10000, 160000]`. fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 773_000 - .saturating_add((81_534_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(81_534_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 51_000 - .saturating_add((4_453_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(RocksDbWeight::get().reads(280 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) + .saturating_add(Weight::from_ref_time(4_453_000 as RefTimeWeight).scalar_saturating_mul(e as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(280 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(c as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(c as RefTimeWeight))) } } diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index 03dc2c613c01e..ad46bdc4185bd 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -329,7 +329,7 @@ impl WeighData<(&BalanceOf,)> for WeightForSetDum let multiplier = self.0; // *target.0 is the amount passed into the extrinsic let cents = *target.0 / >::from(MILLICENTS); - (cents * multiplier).saturated_into::() + Weight::from_ref_time((cents * multiplier).saturated_into::()) } } @@ -392,7 +392,7 @@ pub mod pallet { fn on_initialize(_n: T::BlockNumber) -> Weight { // Anything that needs to be done at the start of the block. // We don't do anything here. - 0 + Weight::zero() } // `on_finalize` is executed at the end of block after all extrinsic are dispatched. diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index 0f659e12fb443..f6afb7a0c77f1 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -52,7 +52,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; @@ -190,7 +190,7 @@ fn weights_work() { let default_call = pallet_example_basic::Call::::accumulate_dummy { increase_by: 10 }; let info1 = default_call.get_dispatch_info(); // aka. `let info = as GetDispatchInfo>::get_dispatch_info(&default_call);` - assert!(info1.weight > 0); + assert!(info1.weight > Weight::zero()); // `set_dummy` is simpler than `accumulate_dummy`, and the weight // should be less. diff --git a/frame/examples/basic/src/weights.rs b/frame/examples/basic/src/weights.rs index 5fc6434e396eb..e8fc44bc4b050 100644 --- a/frame/examples/basic/src/weights.rs +++ b/frame/examples/basic/src/weights.rs @@ -49,7 +49,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_example_basic. @@ -63,39 +63,39 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn set_dummy_benchmark(b: u32, ) -> Weight { - (5_834_000 as Weight) - .saturating_add((24_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(5_834_000 as RefTimeWeight) + .saturating_add(Weight::from_ref_time(24_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } fn accumulate_dummy(b: u32, ) -> Weight { - (51_353_000 as Weight) - .saturating_add((14_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(51_353_000 as RefTimeWeight) + .saturating_add(Weight::from_ref_time(14_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } fn sort_vector(x: u32, ) -> Weight { - (2_569_000 as Weight) + Weight::from_ref_time(2_569_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(4_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) } } // For backwards compatibility and tests impl WeightInfo for () { fn set_dummy_benchmark(b: u32, ) -> Weight { - (5_834_000 as Weight) - .saturating_add((24_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(5_834_000 as RefTimeWeight) + .saturating_add(Weight::from_ref_time(24_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } fn accumulate_dummy(b: u32, ) -> Weight { - (51_353_000 as Weight) - .saturating_add((14_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(51_353_000 as RefTimeWeight) + .saturating_add(Weight::from_ref_time(14_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } fn sort_vector(x: u32, ) -> Weight { - (2_569_000 as Weight) + Weight::from_ref_time(2_569_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(4_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) } } diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 703220e64fa8a..5b03614333cc9 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -53,7 +53,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; diff --git a/frame/executive/README.md b/frame/executive/README.md index e96d07b0843f2..c14c3912b082d 100644 --- a/frame/executive/README.md +++ b/frame/executive/README.md @@ -56,7 +56,7 @@ struct CustomOnRuntimeUpgrade; impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { fn on_runtime_upgrade() -> frame_support::weights::Weight { // Do whatever you want. - 0 + frame_support::weights::Weight::zero() } } diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index cd3e1c500db26..45361084f2f42 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -107,7 +107,7 @@ //! impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { //! fn on_runtime_upgrade() -> frame_support::weights::Weight { //! // Do whatever you want. -//! 0 +//! frame_support::weights::Weight::zero() //! } //! } //! @@ -123,12 +123,12 @@ use frame_support::{ EnsureInherentsAreFirst, ExecuteBlock, OffchainWorker, OnFinalize, OnIdle, OnInitialize, OnRuntimeUpgrade, }, - weights::{DispatchClass, DispatchInfo, GetDispatchInfo}, + weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Weight}, }; use sp_runtime::{ generic::Digest, traits::{ - self, Applyable, CheckEqual, Checkable, Dispatchable, Header, NumberFor, One, Saturating, + self, Applyable, CheckEqual, Checkable, Dispatchable, Header, NumberFor, One, ValidateUnsigned, Zero, }, transaction_validity::{TransactionSource, TransactionValidity}, @@ -299,7 +299,7 @@ where // This means the format of all the event related storages must always be compatible. >::reset_events(); - let mut weight = 0; + let mut weight = Weight::new(); if Self::runtime_upgraded() { weight = weight.saturating_add(Self::execute_on_runtime_upgrade()); } @@ -413,7 +413,7 @@ where let max_weight = >::get().max_block; let remaining_weight = max_weight.saturating_sub(weight.total()); - if remaining_weight > 0 { + if remaining_weight > Weight::zero() { let used_weight = >::on_idle( block_number, remaining_weight, @@ -593,12 +593,12 @@ mod tests { // one with block number arg and one without fn on_initialize(n: T::BlockNumber) -> Weight { println!("on_initialize({})", n); - 175 + Weight::from_ref_time(175) } fn on_idle(n: T::BlockNumber, remaining_weight: Weight) -> Weight { println!("on_idle{}, {})", n, remaining_weight); - 175 + Weight::from_ref_time(175) } fn on_finalize(n: T::BlockNumber) { @@ -607,7 +607,7 @@ mod tests { fn on_runtime_upgrade() -> Weight { sp_io::storage::set(super::TEST_KEY, "module".as_bytes()); - 200 + Weight::from_ref_time(200) } fn offchain_worker(n: T::BlockNumber) { @@ -721,9 +721,9 @@ mod tests { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() - .base_block(10) - .for_class(DispatchClass::all(), |weights| weights.base_extrinsic = 5) - .for_class(DispatchClass::non_mandatory(), |weights| weights.max_total = 1024.into()) + .base_block(Weight::from_ref_time(10)) + .for_class(DispatchClass::all(), |weights| weights.base_extrinsic = Weight::from_ref_time(5)) + .for_class(DispatchClass::non_mandatory(), |weights| weights.max_total = Weight::from_ref_time(1024).into()) .build_or_panic(); pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { read: 10, @@ -814,7 +814,7 @@ mod tests { sp_io::storage::set(TEST_KEY, "custom_upgrade".as_bytes()); sp_io::storage::set(CUSTOM_ON_RUNTIME_KEY, &true.encode()); System::deposit_event(frame_system::Event::CodeUpdated); - 100 + Weight::from_ref_time(100) } } @@ -988,12 +988,12 @@ mod tests { sign_extra(1, 0, 0), ); let encoded = xt.encode(); - let encoded_len = encoded.len() as Weight; + let encoded_len = encoded.len() as u64; // on_initialize weight + base block execution weight let block_weights = ::BlockWeights::get(); - let base_block_weight = 175 + block_weights.base_block; + let base_block_weight = Weight::from_ref_time(175) + block_weights.base_block; let limit = block_weights.get(DispatchClass::Normal).max_total.unwrap() - base_block_weight; - let num_to_exhaust_block = limit / (encoded_len + 5); + let num_to_exhaust_block = limit.ref_time() / (encoded_len + 5); t.execute_with(|| { Executive::initialize_block(&Header::new( 1, @@ -1016,7 +1016,7 @@ mod tests { assert_eq!( >::block_weight().total(), //--------------------- on_initialize + block_execution + extrinsic_base weight - (encoded_len + 5) * (nonce + 1) + base_block_weight, + Weight::from_ref_time((encoded_len + 5) * (nonce + 1)) + base_block_weight, ); assert_eq!( >::extrinsic_index(), @@ -1047,8 +1047,8 @@ mod tests { let mut t = new_test_ext(1); t.execute_with(|| { // Block execution weight + on_initialize weight from custom module - let base_block_weight = - 175 + ::BlockWeights::get().base_block; + let base_block_weight = Weight::from_ref_time(175) + + ::BlockWeights::get().base_block; Executive::initialize_block(&Header::new( 1, @@ -1066,7 +1066,7 @@ mod tests { assert!(Executive::apply_extrinsic(x2.clone()).unwrap().is_ok()); // default weight for `TestXt` == encoded length. - let extrinsic_weight = len as Weight + + let extrinsic_weight = Weight::from_ref_time(len as u64) + ::BlockWeights::get() .get(DispatchClass::Normal) .base_extrinsic; @@ -1180,7 +1180,10 @@ mod tests { // NOTE: might need updates over time if new weights are introduced. // For now it only accounts for the base block execution weight and // the `on_initialize` weight defined in the custom test module. - assert_eq!(>::block_weight().total(), 175 + 175 + 10); + assert_eq!( + >::block_weight().total(), + Weight::from_ref_time(175 + 175 + 10) + ); }) } diff --git a/frame/gilt/src/lib.rs b/frame/gilt/src/lib.rs index 59522f9a106f2..b94b7d164f04c 100644 --- a/frame/gilt/src/lib.rs +++ b/frame/gilt/src/lib.rs @@ -335,7 +335,7 @@ pub mod pallet { if (n % T::IntakePeriod::get()).is_zero() { Self::pursue_target(T::MaxIntakeBids::get()) } else { - 0 + Weight::zero() } } } diff --git a/frame/gilt/src/weights.rs b/frame/gilt/src/weights.rs index 952080a2d030b..3d2b629e8b16b 100644 --- a/frame/gilt/src/weights.rs +++ b/frame/gilt/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_gilt. @@ -60,70 +60,70 @@ impl WeightInfo for SubstrateWeight { // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) fn place_bid(l: u32, ) -> Weight { - (41_605_000 as Weight) + Weight::from_ref_time(41_605_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((62_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(62_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) fn place_bid_max() -> Weight { - (97_715_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(97_715_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) fn retract_bid(l: u32, ) -> Weight { - (42_061_000 as Weight) + Weight::from_ref_time(42_061_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((52_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(52_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Gilt ActiveTotal (r:1 w:1) fn set_target() -> Weight { - (5_026_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(5_026_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Gilt Active (r:1 w:1) // Storage: Gilt ActiveTotal (r:1 w:1) fn thaw() -> Weight { - (47_753_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(47_753_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Gilt ActiveTotal (r:1 w:0) fn pursue_target_noop() -> Weight { - (1_663_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(1_663_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) } // Storage: Gilt ActiveTotal (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt Active (r:0 w:1) fn pursue_target_per_item(b: u32, ) -> Weight { - (40_797_000 as Weight) + Weight::from_ref_time(40_797_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((4_122_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(b as Weight))) + .saturating_add(Weight::from_ref_time(4_122_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(b as RefTimeWeight))) } // Storage: Gilt ActiveTotal (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt Active (r:0 w:1) fn pursue_target_per_queue(q: u32, ) -> Weight { - (14_944_000 as Weight) + Weight::from_ref_time(14_944_000 as RefTimeWeight) // Standard Error: 6_000 - .saturating_add((8_135_000 as Weight).saturating_mul(q as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(q as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(q as Weight))) + .saturating_add(Weight::from_ref_time(8_135_000 as RefTimeWeight).scalar_saturating_mul(q as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(q as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((2 as RefTimeWeight).saturating_mul(q as RefTimeWeight))) } } @@ -132,69 +132,69 @@ impl WeightInfo for () { // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) fn place_bid(l: u32, ) -> Weight { - (41_605_000 as Weight) + Weight::from_ref_time(41_605_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((62_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(62_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) fn place_bid_max() -> Weight { - (97_715_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(97_715_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) fn retract_bid(l: u32, ) -> Weight { - (42_061_000 as Weight) + Weight::from_ref_time(42_061_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((52_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(52_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Gilt ActiveTotal (r:1 w:1) fn set_target() -> Weight { - (5_026_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(5_026_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Gilt Active (r:1 w:1) // Storage: Gilt ActiveTotal (r:1 w:1) fn thaw() -> Weight { - (47_753_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(47_753_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Gilt ActiveTotal (r:1 w:0) fn pursue_target_noop() -> Weight { - (1_663_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(1_663_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) } // Storage: Gilt ActiveTotal (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt Active (r:0 w:1) fn pursue_target_per_item(b: u32, ) -> Weight { - (40_797_000 as Weight) + Weight::from_ref_time(40_797_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((4_122_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(b as Weight))) + .saturating_add(Weight::from_ref_time(4_122_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(b as RefTimeWeight))) } // Storage: Gilt ActiveTotal (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt Active (r:0 w:1) fn pursue_target_per_queue(q: u32, ) -> Weight { - (14_944_000 as Weight) + Weight::from_ref_time(14_944_000 as RefTimeWeight) // Standard Error: 6_000 - .saturating_add((8_135_000 as Weight).saturating_mul(q as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(q as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(q as Weight))) + .saturating_add(Weight::from_ref_time(8_135_000 as RefTimeWeight).scalar_saturating_mul(q as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(q as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((2 as RefTimeWeight).saturating_mul(q as RefTimeWeight))) } } diff --git a/frame/grandpa/src/default_weights.rs b/frame/grandpa/src/default_weights.rs index 330e9bb255177..f21c3ddc101f7 100644 --- a/frame/grandpa/src/default_weights.rs +++ b/frame/grandpa/src/default_weights.rs @@ -35,7 +35,7 @@ impl crate::WeightInfo for () { // checking membership proof (35 * WEIGHT_PER_MICROS) - .saturating_add((175 * WEIGHT_PER_NANOS).saturating_mul(validator_count)) + .saturating_add((175 * WEIGHT_PER_NANOS).scalar_saturating_mul(validator_count)) .saturating_add(DbWeight::get().reads(5)) // check equivocation proof .saturating_add(95 * WEIGHT_PER_MICROS) diff --git a/frame/grandpa/src/migrations/v4.rs b/frame/grandpa/src/migrations/v4.rs index ab43f7baef4e9..81dbd3bab4b67 100644 --- a/frame/grandpa/src/migrations/v4.rs +++ b/frame/grandpa/src/migrations/v4.rs @@ -37,7 +37,7 @@ pub fn migrate>(new_pallet_name: N) -> Weight { target: "runtime::afg", "New pallet name is equal to the old prefix. No migration needs to be done.", ); - return 0 + return Weight::zero() } let storage_version = StorageVersion::get::>(); log::info!( @@ -57,7 +57,7 @@ pub fn migrate>(new_pallet_name: N) -> Weight { ::BlockWeights::get().max_block } else { - 0 + Weight::zero() } } diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 5e6c955c441c5..d246466cf0db4 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -71,7 +71,7 @@ impl_opaque_keys! { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { diff --git a/frame/grandpa/src/tests.rs b/frame/grandpa/src/tests.rs index ab0a9c677b00e..9c39069bf9538 100644 --- a/frame/grandpa/src/tests.rs +++ b/frame/grandpa/src/tests.rs @@ -856,7 +856,7 @@ fn valid_equivocation_reports_dont_pay_fees() { .get_dispatch_info(); // it should have non-zero weight and the fee has to be paid. - assert!(info.weight > 0); + assert!(info.weight > Weight::zero()); assert_eq!(info.pays_fee, Pays::Yes); // report the equivocation. diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 6066f176a6106..a0773e9904a1c 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -50,7 +50,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; diff --git a/frame/identity/src/weights.rs b/frame/identity/src/weights.rs index 7d3371c31b03b..780abf1bb01df 100644 --- a/frame/identity/src/weights.rs +++ b/frame/identity/src/weights.rs @@ -40,7 +40,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_identity. @@ -69,48 +69,48 @@ impl WeightInfo for SubstrateWeight { // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn add_registrar(r: u32, ) -> Weight { - (16_649_000 as Weight) + Weight::from_ref_time(16_649_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((241_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(241_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[1, 100]`. fn set_identity(r: u32, x: u32, ) -> Weight { - (31_322_000 as Weight) + Weight::from_ref_time(31_322_000 as RefTimeWeight) // Standard Error: 10_000 - .saturating_add((252_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(252_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((312_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(312_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn set_subs_new(s: u32, ) -> Weight { - (30_012_000 as Weight) + Weight::from_ref_time(30_012_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((3_005_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(3_005_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SuperOf (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn set_subs_old(p: u32, ) -> Weight { - (29_623_000 as Weight) + Weight::from_ref_time(29_623_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_100_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + .saturating_add(Weight::from_ref_time(1_100_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) @@ -119,81 +119,81 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 100]`. /// The range of component `x` is `[1, 100]`. fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { - (34_370_000 as Weight) + Weight::from_ref_time(34_370_000 as RefTimeWeight) // Standard Error: 10_000 - .saturating_add((186_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(186_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((1_114_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(1_114_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((189_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(189_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[1, 100]`. fn request_judgement(r: u32, x: u32, ) -> Weight { - (34_759_000 as Weight) + Weight::from_ref_time(34_759_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((251_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(251_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 0 - .saturating_add((340_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(340_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[1, 100]`. fn cancel_request(r: u32, x: u32, ) -> Weight { - (32_254_000 as Weight) + Weight::from_ref_time(32_254_000 as RefTimeWeight) // Standard Error: 7_000 - .saturating_add((159_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(159_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 0 - .saturating_add((347_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(347_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_fee(r: u32, ) -> Weight { - (7_858_000 as Weight) + Weight::from_ref_time(7_858_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((190_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(190_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_account_id(r: u32, ) -> Weight { - (8_011_000 as Weight) + Weight::from_ref_time(8_011_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((187_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(187_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_fields(r: u32, ) -> Weight { - (7_970_000 as Weight) + Weight::from_ref_time(7_970_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((175_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(175_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 19]`. /// The range of component `x` is `[1, 100]`. fn provide_judgement(r: u32, x: u32, ) -> Weight { - (24_730_000 as Weight) + Weight::from_ref_time(24_730_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((196_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(196_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 0 - .saturating_add((341_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(341_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) @@ -203,58 +203,58 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[1, 100]`. /// The range of component `x` is `[1, 100]`. fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight { - (44_988_000 as Weight) + Weight::from_ref_time(44_988_000 as RefTimeWeight) // Standard Error: 10_000 - .saturating_add((201_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(201_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((1_126_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(1_126_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((2_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) /// The range of component `s` is `[1, 99]`. fn add_sub(s: u32, ) -> Weight { - (36_768_000 as Weight) + Weight::from_ref_time(36_768_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((115_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(115_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn rename_sub(s: u32, ) -> Weight { - (13_474_000 as Weight) + Weight::from_ref_time(13_474_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((56_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)) + .saturating_add(Weight::from_ref_time(56_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn remove_sub(s: u32, ) -> Weight { - (37_720_000 as Weight) + Weight::from_ref_time(37_720_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((114_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(114_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) /// The range of component `s` is `[1, 99]`. fn quit_sub(s: u32, ) -> Weight { - (26_848_000 as Weight) + Weight::from_ref_time(26_848_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((115_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)) + .saturating_add(Weight::from_ref_time(115_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } } @@ -263,48 +263,48 @@ impl WeightInfo for () { // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn add_registrar(r: u32, ) -> Weight { - (16_649_000 as Weight) + Weight::from_ref_time(16_649_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((241_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(241_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[1, 100]`. fn set_identity(r: u32, x: u32, ) -> Weight { - (31_322_000 as Weight) + Weight::from_ref_time(31_322_000 as RefTimeWeight) // Standard Error: 10_000 - .saturating_add((252_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(252_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((312_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(312_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn set_subs_new(s: u32, ) -> Weight { - (30_012_000 as Weight) + Weight::from_ref_time(30_012_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((3_005_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(3_005_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SuperOf (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn set_subs_old(p: u32, ) -> Weight { - (29_623_000 as Weight) + Weight::from_ref_time(29_623_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_100_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + .saturating_add(Weight::from_ref_time(1_100_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) @@ -313,81 +313,81 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 100]`. /// The range of component `x` is `[1, 100]`. fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { - (34_370_000 as Weight) + Weight::from_ref_time(34_370_000 as RefTimeWeight) // Standard Error: 10_000 - .saturating_add((186_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(186_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((1_114_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(1_114_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((189_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(189_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[1, 100]`. fn request_judgement(r: u32, x: u32, ) -> Weight { - (34_759_000 as Weight) + Weight::from_ref_time(34_759_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((251_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(251_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 0 - .saturating_add((340_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(340_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[1, 100]`. fn cancel_request(r: u32, x: u32, ) -> Weight { - (32_254_000 as Weight) + Weight::from_ref_time(32_254_000 as RefTimeWeight) // Standard Error: 7_000 - .saturating_add((159_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(159_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 0 - .saturating_add((347_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(347_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_fee(r: u32, ) -> Weight { - (7_858_000 as Weight) + Weight::from_ref_time(7_858_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((190_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(190_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_account_id(r: u32, ) -> Weight { - (8_011_000 as Weight) + Weight::from_ref_time(8_011_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((187_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(187_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_fields(r: u32, ) -> Weight { - (7_970_000 as Weight) + Weight::from_ref_time(7_970_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((175_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(175_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 19]`. /// The range of component `x` is `[1, 100]`. fn provide_judgement(r: u32, x: u32, ) -> Weight { - (24_730_000 as Weight) + Weight::from_ref_time(24_730_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((196_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(196_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 0 - .saturating_add((341_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(341_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) @@ -397,57 +397,57 @@ impl WeightInfo for () { /// The range of component `s` is `[1, 100]`. /// The range of component `x` is `[1, 100]`. fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight { - (44_988_000 as Weight) + Weight::from_ref_time(44_988_000 as RefTimeWeight) // Standard Error: 10_000 - .saturating_add((201_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(201_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((1_126_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(1_126_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((2_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) /// The range of component `s` is `[1, 99]`. fn add_sub(s: u32, ) -> Weight { - (36_768_000 as Weight) + Weight::from_ref_time(36_768_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((115_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(115_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn rename_sub(s: u32, ) -> Weight { - (13_474_000 as Weight) + Weight::from_ref_time(13_474_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((56_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(56_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn remove_sub(s: u32, ) -> Weight { - (37_720_000 as Weight) + Weight::from_ref_time(37_720_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((114_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(114_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) /// The range of component `s` is `[1, 99]`. fn quit_sub(s: u32, ) -> Weight { - (26_848_000 as Weight) + Weight::from_ref_time(26_848_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((115_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(115_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } } diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 2459f7e748941..b734bd37b6fd4 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -123,7 +123,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Runtime { diff --git a/frame/im-online/src/weights.rs b/frame/im-online/src/weights.rs index 34762e66ec301..09fbc55854288 100644 --- a/frame/im-online/src/weights.rs +++ b/frame/im-online/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_im_online. @@ -56,13 +56,13 @@ impl WeightInfo for SubstrateWeight { // Storage: ImOnline AuthoredBlocks (r:1 w:0) // Storage: ImOnline Keys (r:1 w:0) fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight { - (79_225_000 as Weight) + Weight::from_ref_time(79_225_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((41_000 as Weight).saturating_mul(k as Weight)) + .saturating_add(Weight::from_ref_time(41_000 as RefTimeWeight).scalar_saturating_mul(k as RefTimeWeight)) // Standard Error: 0 - .saturating_add((293_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(293_000 as RefTimeWeight).scalar_saturating_mul(e as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } } @@ -74,12 +74,12 @@ impl WeightInfo for () { // Storage: ImOnline AuthoredBlocks (r:1 w:0) // Storage: ImOnline Keys (r:1 w:0) fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight { - (79_225_000 as Weight) + Weight::from_ref_time(79_225_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((41_000 as Weight).saturating_mul(k as Weight)) + .saturating_add(Weight::from_ref_time(41_000 as RefTimeWeight).scalar_saturating_mul(k as RefTimeWeight)) // Standard Error: 0 - .saturating_add((293_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(293_000 as RefTimeWeight).scalar_saturating_mul(e as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } } diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 6bd79708c3dd2..693296a3b1064 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -44,7 +44,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { diff --git a/frame/indices/src/weights.rs b/frame/indices/src/weights.rs index 6635d45272048..2475c86fd499b 100644 --- a/frame/indices/src/weights.rs +++ b/frame/indices/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_indices. @@ -56,35 +56,35 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Indices Accounts (r:1 w:1) fn claim() -> Weight { - (25_929_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_929_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (32_627_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_627_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Indices Accounts (r:1 w:1) fn free() -> Weight { - (26_804_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(26_804_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn force_transfer() -> Weight { - (27_390_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(27_390_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Indices Accounts (r:1 w:1) fn freeze() -> Weight { - (30_973_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(30_973_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } } @@ -92,34 +92,34 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: Indices Accounts (r:1 w:1) fn claim() -> Weight { - (25_929_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_929_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (32_627_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_627_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Indices Accounts (r:1 w:1) fn free() -> Weight { - (26_804_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(26_804_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn force_transfer() -> Weight { - (27_390_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(27_390_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Indices Accounts (r:1 w:1) fn freeze() -> Weight { - (30_973_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(30_973_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } } diff --git a/frame/lottery/src/weights.rs b/frame/lottery/src/weights.rs index 193958cfd41aa..f646ca02a0377 100644 --- a/frame/lottery/src/weights.rs +++ b/frame/lottery/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_lottery. @@ -63,30 +63,30 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: Lottery Tickets (r:0 w:1) fn buy_ticket() -> Weight { - (44_706_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(44_706_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Lottery CallIndices (r:0 w:1) fn set_calls(n: u32, ) -> Weight { - (12_556_000 as Weight) + Weight::from_ref_time(12_556_000 as RefTimeWeight) // Standard Error: 7_000 - .saturating_add((295_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(295_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Lottery Lottery (r:1 w:1) // Storage: Lottery LotteryIndex (r:1 w:1) // Storage: System Account (r:1 w:1) fn start_lottery() -> Weight { - (38_051_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(38_051_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Lottery Lottery (r:1 w:1) fn stop_repeat() -> Weight { - (6_910_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(6_910_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) // Storage: Lottery Lottery (r:1 w:1) @@ -94,9 +94,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Lottery TicketsCount (r:1 w:1) // Storage: Lottery Tickets (r:1 w:0) fn on_initialize_end() -> Weight { - (53_732_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(53_732_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) // Storage: Lottery Lottery (r:1 w:1) @@ -105,9 +105,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Lottery Tickets (r:1 w:0) // Storage: Lottery LotteryIndex (r:1 w:1) fn on_initialize_repeat() -> Weight { - (55_868_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(55_868_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(7 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } } @@ -121,30 +121,30 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: Lottery Tickets (r:0 w:1) fn buy_ticket() -> Weight { - (44_706_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(44_706_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Lottery CallIndices (r:0 w:1) fn set_calls(n: u32, ) -> Weight { - (12_556_000 as Weight) + Weight::from_ref_time(12_556_000 as RefTimeWeight) // Standard Error: 7_000 - .saturating_add((295_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(295_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Lottery Lottery (r:1 w:1) // Storage: Lottery LotteryIndex (r:1 w:1) // Storage: System Account (r:1 w:1) fn start_lottery() -> Weight { - (38_051_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(38_051_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Lottery Lottery (r:1 w:1) fn stop_repeat() -> Weight { - (6_910_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(6_910_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) // Storage: Lottery Lottery (r:1 w:1) @@ -152,9 +152,9 @@ impl WeightInfo for () { // Storage: Lottery TicketsCount (r:1 w:1) // Storage: Lottery Tickets (r:1 w:0) fn on_initialize_end() -> Weight { - (53_732_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(53_732_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) // Storage: Lottery Lottery (r:1 w:1) @@ -163,8 +163,8 @@ impl WeightInfo for () { // Storage: Lottery Tickets (r:1 w:0) // Storage: Lottery LotteryIndex (r:1 w:1) fn on_initialize_repeat() -> Weight { - (55_868_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(55_868_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(7 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } } diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 32e1130f3d944..b4c9c3b38f1da 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -532,7 +532,7 @@ mod tests { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); pub static Members: Vec = vec![]; pub static Prime: Option = None; } diff --git a/frame/membership/src/migrations/v4.rs b/frame/membership/src/migrations/v4.rs index b3b52751d9598..5b8735aa2bac9 100644 --- a/frame/membership/src/migrations/v4.rs +++ b/frame/membership/src/migrations/v4.rs @@ -46,7 +46,7 @@ pub fn migrate::on_chain_storage_version(); @@ -71,7 +71,7 @@ pub fn migrate WeightInfo for SubstrateWeight { // Storage: TechnicalCommittee Members (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn add_member(m: u32, ) -> Weight { - (15_318_000 as Weight) + Weight::from_ref_time(15_318_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((51_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(51_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -73,11 +73,11 @@ impl WeightInfo for SubstrateWeight { // Storage: TechnicalCommittee Members (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn remove_member(m: u32, ) -> Weight { - (18_005_000 as Weight) + Weight::from_ref_time(18_005_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((45_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(45_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -85,11 +85,11 @@ impl WeightInfo for SubstrateWeight { // Storage: TechnicalCommittee Members (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn swap_member(m: u32, ) -> Weight { - (18_029_000 as Weight) + Weight::from_ref_time(18_029_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((55_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(55_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -97,11 +97,11 @@ impl WeightInfo for SubstrateWeight { // Storage: TechnicalCommittee Members (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn reset_member(m: u32, ) -> Weight { - (18_105_000 as Weight) + Weight::from_ref_time(18_105_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((158_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(158_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -109,29 +109,29 @@ impl WeightInfo for SubstrateWeight { // Storage: TechnicalCommittee Members (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn change_key(m: u32, ) -> Weight { - (18_852_000 as Weight) + Weight::from_ref_time(18_852_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((55_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(55_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: TechnicalMembership Members (r:1 w:0) // Storage: TechnicalMembership Prime (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn set_prime(m: u32, ) -> Weight { - (4_869_000 as Weight) + Weight::from_ref_time(4_869_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((28_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(28_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: TechnicalMembership Prime (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn clear_prime(m: u32, ) -> Weight { - (1_593_000 as Weight) + Weight::from_ref_time(1_593_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } } @@ -142,11 +142,11 @@ impl WeightInfo for () { // Storage: TechnicalCommittee Members (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn add_member(m: u32, ) -> Weight { - (15_318_000 as Weight) + Weight::from_ref_time(15_318_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((51_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(51_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -154,11 +154,11 @@ impl WeightInfo for () { // Storage: TechnicalCommittee Members (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn remove_member(m: u32, ) -> Weight { - (18_005_000 as Weight) + Weight::from_ref_time(18_005_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((45_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(45_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -166,11 +166,11 @@ impl WeightInfo for () { // Storage: TechnicalCommittee Members (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn swap_member(m: u32, ) -> Weight { - (18_029_000 as Weight) + Weight::from_ref_time(18_029_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((55_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(55_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -178,11 +178,11 @@ impl WeightInfo for () { // Storage: TechnicalCommittee Members (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn reset_member(m: u32, ) -> Weight { - (18_105_000 as Weight) + Weight::from_ref_time(18_105_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((158_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(158_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -190,28 +190,28 @@ impl WeightInfo for () { // Storage: TechnicalCommittee Members (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn change_key(m: u32, ) -> Weight { - (18_852_000 as Weight) + Weight::from_ref_time(18_852_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((55_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(55_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: TechnicalMembership Members (r:1 w:0) // Storage: TechnicalMembership Prime (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn set_prime(m: u32, ) -> Weight { - (4_869_000 as Weight) + Weight::from_ref_time(4_869_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((28_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(28_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: TechnicalMembership Prime (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) fn clear_prime(m: u32, ) -> Weight { - (1_593_000 as Weight) + Weight::from_ref_time(1_593_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } } diff --git a/frame/merkle-mountain-range/src/default_weights.rs b/frame/merkle-mountain-range/src/default_weights.rs index 73d1963a42964..e7a4b6ab31c4a 100644 --- a/frame/merkle-mountain-range/src/default_weights.rs +++ b/frame/merkle-mountain-range/src/default_weights.rs @@ -30,7 +30,7 @@ impl crate::WeightInfo for () { // Blake2 hash cost. let hash_weight = 2 * WEIGHT_PER_NANOS; // No-op hook. - let hook_weight = 0; + let hook_weight = Weight::zero(); leaf_weight .saturating_add(hash_weight) diff --git a/frame/merkle-mountain-range/src/tests.rs b/frame/merkle-mountain-range/src/tests.rs index 566a051823d5e..e13f89617bb9a 100644 --- a/frame/merkle-mountain-range/src/tests.rs +++ b/frame/merkle-mountain-range/src/tests.rs @@ -39,7 +39,7 @@ fn register_offchain_ext(ext: &mut sp_io::TestExternalities) { ext.register_extension(OffchainWorkerExt::new(offchain)); } -fn new_block() -> u64 { +fn new_block() -> Weight { let number = frame_system::Pallet::::block_number() + 1; let hash = H256::repeat_byte(number as u8); LEAF_DATA.with(|r| r.borrow_mut().a = number); @@ -110,7 +110,7 @@ fn should_start_empty() { crate::RootHash::::get(), hex("4320435e8c3318562dba60116bdbcc0b82ffcecb9bb39aae3300cfda3ad0b8b0") ); - assert!(weight != 0); + assert!(weight != Weight::zero()); }); } diff --git a/frame/multisig/src/benchmarking.rs b/frame/multisig/src/benchmarking.rs index 8201426f5330f..dafc421a7b72d 100644 --- a/frame/multisig/src/benchmarking.rs +++ b/frame/multisig/src/benchmarking.rs @@ -80,7 +80,7 @@ benchmarks! { // Whitelist caller account from further DB operations. let caller_key = frame_system::Account::::hashed_key_for(&caller); frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into()); - }: as_multi(RawOrigin::Signed(caller), s as u16, signatories, None, call, false, 0) + }: as_multi(RawOrigin::Signed(caller), s as u16, signatories, None, call, false, Weight::zero()) verify { assert!(Multisigs::::contains_key(multi_account_id, call_hash)); assert!(!Calls::::contains_key(call_hash)); @@ -99,7 +99,7 @@ benchmarks! { // Whitelist caller account from further DB operations. let caller_key = frame_system::Account::::hashed_key_for(&caller); frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into()); - }: as_multi(RawOrigin::Signed(caller), s as u16, signatories, None, call, true, 0) + }: as_multi(RawOrigin::Signed(caller), s as u16, signatories, None, call, true, Weight::zero()) verify { assert!(Multisigs::::contains_key(multi_account_id, call_hash)); assert!(Calls::::contains_key(call_hash)); @@ -118,13 +118,13 @@ benchmarks! { // before the call, get the timepoint let timepoint = Multisig::::timepoint(); // Create the multi, storing for worst case - Multisig::::as_multi(RawOrigin::Signed(caller).into(), s as u16, signatories, None, call.clone(), true, 0)?; + Multisig::::as_multi(RawOrigin::Signed(caller).into(), s as u16, signatories, None, call.clone(), true, Weight::zero())?; assert!(Calls::::contains_key(call_hash)); let caller2 = signatories2.remove(0); // Whitelist caller account from further DB operations. let caller_key = frame_system::Account::::hashed_key_for(&caller2); frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into()); - }: as_multi(RawOrigin::Signed(caller2), s as u16, signatories2, Some(timepoint), call, false, 0) + }: as_multi(RawOrigin::Signed(caller2), s as u16, signatories2, Some(timepoint), call, false, Weight::zero()) verify { let multisig = Multisigs::::get(multi_account_id, call_hash).ok_or("multisig not created")?; assert_eq!(multisig.approvals.len(), 2); @@ -143,13 +143,13 @@ benchmarks! { // before the call, get the timepoint let timepoint = Multisig::::timepoint(); // Create the multi, not storing - Multisig::::as_multi(RawOrigin::Signed(caller).into(), s as u16, signatories, None, call.clone(), false, 0)?; + Multisig::::as_multi(RawOrigin::Signed(caller).into(), s as u16, signatories, None, call.clone(), false, Weight::zero())?; assert!(!Calls::::contains_key(call_hash)); let caller2 = signatories2.remove(0); // Whitelist caller account from further DB operations. let caller_key = frame_system::Account::::hashed_key_for(&caller2); frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into()); - }: as_multi(RawOrigin::Signed(caller2), s as u16, signatories2, Some(timepoint), call, true, 0) + }: as_multi(RawOrigin::Signed(caller2), s as u16, signatories2, Some(timepoint), call, true, Weight::zero()) verify { let multisig = Multisigs::::get(multi_account_id, call_hash).ok_or("multisig not created")?; assert_eq!(multisig.approvals.len(), 2); @@ -169,20 +169,20 @@ benchmarks! { // before the call, get the timepoint let timepoint = Multisig::::timepoint(); // Create the multi, storing it for worst case - Multisig::::as_multi(RawOrigin::Signed(caller).into(), s as u16, signatories, None, call.clone(), true, 0)?; + Multisig::::as_multi(RawOrigin::Signed(caller).into(), s as u16, signatories, None, call.clone(), true, Weight::zero())?; // Everyone except the first person approves for i in 1 .. s - 1 { let mut signatories_loop = signatories2.clone(); let caller_loop = signatories_loop.remove(i as usize); let o = RawOrigin::Signed(caller_loop).into(); - Multisig::::as_multi(o, s as u16, signatories_loop, Some(timepoint), call.clone(), false, 0)?; + Multisig::::as_multi(o, s as u16, signatories_loop, Some(timepoint), call.clone(), false, Weight::zero())?; } let caller2 = signatories2.remove(0); assert!(Multisigs::::contains_key(&multi_account_id, call_hash)); // Whitelist caller account from further DB operations. let caller_key = frame_system::Account::::hashed_key_for(&caller2); frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into()); - }: as_multi(RawOrigin::Signed(caller2), s as u16, signatories2, Some(timepoint), call, false, Weight::max_value()) + }: as_multi(RawOrigin::Signed(caller2), s as u16, signatories2, Some(timepoint), call, false, Weight::MAX) verify { assert!(!Multisigs::::contains_key(&multi_account_id, call_hash)); } @@ -200,7 +200,7 @@ benchmarks! { let caller_key = frame_system::Account::::hashed_key_for(&caller); frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into()); // Create the multi - }: approve_as_multi(RawOrigin::Signed(caller), s as u16, signatories, None, call_hash, 0) + }: approve_as_multi(RawOrigin::Signed(caller), s as u16, signatories, None, call_hash, Weight::zero()) verify { assert!(Multisigs::::contains_key(multi_account_id, call_hash)); } @@ -225,13 +225,13 @@ benchmarks! { None, call, false, - 0 + Weight::zero() )?; let caller2 = signatories2.remove(0); // Whitelist caller account from further DB operations. let caller_key = frame_system::Account::::hashed_key_for(&caller2); frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into()); - }: approve_as_multi(RawOrigin::Signed(caller2), s as u16, signatories2, Some(timepoint), call_hash, 0) + }: approve_as_multi(RawOrigin::Signed(caller2), s as u16, signatories2, Some(timepoint), call_hash, Weight::zero()) verify { let multisig = Multisigs::::get(multi_account_id, call_hash).ok_or("multisig not created")?; assert_eq!(multisig.approvals.len(), 2); @@ -251,13 +251,13 @@ benchmarks! { // before the call, get the timepoint let timepoint = Multisig::::timepoint(); // Create the multi - Multisig::::as_multi(RawOrigin::Signed(caller).into(), s as u16, signatories, None, call.clone(), true, 0)?; + Multisig::::as_multi(RawOrigin::Signed(caller).into(), s as u16, signatories, None, call.clone(), true, Weight::zero())?; // Everyone except the first person approves for i in 1 .. s - 1 { let mut signatories_loop = signatories2.clone(); let caller_loop = signatories_loop.remove(i as usize); let o = RawOrigin::Signed(caller_loop).into(); - Multisig::::as_multi(o, s as u16, signatories_loop, Some(timepoint), call.clone(), false, 0)?; + Multisig::::as_multi(o, s as u16, signatories_loop, Some(timepoint), call.clone(), false, Weight::zero())?; } let caller2 = signatories2.remove(0); assert!(Multisigs::::contains_key(&multi_account_id, call_hash)); @@ -270,7 +270,7 @@ benchmarks! { signatories2, Some(timepoint), call_hash, - Weight::max_value() + Weight::MAX ) verify { assert!(!Multisigs::::contains_key(multi_account_id, call_hash)); @@ -288,7 +288,7 @@ benchmarks! { let timepoint = Multisig::::timepoint(); // Create the multi let o = RawOrigin::Signed(caller.clone()).into(); - Multisig::::as_multi(o, s as u16, signatories.clone(), None, call, true, 0)?; + Multisig::::as_multi(o, s as u16, signatories.clone(), None, call, true, Weight::zero())?; assert!(Multisigs::::contains_key(&multi_account_id, call_hash)); assert!(Calls::::contains_key(call_hash)); // Whitelist caller account from further DB operations. diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index d4ea041e5820e..10184ce84a9a8 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -257,9 +257,9 @@ pub mod pallet { let dispatch_info = call.get_dispatch_info(); ( T::WeightInfo::as_multi_threshold_1(call.using_encoded(|c| c.len() as u32)) - .saturating_add(dispatch_info.weight) // AccountData for inner call origin accountdata. - .saturating_add(T::DbWeight::get().reads_writes(1, 1)), + .saturating_add(T::DbWeight::get().reads_writes(1, 1)) + .saturating_add(dispatch_info.weight), dispatch_info.class, ) })] diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index 5d37e32e4d8a4..ddf5197ab734c 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -50,7 +50,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type BaseCallFilter = TestBaseCallFilter; @@ -152,7 +152,7 @@ fn multisig_deposit_is_taken_and_returned() { None, OpaqueCall::from_encoded(data.clone()), false, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(1), 2); assert_eq!(Balances::reserved_balance(1), 3); @@ -190,7 +190,7 @@ fn multisig_deposit_is_taken_and_returned_with_call_storage() { None, OpaqueCall::from_encoded(data), true, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(1), 0); assert_eq!(Balances::reserved_balance(1), 5); @@ -221,7 +221,14 @@ fn multisig_deposit_is_taken_and_returned_with_alt_call_storage() { let data = call.encode(); let hash = blake2_256(&data); - assert_ok!(Multisig::approve_as_multi(Origin::signed(1), 3, vec![2, 3], None, hash, 0)); + assert_ok!(Multisig::approve_as_multi( + Origin::signed(1), + 3, + vec![2, 3], + None, + hash, + Weight::zero() + )); assert_eq!(Balances::free_balance(1), 1); assert_eq!(Balances::reserved_balance(1), 4); @@ -232,7 +239,7 @@ fn multisig_deposit_is_taken_and_returned_with_alt_call_storage() { Some(now()), OpaqueCall::from_encoded(data), true, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(2), 3); assert_eq!(Balances::reserved_balance(2), 2); @@ -259,18 +266,25 @@ fn cancel_multisig_returns_deposit() { new_test_ext().execute_with(|| { let call = call_transfer(6, 15).encode(); let hash = blake2_256(&call); - assert_ok!(Multisig::approve_as_multi(Origin::signed(1), 3, vec![2, 3], None, hash, 0)); + assert_ok!(Multisig::approve_as_multi( + Origin::signed(1), + 3, + vec![2, 3], + None, + hash, + Weight::zero() + )); assert_ok!(Multisig::approve_as_multi( Origin::signed(2), 3, vec![1, 3], Some(now()), hash, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(1), 6); assert_eq!(Balances::reserved_balance(1), 4); - assert_ok!(Multisig::cancel_as_multi(Origin::signed(1), 3, vec![2, 3], now(), hash),); + assert_ok!(Multisig::cancel_as_multi(Origin::signed(1), 3, vec![2, 3], now(), hash)); assert_eq!(Balances::free_balance(1), 10); assert_eq!(Balances::reserved_balance(1), 0); }); @@ -288,11 +302,25 @@ fn timepoint_checking_works() { let hash = blake2_256(&call); assert_noop!( - Multisig::approve_as_multi(Origin::signed(2), 2, vec![1, 3], Some(now()), hash, 0), + Multisig::approve_as_multi( + Origin::signed(2), + 2, + vec![1, 3], + Some(now()), + hash, + Weight::zero() + ), Error::::UnexpectedTimepoint, ); - assert_ok!(Multisig::approve_as_multi(Origin::signed(1), 2, vec![2, 3], None, hash, 0)); + assert_ok!(Multisig::approve_as_multi( + Origin::signed(1), + 2, + vec![2, 3], + None, + hash, + Weight::zero() + )); assert_noop!( Multisig::as_multi( @@ -302,7 +330,7 @@ fn timepoint_checking_works() { None, OpaqueCall::from_encoded(call.clone()), false, - 0 + Weight::zero() ), Error::::NoTimepoint, ); @@ -315,7 +343,7 @@ fn timepoint_checking_works() { Some(later), OpaqueCall::from_encoded(call), false, - 0 + Weight::zero() ), Error::::WrongTimepoint, ); @@ -341,7 +369,7 @@ fn multisig_2_of_3_works_with_call_storing() { None, OpaqueCall::from_encoded(data), true, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(6), 0); @@ -369,7 +397,14 @@ fn multisig_2_of_3_works() { let call_weight = call.get_dispatch_info().weight; let data = call.encode(); let hash = blake2_256(&data); - assert_ok!(Multisig::approve_as_multi(Origin::signed(1), 2, vec![2, 3], None, hash, 0)); + assert_ok!(Multisig::approve_as_multi( + Origin::signed(1), + 2, + vec![2, 3], + None, + hash, + Weight::zero() + )); assert_eq!(Balances::free_balance(6), 0); assert_ok!(Multisig::as_multi( @@ -397,14 +432,21 @@ fn multisig_3_of_3_works() { let call_weight = call.get_dispatch_info().weight; let data = call.encode(); let hash = blake2_256(&data); - assert_ok!(Multisig::approve_as_multi(Origin::signed(1), 3, vec![2, 3], None, hash, 0)); + assert_ok!(Multisig::approve_as_multi( + Origin::signed(1), + 3, + vec![2, 3], + None, + hash, + Weight::zero() + )); assert_ok!(Multisig::approve_as_multi( Origin::signed(2), 3, vec![1, 3], Some(now()), hash, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(6), 0); @@ -426,14 +468,21 @@ fn cancel_multisig_works() { new_test_ext().execute_with(|| { let call = call_transfer(6, 15).encode(); let hash = blake2_256(&call); - assert_ok!(Multisig::approve_as_multi(Origin::signed(1), 3, vec![2, 3], None, hash, 0)); + assert_ok!(Multisig::approve_as_multi( + Origin::signed(1), + 3, + vec![2, 3], + None, + hash, + Weight::zero() + )); assert_ok!(Multisig::approve_as_multi( Origin::signed(2), 3, vec![1, 3], Some(now()), hash, - 0 + Weight::zero() )); assert_noop!( Multisig::cancel_as_multi(Origin::signed(2), 3, vec![1, 3], now(), hash), @@ -455,7 +504,7 @@ fn cancel_multisig_with_call_storage_works() { None, OpaqueCall::from_encoded(call), true, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(1), 4); assert_ok!(Multisig::approve_as_multi( @@ -464,7 +513,7 @@ fn cancel_multisig_with_call_storage_works() { vec![1, 3], Some(now()), hash, - 0 + Weight::zero() )); assert_noop!( Multisig::cancel_as_multi(Origin::signed(2), 3, vec![1, 3], now(), hash), @@ -480,7 +529,14 @@ fn cancel_multisig_with_alt_call_storage_works() { new_test_ext().execute_with(|| { let call = call_transfer(6, 15).encode(); let hash = blake2_256(&call); - assert_ok!(Multisig::approve_as_multi(Origin::signed(1), 3, vec![2, 3], None, hash, 0)); + assert_ok!(Multisig::approve_as_multi( + Origin::signed(1), + 3, + vec![2, 3], + None, + hash, + Weight::zero() + )); assert_eq!(Balances::free_balance(1), 6); assert_ok!(Multisig::as_multi( Origin::signed(2), @@ -489,7 +545,7 @@ fn cancel_multisig_with_alt_call_storage_works() { Some(now()), OpaqueCall::from_encoded(call), true, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(2), 8); assert_ok!(Multisig::cancel_as_multi(Origin::signed(1), 3, vec![2, 3], now(), hash)); @@ -516,7 +572,7 @@ fn multisig_2_of_3_as_multi_works() { None, OpaqueCall::from_encoded(data.clone()), false, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(6), 0); @@ -555,7 +611,7 @@ fn multisig_2_of_3_as_multi_with_many_calls_works() { None, OpaqueCall::from_encoded(data1.clone()), false, - 0 + Weight::zero() )); assert_ok!(Multisig::as_multi( Origin::signed(2), @@ -564,7 +620,7 @@ fn multisig_2_of_3_as_multi_with_many_calls_works() { None, OpaqueCall::from_encoded(data2.clone()), false, - 0 + Weight::zero() )); assert_ok!(Multisig::as_multi( Origin::signed(3), @@ -609,7 +665,7 @@ fn multisig_2_of_3_cannot_reissue_same_call() { None, OpaqueCall::from_encoded(data.clone()), false, - 0 + Weight::zero() )); assert_ok!(Multisig::as_multi( Origin::signed(2), @@ -629,7 +685,7 @@ fn multisig_2_of_3_cannot_reissue_same_call() { None, OpaqueCall::from_encoded(data.clone()), false, - 0 + Weight::zero() )); assert_ok!(Multisig::as_multi( Origin::signed(3), @@ -667,7 +723,7 @@ fn minimum_threshold_check_works() { None, OpaqueCall::from_encoded(call.clone()), false, - 0 + Weight::zero() ), Error::::MinimumThreshold, ); @@ -679,7 +735,7 @@ fn minimum_threshold_check_works() { None, OpaqueCall::from_encoded(call.clone()), false, - 0 + Weight::zero() ), Error::::MinimumThreshold, ); @@ -698,7 +754,7 @@ fn too_many_signatories_fails() { None, OpaqueCall::from_encoded(call), false, - 0 + Weight::zero() ), Error::::TooManySignatories, ); @@ -710,9 +766,23 @@ fn duplicate_approvals_are_ignored() { new_test_ext().execute_with(|| { let call = call_transfer(6, 15).encode(); let hash = blake2_256(&call); - assert_ok!(Multisig::approve_as_multi(Origin::signed(1), 2, vec![2, 3], None, hash, 0)); + assert_ok!(Multisig::approve_as_multi( + Origin::signed(1), + 2, + vec![2, 3], + None, + hash, + Weight::zero() + )); assert_noop!( - Multisig::approve_as_multi(Origin::signed(1), 2, vec![2, 3], Some(now()), hash, 0), + Multisig::approve_as_multi( + Origin::signed(1), + 2, + vec![2, 3], + Some(now()), + hash, + Weight::zero() + ), Error::::AlreadyApproved, ); assert_ok!(Multisig::approve_as_multi( @@ -721,10 +791,17 @@ fn duplicate_approvals_are_ignored() { vec![1, 3], Some(now()), hash, - 0 + Weight::zero() )); assert_noop!( - Multisig::approve_as_multi(Origin::signed(3), 2, vec![1, 2], Some(now()), hash, 0), + Multisig::approve_as_multi( + Origin::signed(3), + 2, + vec![1, 2], + Some(now()), + hash, + Weight::zero() + ), Error::::AlreadyApproved, ); }); @@ -741,7 +818,14 @@ fn multisig_1_of_3_works() { let call = call_transfer(6, 15).encode(); let hash = blake2_256(&call); assert_noop!( - Multisig::approve_as_multi(Origin::signed(1), 1, vec![2, 3], None, hash, 0), + Multisig::approve_as_multi( + Origin::signed(1), + 1, + vec![2, 3], + None, + hash, + Weight::zero() + ), Error::::MinimumThreshold, ); assert_noop!( @@ -752,7 +836,7 @@ fn multisig_1_of_3_works() { None, OpaqueCall::from_encoded(call), false, - 0 + Weight::zero() ), Error::::MinimumThreshold, ); @@ -791,7 +875,7 @@ fn weight_check_works() { None, OpaqueCall::from_encoded(data.clone()), false, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(6), 0); @@ -803,7 +887,7 @@ fn weight_check_works() { Some(now()), OpaqueCall::from_encoded(data), false, - 0 + Weight::zero() ), Error::::MaxWeightTooLow, ); @@ -825,14 +909,21 @@ fn multisig_handles_no_preimage_after_all_approve() { let call_weight = call.get_dispatch_info().weight; let data = call.encode(); let hash = blake2_256(&data); - assert_ok!(Multisig::approve_as_multi(Origin::signed(1), 3, vec![2, 3], None, hash, 0)); + assert_ok!(Multisig::approve_as_multi( + Origin::signed(1), + 3, + vec![2, 3], + None, + hash, + Weight::zero() + )); assert_ok!(Multisig::approve_as_multi( Origin::signed(2), 3, vec![1, 3], Some(now()), hash, - 0 + Weight::zero() )); assert_ok!(Multisig::approve_as_multi( Origin::signed(3), @@ -840,7 +931,7 @@ fn multisig_handles_no_preimage_after_all_approve() { vec![1, 2], Some(now()), hash, - 0 + Weight::zero() )); assert_eq!(Balances::free_balance(6), 0); diff --git a/frame/multisig/src/weights.rs b/frame/multisig/src/weights.rs index 7946b96546768..0b580ec82b640 100644 --- a/frame/multisig/src/weights.rs +++ b/frame/multisig/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_multisig. @@ -60,199 +60,199 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn as_multi_threshold_1(_z: u32, ) -> Weight { - (17_537_000 as Weight) + Weight::from_ref_time(17_537_000 as RefTimeWeight) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) fn as_multi_create(s: u32, z: u32, ) -> Weight { - (36_535_000 as Weight) + Weight::from_ref_time(36_535_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((99_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(99_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) fn as_multi_create_store(s: u32, z: u32, ) -> Weight { - (39_918_000 as Weight) + Weight::from_ref_time(39_918_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((95_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(95_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) fn as_multi_approve(s: u32, z: u32, ) -> Weight { - (25_524_000 as Weight) + Weight::from_ref_time(25_524_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((94_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(94_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:1) fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { - (39_923_000 as Weight) + Weight::from_ref_time(39_923_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((91_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(91_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:1) // Storage: System Account (r:1 w:1) fn as_multi_complete(s: u32, z: u32, ) -> Weight { - (45_877_000 as Weight) + Weight::from_ref_time(45_877_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((146_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(146_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) fn approve_as_multi_create(s: u32, ) -> Weight { - (34_309_000 as Weight) + Weight::from_ref_time(34_309_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((114_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)) + .saturating_add(Weight::from_ref_time(114_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:0) fn approve_as_multi_approve(s: u32, ) -> Weight { - (22_848_000 as Weight) + Weight::from_ref_time(22_848_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((114_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(Weight::from_ref_time(114_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:1) // Storage: System Account (r:1 w:1) fn approve_as_multi_complete(s: u32, ) -> Weight { - (63_239_000 as Weight) + Weight::from_ref_time(63_239_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((161_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(161_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:1) fn cancel_as_multi(s: u32, ) -> Weight { - (51_254_000 as Weight) + Weight::from_ref_time(51_254_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((118_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)) + .saturating_add(Weight::from_ref_time(118_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } } // For backwards compatibility and tests impl WeightInfo for () { fn as_multi_threshold_1(_z: u32, ) -> Weight { - (17_537_000 as Weight) + Weight::from_ref_time(17_537_000 as RefTimeWeight) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) fn as_multi_create(s: u32, z: u32, ) -> Weight { - (36_535_000 as Weight) + Weight::from_ref_time(36_535_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((99_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(99_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) fn as_multi_create_store(s: u32, z: u32, ) -> Weight { - (39_918_000 as Weight) + Weight::from_ref_time(39_918_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((95_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(95_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) fn as_multi_approve(s: u32, z: u32, ) -> Weight { - (25_524_000 as Weight) + Weight::from_ref_time(25_524_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((94_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(94_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:1) fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { - (39_923_000 as Weight) + Weight::from_ref_time(39_923_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((91_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(91_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:1) // Storage: System Account (r:1 w:1) fn as_multi_complete(s: u32, z: u32, ) -> Weight { - (45_877_000 as Weight) + Weight::from_ref_time(45_877_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((146_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(Weight::from_ref_time(146_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) fn approve_as_multi_create(s: u32, ) -> Weight { - (34_309_000 as Weight) + Weight::from_ref_time(34_309_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((114_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(114_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:0) fn approve_as_multi_approve(s: u32, ) -> Weight { - (22_848_000 as Weight) + Weight::from_ref_time(22_848_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((114_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(114_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:1) // Storage: System Account (r:1 w:1) fn approve_as_multi_complete(s: u32, ) -> Weight { - (63_239_000 as Weight) + Weight::from_ref_time(63_239_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((161_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(161_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Calls (r:1 w:1) fn cancel_as_multi(s: u32, ) -> Weight { - (51_254_000 as Weight) + Weight::from_ref_time(51_254_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((118_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(118_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } } diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 8eb6936ec0450..cf5af649b7843 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -273,7 +273,7 @@ mod tests { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; diff --git a/frame/node-authorization/src/weights.rs b/frame/node-authorization/src/weights.rs index cf182f94273ce..f5a816ddaecee 100644 --- a/frame/node-authorization/src/weights.rs +++ b/frame/node-authorization/src/weights.rs @@ -21,7 +21,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; pub trait WeightInfo { @@ -37,13 +37,13 @@ pub trait WeightInfo { } impl WeightInfo for () { - fn add_well_known_node() -> Weight { 50_000_000 } - fn remove_well_known_node() -> Weight { 50_000_000 } - fn swap_well_known_node() -> Weight { 50_000_000 } - fn reset_well_known_nodes() -> Weight { 50_000_000 } - fn claim_node() -> Weight { 50_000_000 } - fn remove_claim() -> Weight { 50_000_000 } - fn transfer_node() -> Weight { 50_000_000 } - fn add_connections() -> Weight { 50_000_000 } - fn remove_connections() -> Weight { 50_000_000 } + fn add_well_known_node() -> Weight { Weight::from_ref_time(50_000_000) } + fn remove_well_known_node() -> Weight { Weight::from_ref_time(50_000_000) } + fn swap_well_known_node() -> Weight { Weight::from_ref_time(50_000_000) } + fn reset_well_known_nodes() -> Weight { Weight::from_ref_time(50_000_000) } + fn claim_node() -> Weight { Weight::from_ref_time(50_000_000) } + fn remove_claim() -> Weight { Weight::from_ref_time(50_000_000) } + fn transfer_node() -> Weight { Weight::from_ref_time(50_000_000) } + fn add_connections() -> Weight { Weight::from_ref_time(50_000_000) } + fn remove_connections() -> Weight { Weight::from_ref_time(50_000_000) } } diff --git a/frame/nomination-pools/src/migration.rs b/frame/nomination-pools/src/migration.rs index 243e5489b5445..412c954a2bbf3 100644 --- a/frame/nomination-pools/src/migration.rs +++ b/frame/nomination-pools/src/migration.rs @@ -320,6 +320,7 @@ pub mod v2 { current ); current.put::>(); + T::DbWeight::get().reads_writes(members_translated + 1, reward_pools_translated + 1) } } diff --git a/frame/nomination-pools/src/weights.rs b/frame/nomination-pools/src/weights.rs index a9003ffd3fb4c..1f0d2ce8cddc4 100644 --- a/frame/nomination-pools/src/weights.rs +++ b/frame/nomination-pools/src/weights.rs @@ -41,7 +41,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_nomination_pools. @@ -80,9 +80,9 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList ListNodes (r:3 w:3) // Storage: BagsList ListBags (r:2 w:2) fn join() -> Weight { - (123_947_000 as Weight) - .saturating_add(T::DbWeight::get().reads(17 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + Weight::from_ref_time(123_947_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(17 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(12 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -94,9 +94,9 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList ListNodes (r:3 w:3) // Storage: BagsList ListBags (r:2 w:2) fn bond_extra_transfer() -> Weight { - (118_236_000 as Weight) - .saturating_add(T::DbWeight::get().reads(14 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + Weight::from_ref_time(118_236_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(14 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(12 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -108,18 +108,18 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList ListNodes (r:3 w:3) // Storage: BagsList ListBags (r:2 w:2) fn bond_extra_reward() -> Weight { - (132_475_000 as Weight) - .saturating_add(T::DbWeight::get().reads(14 as Weight)) - .saturating_add(T::DbWeight::get().writes(13 as Weight)) + Weight::from_ref_time(132_475_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(14 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(13 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) // Storage: NominationPools RewardPools (r:1 w:1) // Storage: System Account (r:1 w:1) fn claim_payout() -> Weight { - (50_299_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(50_299_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -136,9 +136,9 @@ impl WeightInfo for SubstrateWeight { // Storage: NominationPools SubPoolsStorage (r:1 w:1) // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) fn unbond() -> Weight { - (121_254_000 as Weight) - .saturating_add(T::DbWeight::get().reads(18 as Weight)) - .saturating_add(T::DbWeight::get().writes(13 as Weight)) + Weight::from_ref_time(121_254_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(18 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(13 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -146,11 +146,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { - (41_928_000 as Weight) + Weight::from_ref_time(41_928_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((52_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(52_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -162,11 +162,11 @@ impl WeightInfo for SubstrateWeight { // Storage: NominationPools CounterForPoolMembers (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - (81_611_000 as Weight) + Weight::from_ref_time(81_611_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((56_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + .saturating_add(Weight::from_ref_time(56_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(8 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(7 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -189,9 +189,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Payee (r:0 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(_s: u32, ) -> Weight { - (139_849_000 as Weight) - .saturating_add(T::DbWeight::get().reads(19 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + Weight::from_ref_time(139_849_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(19 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(16 as RefTimeWeight)) } // Storage: Staking MinNominatorBond (r:1 w:0) // Storage: NominationPools MinCreateBond (r:1 w:0) @@ -216,9 +216,9 @@ impl WeightInfo for SubstrateWeight { // Storage: NominationPools BondedPools (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn create() -> Weight { - (126_246_000 as Weight) - .saturating_add(T::DbWeight::get().reads(22 as Weight)) - .saturating_add(T::DbWeight::get().writes(15 as Weight)) + Weight::from_ref_time(126_246_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(22 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(15 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -234,30 +234,30 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking CounterForNominators (r:1 w:1) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - (48_829_000 as Weight) + Weight::from_ref_time(48_829_000 as RefTimeWeight) // Standard Error: 10_000 - .saturating_add((2_204_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + .saturating_add(Weight::from_ref_time(2_204_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(12 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) fn set_state() -> Weight { - (26_761_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(26_761_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: NominationPools Metadata (r:1 w:1) // Storage: NominationPools CounterForMetadata (r:1 w:1) /// The range of component `n` is `[1, 256]`. fn set_metadata(n: u32, ) -> Weight { - (14_519_000 as Weight) + Weight::from_ref_time(14_519_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: NominationPools MinJoinBond (r:0 w:1) // Storage: NominationPools MaxPoolMembers (r:0 w:1) @@ -265,14 +265,14 @@ impl WeightInfo for SubstrateWeight { // Storage: NominationPools MinCreateBond (r:0 w:1) // Storage: NominationPools MaxPools (r:0 w:1) fn set_configs() -> Weight { - (6_173_000 as Weight) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(6_173_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:1) fn update_roles() -> Weight { - (22_261_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_261_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -283,9 +283,9 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList ListBags (r:1 w:1) // Storage: BagsList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - (47_959_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(47_959_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(8 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } } @@ -305,9 +305,9 @@ impl WeightInfo for () { // Storage: BagsList ListNodes (r:3 w:3) // Storage: BagsList ListBags (r:2 w:2) fn join() -> Weight { - (123_947_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(17 as Weight)) - .saturating_add(RocksDbWeight::get().writes(12 as Weight)) + Weight::from_ref_time(123_947_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(17 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(12 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -319,9 +319,9 @@ impl WeightInfo for () { // Storage: BagsList ListNodes (r:3 w:3) // Storage: BagsList ListBags (r:2 w:2) fn bond_extra_transfer() -> Weight { - (118_236_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(14 as Weight)) - .saturating_add(RocksDbWeight::get().writes(12 as Weight)) + Weight::from_ref_time(118_236_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(14 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(12 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -333,18 +333,18 @@ impl WeightInfo for () { // Storage: BagsList ListNodes (r:3 w:3) // Storage: BagsList ListBags (r:2 w:2) fn bond_extra_reward() -> Weight { - (132_475_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(14 as Weight)) - .saturating_add(RocksDbWeight::get().writes(13 as Weight)) + Weight::from_ref_time(132_475_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(14 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(13 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) // Storage: NominationPools RewardPools (r:1 w:1) // Storage: System Account (r:1 w:1) fn claim_payout() -> Weight { - (50_299_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(50_299_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -361,9 +361,9 @@ impl WeightInfo for () { // Storage: NominationPools SubPoolsStorage (r:1 w:1) // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) fn unbond() -> Weight { - (121_254_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(18 as Weight)) - .saturating_add(RocksDbWeight::get().writes(13 as Weight)) + Weight::from_ref_time(121_254_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(18 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(13 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -371,11 +371,11 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { - (41_928_000 as Weight) + Weight::from_ref_time(41_928_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((52_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(52_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -387,11 +387,11 @@ impl WeightInfo for () { // Storage: NominationPools CounterForPoolMembers (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - (81_611_000 as Weight) + Weight::from_ref_time(81_611_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((56_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) + .saturating_add(Weight::from_ref_time(56_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(8 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(7 as RefTimeWeight)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -414,9 +414,9 @@ impl WeightInfo for () { // Storage: Staking Payee (r:0 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(_s: u32, ) -> Weight { - (139_849_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(19 as Weight)) - .saturating_add(RocksDbWeight::get().writes(16 as Weight)) + Weight::from_ref_time(139_849_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(19 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(16 as RefTimeWeight)) } // Storage: Staking MinNominatorBond (r:1 w:0) // Storage: NominationPools MinCreateBond (r:1 w:0) @@ -441,9 +441,9 @@ impl WeightInfo for () { // Storage: NominationPools BondedPools (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn create() -> Weight { - (126_246_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(22 as Weight)) - .saturating_add(RocksDbWeight::get().writes(15 as Weight)) + Weight::from_ref_time(126_246_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(22 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(15 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -459,30 +459,30 @@ impl WeightInfo for () { // Storage: Staking CounterForNominators (r:1 w:1) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - (48_829_000 as Weight) + Weight::from_ref_time(48_829_000 as RefTimeWeight) // Standard Error: 10_000 - .saturating_add((2_204_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(12 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + .saturating_add(Weight::from_ref_time(2_204_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(12 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) fn set_state() -> Weight { - (26_761_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(26_761_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: NominationPools Metadata (r:1 w:1) // Storage: NominationPools CounterForMetadata (r:1 w:1) /// The range of component `n` is `[1, 256]`. fn set_metadata(n: u32, ) -> Weight { - (14_519_000 as Weight) + Weight::from_ref_time(14_519_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: NominationPools MinJoinBond (r:0 w:1) // Storage: NominationPools MaxPoolMembers (r:0 w:1) @@ -490,14 +490,14 @@ impl WeightInfo for () { // Storage: NominationPools MinCreateBond (r:0 w:1) // Storage: NominationPools MaxPools (r:0 w:1) fn set_configs() -> Weight { - (6_173_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(6_173_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:1) fn update_roles() -> Weight { - (22_261_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_261_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -508,8 +508,8 @@ impl WeightInfo for () { // Storage: BagsList ListBags (r:1 w:1) // Storage: BagsList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - (47_959_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(47_959_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(8 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } } diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index d51a81b1212c0..312bc4e18f413 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -40,7 +40,9 @@ type Balance = u64; parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(2 * WEIGHT_PER_SECOND); + frame_system::limits::BlockWeights::simple_max( + 2 * WEIGHT_PER_SECOND + ); } impl frame_system::Config for Test { diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 109806049a0fd..1a1f05cb9c088 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -50,7 +50,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(2_000_000_000_000); + frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(2_000_000_000_000)); } impl frame_system::Config for Test { type BaseCallFilter = Everything; diff --git a/frame/preimage/src/weights.rs b/frame/preimage/src/weights.rs index de3eb6607fe8c..183b704ec705d 100644 --- a/frame/preimage/src/weights.rs +++ b/frame/preimage/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_preimage. @@ -64,87 +64,87 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn note_preimage(s: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_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)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:0) fn note_requested_preimage(s: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_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)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // 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) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_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)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_preimage() -> Weight { - (44_380_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(44_380_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_no_deposit_preimage() -> Weight { - (30_280_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(30_280_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_preimage() -> Weight { - (42_809_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(42_809_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_no_deposit_preimage() -> Weight { - (28_964_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(28_964_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_unnoted_preimage() -> Weight { - (17_555_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(17_555_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_requested_preimage() -> Weight { - (7_745_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(7_745_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_preimage() -> Weight { - (29_758_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(29_758_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_unnoted_preimage() -> Weight { - (18_360_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(18_360_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) fn unrequest_multi_referenced_preimage() -> Weight { - (7_439_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(7_439_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } } @@ -153,86 +153,86 @@ impl WeightInfo for () { // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn note_preimage(s: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:0) fn note_requested_preimage(s: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // 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) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_preimage() -> Weight { - (44_380_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(44_380_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_no_deposit_preimage() -> Weight { - (30_280_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(30_280_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_preimage() -> Weight { - (42_809_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(42_809_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_no_deposit_preimage() -> Weight { - (28_964_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(28_964_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_unnoted_preimage() -> Weight { - (17_555_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(17_555_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_requested_preimage() -> Weight { - (7_745_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(7_745_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_preimage() -> Weight { - (29_758_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(29_758_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_unnoted_preimage() -> Weight { - (18_360_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(18_360_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Preimage StatusFor (r:1 w:1) fn unrequest_multi_referenced_preimage() -> Weight { - (7_439_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(7_439_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } } diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 761d530954100..2d8dfc238bcd0 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -199,9 +199,9 @@ pub mod pallet { #[pallet::weight({ let di = call.get_dispatch_info(); (T::WeightInfo::proxy(T::MaxProxies::get()) - .saturating_add(di.weight) // AccountData for inner call origin accountdata. - .saturating_add(T::DbWeight::get().reads_writes(1, 1)), + .saturating_add(T::DbWeight::get().reads_writes(1, 1)) + .saturating_add(di.weight), di.class) })] pub fn proxy( @@ -529,9 +529,9 @@ pub mod pallet { #[pallet::weight({ let di = call.get_dispatch_info(); (T::WeightInfo::proxy_announced(T::MaxPending::get(), T::MaxProxies::get()) - .saturating_add(di.weight) // AccountData for inner call origin accountdata. - .saturating_add(T::DbWeight::get().reads_writes(1, 1)), + .saturating_add(T::DbWeight::get().reads_writes(1, 1)) + .saturating_add(di.weight), di.class) })] pub fn proxy_announced( diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 72acee1e0347e..b8d5a55705efa 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -54,7 +54,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type BaseCallFilter = BaseFilter; diff --git a/frame/proxy/src/weights.rs b/frame/proxy/src/weights.rs index 19beaf4d1401b..119df271e0d55 100644 --- a/frame/proxy/src/weights.rs +++ b/frame/proxy/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_proxy. @@ -61,97 +61,97 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Proxy Proxies (r:1 w:0) fn proxy(p: u32, ) -> Weight { - (17_768_000 as Weight) + Weight::from_ref_time(17_768_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((76_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(Weight::from_ref_time(76_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) fn proxy_announced(a: u32, p: u32, ) -> Weight { - (35_682_000 as Weight) + Weight::from_ref_time(35_682_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((158_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(158_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((73_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(73_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) fn remove_announcement(a: u32, p: u32, ) -> Weight { - (25_586_000 as Weight) + Weight::from_ref_time(25_586_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((175_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(175_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((18_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(18_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) fn reject_announcement(a: u32, p: u32, ) -> Weight { - (25_794_000 as Weight) + Weight::from_ref_time(25_794_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((173_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(173_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((13_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(13_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) fn announce(a: u32, p: u32, ) -> Weight { - (33_002_000 as Weight) + Weight::from_ref_time(33_002_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((163_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(163_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((79_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(79_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:1) fn add_proxy(p: u32, ) -> Weight { - (28_166_000 as Weight) + Weight::from_ref_time(28_166_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((105_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(105_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:1) fn remove_proxy(p: u32, ) -> Weight { - (28_128_000 as Weight) + Weight::from_ref_time(28_128_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((118_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(118_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:1) fn remove_proxies(p: u32, ) -> Weight { - (24_066_000 as Weight) + Weight::from_ref_time(24_066_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((81_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(81_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: Proxy Proxies (r:1 w:1) fn anonymous(p: u32, ) -> Weight { - (31_077_000 as Weight) + Weight::from_ref_time(31_077_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((37_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(37_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:1) fn kill_anonymous(p: u32, ) -> Weight { - (24_657_000 as Weight) + Weight::from_ref_time(24_657_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((87_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(87_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } } @@ -159,96 +159,96 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: Proxy Proxies (r:1 w:0) fn proxy(p: u32, ) -> Weight { - (17_768_000 as Weight) + Weight::from_ref_time(17_768_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((76_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(Weight::from_ref_time(76_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) fn proxy_announced(a: u32, p: u32, ) -> Weight { - (35_682_000 as Weight) + Weight::from_ref_time(35_682_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((158_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(158_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((73_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(73_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) fn remove_announcement(a: u32, p: u32, ) -> Weight { - (25_586_000 as Weight) + Weight::from_ref_time(25_586_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((175_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(175_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((18_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(18_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) fn reject_announcement(a: u32, p: u32, ) -> Weight { - (25_794_000 as Weight) + Weight::from_ref_time(25_794_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((173_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(173_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 1_000 - .saturating_add((13_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(13_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) fn announce(a: u32, p: u32, ) -> Weight { - (33_002_000 as Weight) + Weight::from_ref_time(33_002_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((163_000 as Weight).saturating_mul(a as Weight)) + .saturating_add(Weight::from_ref_time(163_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((79_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(79_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:1) fn add_proxy(p: u32, ) -> Weight { - (28_166_000 as Weight) + Weight::from_ref_time(28_166_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((105_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(105_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:1) fn remove_proxy(p: u32, ) -> Weight { - (28_128_000 as Weight) + Weight::from_ref_time(28_128_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((118_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(118_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:1) fn remove_proxies(p: u32, ) -> Weight { - (24_066_000 as Weight) + Weight::from_ref_time(24_066_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((81_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(81_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: Proxy Proxies (r:1 w:1) fn anonymous(p: u32, ) -> Weight { - (31_077_000 as Weight) + Weight::from_ref_time(31_077_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((37_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(37_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Proxy Proxies (r:1 w:1) fn kill_anonymous(p: u32, ) -> Weight { - (24_657_000 as Weight) + Weight::from_ref_time(24_657_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((87_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(87_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } } diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index f709578f6941a..467cae9728fae 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -69,7 +69,7 @@ use safe_mix::TripletMix; use codec::Encode; -use frame_support::traits::Randomness; +use frame_support::{pallet_prelude::Weight, traits::Randomness}; use sp_runtime::traits::{Hash, Saturating}; const RANDOM_MATERIAL_LEN: u32 = 81; @@ -187,7 +187,7 @@ mod tests { parameter_types! { pub BlockWeights: limits::BlockWeights = limits::BlockWeights - ::simple_max(1024); + ::simple_max(Weight::from_ref_time(1024)); pub BlockLength: limits::BlockLength = limits::BlockLength ::max(2 * 1024); } diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index 530388d83f3c4..b4173b30b0c2e 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -22,6 +22,7 @@ use std::collections::BTreeMap; use frame_support::{ assert_noop, assert_ok, error::BadOrigin, + pallet_prelude::Weight, parameter_types, traits::{ConstU16, ConstU32, ConstU64, EitherOf, Everything, MapSuccess, Polling}, }; @@ -50,7 +51,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1_000_000); + frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(1_000_000)); } impl frame_system::Config for Test { type BaseCallFilter = Everything; diff --git a/frame/ranked-collective/src/weights.rs b/frame/ranked-collective/src/weights.rs index 3048dd804a5e2..a0309daea2263 100644 --- a/frame/ranked-collective/src/weights.rs +++ b/frame/ranked-collective/src/weights.rs @@ -40,7 +40,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_ranked_collective. @@ -61,62 +61,62 @@ impl WeightInfo for SubstrateWeight { // Storage: RankedCollective IndexToId (r:0 w:1) // Storage: RankedCollective IdToIndex (r:0 w:1) fn add_member() -> Weight { - (11_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(11_000_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: RankedCollective Members (r:1 w:1) // Storage: RankedCollective MemberCount (r:1 w:1) // Storage: RankedCollective IdToIndex (r:1 w:1) // Storage: RankedCollective IndexToId (r:1 w:1) fn remove_member(r: u32, ) -> Weight { - (16_855_000 as Weight) + Weight::from_ref_time(16_855_000 as RefTimeWeight) // Standard Error: 27_000 - .saturating_add((8_107_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(8_107_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: RankedCollective Members (r:1 w:1) // Storage: RankedCollective MemberCount (r:1 w:1) // Storage: RankedCollective IndexToId (r:0 w:1) // Storage: RankedCollective IdToIndex (r:0 w:1) fn promote_member(r: u32, ) -> Weight { - (11_936_000 as Weight) + Weight::from_ref_time(11_936_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((9_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(9_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: RankedCollective Members (r:1 w:1) // Storage: RankedCollective MemberCount (r:1 w:1) // Storage: RankedCollective IdToIndex (r:1 w:1) // Storage: RankedCollective IndexToId (r:1 w:1) fn demote_member(r: u32, ) -> Weight { - (17_582_000 as Weight) + Weight::from_ref_time(17_582_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((142_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(142_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: RankedCollective Members (r:1 w:0) // Storage: RankedPolls ReferendumInfoFor (r:1 w:1) // Storage: RankedCollective Voting (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn vote() -> Weight { - (22_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(22_000_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: RankedPolls ReferendumInfoFor (r:1 w:0) // Storage: RankedCollective Voting (r:0 w:1) fn cleanup_poll(n: u32, ) -> Weight { - (6_188_000 as Weight) + Weight::from_ref_time(6_188_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((867_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(867_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } } @@ -127,61 +127,61 @@ impl WeightInfo for () { // Storage: RankedCollective IndexToId (r:0 w:1) // Storage: RankedCollective IdToIndex (r:0 w:1) fn add_member() -> Weight { - (11_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(11_000_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: RankedCollective Members (r:1 w:1) // Storage: RankedCollective MemberCount (r:1 w:1) // Storage: RankedCollective IdToIndex (r:1 w:1) // Storage: RankedCollective IndexToId (r:1 w:1) fn remove_member(r: u32, ) -> Weight { - (16_855_000 as Weight) + Weight::from_ref_time(16_855_000 as RefTimeWeight) // Standard Error: 27_000 - .saturating_add((8_107_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(r as Weight))) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(r as Weight))) + .saturating_add(Weight::from_ref_time(8_107_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((3 as RefTimeWeight).saturating_mul(r as RefTimeWeight))) } // Storage: RankedCollective Members (r:1 w:1) // Storage: RankedCollective MemberCount (r:1 w:1) // Storage: RankedCollective IndexToId (r:0 w:1) // Storage: RankedCollective IdToIndex (r:0 w:1) fn promote_member(r: u32, ) -> Weight { - (11_936_000 as Weight) + Weight::from_ref_time(11_936_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((9_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(9_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: RankedCollective Members (r:1 w:1) // Storage: RankedCollective MemberCount (r:1 w:1) // Storage: RankedCollective IdToIndex (r:1 w:1) // Storage: RankedCollective IndexToId (r:1 w:1) fn demote_member(r: u32, ) -> Weight { - (17_582_000 as Weight) + Weight::from_ref_time(17_582_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((142_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(142_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: RankedCollective Members (r:1 w:0) // Storage: RankedPolls ReferendumInfoFor (r:1 w:1) // Storage: RankedCollective Voting (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn vote() -> Weight { - (22_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(22_000_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: RankedPolls ReferendumInfoFor (r:1 w:0) // Storage: RankedCollective Voting (r:0 w:1) fn cleanup_poll(n: u32, ) -> Weight { - (6_188_000 as Weight) + Weight::from_ref_time(6_188_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((867_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(867_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } } diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 44fc4d72a4a5f..5dc49fff09b32 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -47,7 +47,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { diff --git a/frame/recovery/src/weights.rs b/frame/recovery/src/weights.rs index 0887180a533fc..8b82454d5849d 100644 --- a/frame/recovery/src/weights.rs +++ b/frame/recovery/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_recovery. @@ -60,71 +60,71 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Recovery Proxy (r:1 w:0) fn as_recovered() -> Weight { - (6_579_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(6_579_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) } // Storage: Recovery Proxy (r:0 w:1) fn set_recovered() -> Weight { - (13_402_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(13_402_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery Recoverable (r:1 w:1) fn create_recovery(n: u32, ) -> Weight { - (28_217_000 as Weight) + Weight::from_ref_time(28_217_000 as RefTimeWeight) // Standard Error: 13_000 - .saturating_add((172_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(172_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery Recoverable (r:1 w:0) // Storage: Recovery ActiveRecoveries (r:1 w:1) fn initiate_recovery() -> Weight { - (34_082_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(34_082_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery Recoverable (r:1 w:0) // Storage: Recovery ActiveRecoveries (r:1 w:1) fn vouch_recovery(n: u32, ) -> Weight { - (22_038_000 as Weight) + Weight::from_ref_time(22_038_000 as RefTimeWeight) // Standard Error: 19_000 - .saturating_add((307_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(307_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery Recoverable (r:1 w:0) // Storage: Recovery ActiveRecoveries (r:1 w:0) // Storage: Recovery Proxy (r:1 w:1) fn claim_recovery(n: u32, ) -> Weight { - (28_621_000 as Weight) + Weight::from_ref_time(28_621_000 as RefTimeWeight) // Standard Error: 13_000 - .saturating_add((353_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(353_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery ActiveRecoveries (r:1 w:1) // Storage: System Account (r:1 w:1) fn close_recovery(n: u32, ) -> Weight { - (33_287_000 as Weight) + Weight::from_ref_time(33_287_000 as RefTimeWeight) // Standard Error: 19_000 - .saturating_add((264_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(264_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Recovery ActiveRecoveries (r:1 w:0) // Storage: Recovery Recoverable (r:1 w:1) fn remove_recovery(n: u32, ) -> Weight { - (31_964_000 as Weight) + Weight::from_ref_time(31_964_000 as RefTimeWeight) // Standard Error: 13_000 - .saturating_add((222_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(222_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery Proxy (r:1 w:1) fn cancel_recovered() -> Weight { - (12_702_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(12_702_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } } @@ -132,70 +132,70 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: Recovery Proxy (r:1 w:0) fn as_recovered() -> Weight { - (6_579_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(6_579_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) } // Storage: Recovery Proxy (r:0 w:1) fn set_recovered() -> Weight { - (13_402_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(13_402_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery Recoverable (r:1 w:1) fn create_recovery(n: u32, ) -> Weight { - (28_217_000 as Weight) + Weight::from_ref_time(28_217_000 as RefTimeWeight) // Standard Error: 13_000 - .saturating_add((172_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(172_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery Recoverable (r:1 w:0) // Storage: Recovery ActiveRecoveries (r:1 w:1) fn initiate_recovery() -> Weight { - (34_082_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(34_082_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery Recoverable (r:1 w:0) // Storage: Recovery ActiveRecoveries (r:1 w:1) fn vouch_recovery(n: u32, ) -> Weight { - (22_038_000 as Weight) + Weight::from_ref_time(22_038_000 as RefTimeWeight) // Standard Error: 19_000 - .saturating_add((307_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(307_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery Recoverable (r:1 w:0) // Storage: Recovery ActiveRecoveries (r:1 w:0) // Storage: Recovery Proxy (r:1 w:1) fn claim_recovery(n: u32, ) -> Weight { - (28_621_000 as Weight) + Weight::from_ref_time(28_621_000 as RefTimeWeight) // Standard Error: 13_000 - .saturating_add((353_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(353_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery ActiveRecoveries (r:1 w:1) // Storage: System Account (r:1 w:1) fn close_recovery(n: u32, ) -> Weight { - (33_287_000 as Weight) + Weight::from_ref_time(33_287_000 as RefTimeWeight) // Standard Error: 19_000 - .saturating_add((264_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(264_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Recovery ActiveRecoveries (r:1 w:0) // Storage: Recovery Recoverable (r:1 w:1) fn remove_recovery(n: u32, ) -> Weight { - (31_964_000 as Weight) + Weight::from_ref_time(31_964_000 as RefTimeWeight) // Standard Error: 13_000 - .saturating_add((222_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(222_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Recovery Proxy (r:1 w:1) fn cancel_recovered() -> Weight { - (12_702_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(12_702_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } } diff --git a/frame/referenda/src/branch.rs b/frame/referenda/src/branch.rs index f381f5fe5b709..172b5af999df5 100644 --- a/frame/referenda/src/branch.rs +++ b/frame/referenda/src/branch.rs @@ -19,6 +19,7 @@ use super::Config; use crate::weights::WeightInfo; +use frame_support::weights::Weight; /// Branches within the `begin_deciding` function. pub enum BeginDecidingBranch { @@ -82,7 +83,8 @@ impl ServiceBranch { /// Return the maximum possible weight of the `nudge` function. pub fn max_weight_of_nudge, I: 'static>() -> frame_support::weights::Weight { - 0.max(T::WeightInfo::nudge_referendum_no_deposit()) + Weight::new() + .max(T::WeightInfo::nudge_referendum_no_deposit()) .max(T::WeightInfo::nudge_referendum_preparing()) .max(T::WeightInfo::nudge_referendum_queued()) .max(T::WeightInfo::nudge_referendum_not_queued()) @@ -105,7 +107,7 @@ impl ServiceBranch { self, ) -> Option { use ServiceBranch::*; - Some(match self { + let ref_time_weight = match self { Preparing => T::WeightInfo::place_decision_deposit_preparing(), Queued => T::WeightInfo::place_decision_deposit_queued(), NotQueued => T::WeightInfo::place_decision_deposit_not_queued(), @@ -122,12 +124,15 @@ impl ServiceBranch { TimedOut | Fail | NoDeposit => return None, - }) + }; + + Some(ref_time_weight) } /// Return the maximum possible weight of the `place_decision_deposit` function. pub fn max_weight_of_deposit, I: 'static>() -> frame_support::weights::Weight { - 0.max(T::WeightInfo::place_decision_deposit_preparing()) + Weight::new() + .max(T::WeightInfo::place_decision_deposit_preparing()) .max(T::WeightInfo::place_decision_deposit_queued()) .max(T::WeightInfo::place_decision_deposit_not_queued()) .max(T::WeightInfo::place_decision_deposit_passing()) @@ -167,7 +172,8 @@ impl OneFewerDecidingBranch { /// Return the maximum possible weight of the `one_fewer_deciding` function. pub fn max_weight, I: 'static>() -> frame_support::weights::Weight { - 0.max(T::WeightInfo::one_fewer_deciding_queue_empty()) + Weight::new() + .max(T::WeightInfo::one_fewer_deciding_queue_empty()) .max(T::WeightInfo::one_fewer_deciding_passing()) .max(T::WeightInfo::one_fewer_deciding_failing()) } diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index dbe22cd562349..698bea8cc9f67 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -26,6 +26,7 @@ use frame_support::{ ConstU32, ConstU64, Contains, EqualPrivilegeOnly, OnInitialize, OriginTrait, Polling, PreimageRecipient, SortedMembers, }, + weights::Weight, }; use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; @@ -61,8 +62,9 @@ impl Contains for BaseFilter { } parameter_types! { + pub MaxWeight: Weight = Weight::from_ref_time(2_000_000_000_000); pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1_000_000); + frame_system::limits::BlockWeights::simple_max(MaxWeight::get()); } impl frame_system::Config for Test { type BaseCallFilter = BaseFilter; @@ -104,7 +106,7 @@ impl pallet_scheduler::Config for Test { type Origin = Origin; type PalletsOrigin = OriginCaller; type Call = Call; - type MaximumWeight = ConstU64<2_000_000_000_000>; + type MaximumWeight = MaxWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<100>; type WeightInfo = (); diff --git a/frame/referenda/src/weights.rs b/frame/referenda/src/weights.rs index d48ebb1014d48..84a726d9e4fbe 100644 --- a/frame/referenda/src/weights.rs +++ b/frame/referenda/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_referenda. @@ -80,205 +80,205 @@ impl WeightInfo for SubstrateWeight { // Storage: Scheduler Agenda (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:0 w:1) fn submit() -> Weight { - (34_640_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(34_640_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_preparing() -> Weight { - (44_290_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(44_290_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_queued() -> Weight { - (49_428_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(49_428_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_not_queued() -> Weight { - (50_076_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(50_076_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_passing() -> Weight { - (55_935_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(55_935_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_failing() -> Weight { - (52_921_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(52_921_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn refund_decision_deposit() -> Weight { - (29_160_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(29_160_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn cancel() -> Weight { - (34_972_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(34_972_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn kill() -> Weight { - (60_620_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(60_620_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda TrackQueue (r:1 w:0) // Storage: Referenda DecidingCount (r:1 w:1) fn one_fewer_deciding_queue_empty() -> Weight { - (9_615_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(9_615_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_failing() -> Weight { - (113_077_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(113_077_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_passing() -> Weight { - (114_376_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(114_376_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_insertion() -> Weight { - (43_901_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(43_901_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_slide() -> Weight { - (43_279_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(43_279_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_queued() -> Weight { - (45_564_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(45_564_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_not_queued() -> Weight { - (45_061_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(45_061_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_no_deposit() -> Weight { - (23_757_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(23_757_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_preparing() -> Weight { - (24_781_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(24_781_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn nudge_referendum_timed_out() -> Weight { - (18_344_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_344_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_failing() -> Weight { - (34_752_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(34_752_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_passing() -> Weight { - (37_055_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(37_055_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_confirming() -> Weight { - (31_442_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(31_442_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_end_confirming() -> Weight { - (33_201_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(33_201_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_not_confirming() -> Weight { - (30_047_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(30_047_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_confirming() -> Weight { - (29_195_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(29_195_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) // Storage: Scheduler Lookup (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn nudge_referendum_approved() -> Weight { - (50_119_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(50_119_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_rejected() -> Weight { - (32_203_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_203_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } } @@ -288,204 +288,204 @@ impl WeightInfo for () { // Storage: Scheduler Agenda (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:0 w:1) fn submit() -> Weight { - (34_640_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(34_640_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_preparing() -> Weight { - (44_290_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(44_290_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_queued() -> Weight { - (49_428_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(49_428_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_not_queued() -> Weight { - (50_076_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(50_076_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_passing() -> Weight { - (55_935_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(55_935_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_failing() -> Weight { - (52_921_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(52_921_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn refund_decision_deposit() -> Weight { - (29_160_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(29_160_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn cancel() -> Weight { - (34_972_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(34_972_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn kill() -> Weight { - (60_620_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(60_620_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda TrackQueue (r:1 w:0) // Storage: Referenda DecidingCount (r:1 w:1) fn one_fewer_deciding_queue_empty() -> Weight { - (9_615_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(9_615_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_failing() -> Weight { - (113_077_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(113_077_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_passing() -> Weight { - (114_376_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(114_376_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_insertion() -> Weight { - (43_901_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(43_901_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_slide() -> Weight { - (43_279_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(43_279_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_queued() -> Weight { - (45_564_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(45_564_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_not_queued() -> Weight { - (45_061_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(45_061_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_no_deposit() -> Weight { - (23_757_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(23_757_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_preparing() -> Weight { - (24_781_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(24_781_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn nudge_referendum_timed_out() -> Weight { - (18_344_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_344_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_failing() -> Weight { - (34_752_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(34_752_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_passing() -> Weight { - (37_055_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(37_055_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_confirming() -> Weight { - (31_442_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(31_442_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_end_confirming() -> Weight { - (33_201_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(33_201_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_not_confirming() -> Weight { - (30_047_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(30_047_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_confirming() -> Weight { - (29_195_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(29_195_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) // Storage: Scheduler Lookup (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn nudge_referendum_approved() -> Weight { - (50_119_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(50_119_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_rejected() -> Weight { - (32_203_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_203_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } } diff --git a/frame/remark/src/weights.rs b/frame/remark/src/weights.rs index b8bd4618f8def..a098670ccf100 100644 --- a/frame/remark/src/weights.rs +++ b/frame/remark/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_remark. @@ -52,10 +52,10 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) fn store(l: u32, ) -> Weight { - (13_140_000 as Weight) + Weight::from_ref_time(13_140_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) } } @@ -63,9 +63,9 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) fn store(l: u32, ) -> Weight { - (13_140_000 as Weight) + Weight::from_ref_time(13_140_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) } } diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 008105dc737ea..7bbc628604bc6 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -119,7 +119,7 @@ impl Contains for BaseFilter { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(2_000_000_000_000); + frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(2_000_000_000_000)); } impl system::Config for Test { type BaseCallFilter = BaseFilter; diff --git a/frame/scheduler/src/tests.rs b/frame/scheduler/src/tests.rs index d03e13da4747a..56f9298dd4b0c 100644 --- a/frame/scheduler/src/tests.rs +++ b/frame/scheduler/src/tests.rs @@ -30,7 +30,7 @@ use substrate_test_utils::assert_eq_uvec; #[test] fn basic_scheduling_works() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); assert_ok!(Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.into())); run_to_block(3); @@ -45,7 +45,7 @@ fn basic_scheduling_works() { #[test] fn scheduling_with_preimages_works() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); let hash = ::Hashing::hash_of(&call); let hashed = MaybeHashed::Hash(hash); assert_ok!(Preimage::note_preimage(Origin::signed(0), call.encode())); @@ -65,7 +65,7 @@ fn scheduling_with_preimages_works() { #[test] fn scheduling_with_preimage_postpones_correctly() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); let hash = ::Hashing::hash_of(&call); let hashed = MaybeHashed::Hash(hash); @@ -98,7 +98,7 @@ fn scheduling_with_preimage_postpones_correctly() { fn schedule_after_works() { new_test_ext().execute_with(|| { run_to_block(2); - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); // This will schedule the call 3 blocks after the next block... so block 3 + 3 = 6 assert_ok!(Scheduler::do_schedule(DispatchTime::After(3), None, 127, root(), call.into())); @@ -115,7 +115,7 @@ fn schedule_after_works() { fn schedule_after_zero_works() { new_test_ext().execute_with(|| { run_to_block(2); - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); assert_ok!(Scheduler::do_schedule(DispatchTime::After(0), None, 127, root(), call.into())); // Will trigger on the next block. @@ -135,7 +135,7 @@ fn periodic_scheduling_works() { Some((3, 3)), 127, root(), - Call::Logger(logger::Call::log { i: 42, weight: 1000 }).into() + Call::Logger(logger::Call::log { i: 42, weight: Weight::from_ref_time(1000) }).into() )); run_to_block(3); assert!(logger::log().is_empty()); @@ -157,7 +157,7 @@ fn periodic_scheduling_works() { #[test] fn reschedule_works() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); assert_eq!( Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.into()).unwrap(), @@ -188,7 +188,7 @@ fn reschedule_works() { #[test] fn reschedule_named_works() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); assert_eq!( Scheduler::do_schedule_named( @@ -230,7 +230,7 @@ fn reschedule_named_works() { #[test] fn reschedule_named_perodic_works() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); assert_eq!( Scheduler::do_schedule_named( @@ -292,7 +292,7 @@ fn cancel_named_scheduling_works_with_normal_cancel() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), ) .unwrap(); let i = Scheduler::do_schedule( @@ -300,7 +300,7 @@ fn cancel_named_scheduling_works_with_normal_cancel() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into(), + Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), ) .unwrap(); run_to_block(3); @@ -322,7 +322,7 @@ fn cancel_named_periodic_scheduling_works() { Some((3, 3)), 127, root(), - Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into(), + Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), ) .unwrap(); // same id results in error. @@ -332,7 +332,7 @@ fn cancel_named_periodic_scheduling_works() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), ) .is_err()); // different id is ok. @@ -342,7 +342,7 @@ fn cancel_named_periodic_scheduling_works() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), ) .unwrap(); run_to_block(3); @@ -458,8 +458,11 @@ fn scheduler_respects_priority_ordering_with_soft_deadlines() { None, 126, root(), - Call::Logger(LoggerCall::log { i: 2600, weight: max_weight / 2 - item_weight + 1 }) - .into(), + Call::Logger(LoggerCall::log { + i: 2600, + weight: max_weight / 2 - item_weight + Weight::one() + }) + .into(), )); // 2600 does not fit with 69 or 42, but has higher priority, so will go through @@ -484,7 +487,7 @@ fn on_initialize_weight_is_correct() { None, 255, root(), - Call::Logger(LoggerCall::log { i: 3, weight: call_weight + 1 }).into(), + Call::Logger(LoggerCall::log { i: 3, weight: call_weight + Weight::one() }).into(), )); // Anon Periodic assert_ok!(Scheduler::do_schedule( @@ -492,7 +495,8 @@ fn on_initialize_weight_is_correct() { Some((1000, 3)), 128, root(), - Call::Logger(LoggerCall::log { i: 42, weight: call_weight + 2 }).into(), + Call::Logger(LoggerCall::log { i: 42, weight: call_weight + Weight::from_ref_time(2) }) + .into(), )); // Anon assert_ok!(Scheduler::do_schedule( @@ -500,7 +504,8 @@ fn on_initialize_weight_is_correct() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 69, weight: call_weight + 3 }).into(), + Call::Logger(LoggerCall::log { i: 69, weight: call_weight + Weight::from_ref_time(3) }) + .into(), )); // Named Periodic assert_ok!(Scheduler::do_schedule_named( @@ -509,7 +514,11 @@ fn on_initialize_weight_is_correct() { Some((1000, 3)), 126, root(), - Call::Logger(LoggerCall::log { i: 2600, weight: call_weight + 4 }).into(), + Call::Logger(LoggerCall::log { + i: 2600, + weight: call_weight + Weight::from_ref_time(4) + }) + .into(), )); // Will include the named periodic only @@ -517,7 +526,8 @@ fn on_initialize_weight_is_correct() { assert_eq!( actual_weight, base_weight + - call_weight + 4 + <() as MarginalWeightInfo>::item(true, true, Some(false)) + call_weight + Weight::from_ref_time(4) + + <() as MarginalWeightInfo>::item(true, true, Some(false)) ); assert_eq!(logger::log(), vec![(root(), 2600u32)]); @@ -526,8 +536,10 @@ fn on_initialize_weight_is_correct() { assert_eq!( actual_weight, base_weight + - call_weight + 2 + <() as MarginalWeightInfo>::item(false, false, Some(false)) + - call_weight + 3 + <() as MarginalWeightInfo>::item(true, false, Some(false)) + call_weight + Weight::from_ref_time(2) + + <() as MarginalWeightInfo>::item(false, false, Some(false)) + + call_weight + Weight::from_ref_time(3) + + <() as MarginalWeightInfo>::item(true, false, Some(false)) ); assert_eq!(logger::log(), vec![(root(), 2600u32), (root(), 69u32), (root(), 42u32)]); @@ -536,7 +548,8 @@ fn on_initialize_weight_is_correct() { assert_eq!( actual_weight, base_weight + - call_weight + 1 + <() as MarginalWeightInfo>::item(false, true, Some(false)) + call_weight + Weight::from_ref_time(1) + + <() as MarginalWeightInfo>::item(false, true, Some(false)) ); assert_eq!( logger::log(), @@ -552,8 +565,12 @@ fn on_initialize_weight_is_correct() { #[test] fn root_calls_works() { new_test_ext().execute_with(|| { - let call = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); - let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); + let call = Box::new( + Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + ); + let call2 = Box::new( + Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + ); assert_ok!(Scheduler::schedule_named(Origin::root(), 1u32.encode(), 4, None, 127, call,)); assert_ok!(Scheduler::schedule(Origin::root(), 4, None, 127, call2)); run_to_block(3); @@ -573,9 +590,15 @@ fn fails_to_schedule_task_in_the_past() { new_test_ext().execute_with(|| { run_to_block(3); - let call1 = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); - let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); - let call3 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); + let call1 = Box::new( + Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + ); + let call2 = Box::new( + Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + ); + let call3 = Box::new( + Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + ); assert_err!( Scheduler::schedule_named(Origin::root(), 1u32.encode(), 2, None, 127, call1), @@ -597,8 +620,12 @@ fn fails_to_schedule_task_in_the_past() { #[test] fn should_use_orign() { new_test_ext().execute_with(|| { - let call = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); - let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); + let call = Box::new( + Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + ); + let call2 = Box::new( + Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + ); assert_ok!(Scheduler::schedule_named( system::RawOrigin::Signed(1).into(), 1u32.encode(), @@ -623,8 +650,12 @@ fn should_use_orign() { #[test] fn should_check_orign() { new_test_ext().execute_with(|| { - let call = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); - let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); + let call = Box::new( + Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + ); + let call2 = Box::new( + Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + ); assert_noop!( Scheduler::schedule_named( system::RawOrigin::Signed(2).into(), @@ -646,10 +677,20 @@ fn should_check_orign() { #[test] fn should_check_orign_for_cancel() { new_test_ext().execute_with(|| { - let call = - Box::new(Call::Logger(LoggerCall::log_without_filter { i: 69, weight: 1000 }).into()); - let call2 = - Box::new(Call::Logger(LoggerCall::log_without_filter { i: 42, weight: 1000 }).into()); + let call = Box::new( + Call::Logger(LoggerCall::log_without_filter { + i: 69, + weight: Weight::from_ref_time(1000), + }) + .into(), + ); + let call2 = Box::new( + Call::Logger(LoggerCall::log_without_filter { + i: 42, + weight: Weight::from_ref_time(1000), + }) + .into(), + ); assert_ok!(Scheduler::schedule_named( system::RawOrigin::Signed(1).into(), 1u32.encode(), @@ -693,14 +734,20 @@ fn migration_to_v3_works() { Some(ScheduledV1 { maybe_id: None, priority: i as u8 + 10, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }), + call: Call::Logger(LoggerCall::log { + i: 96, + weight: Weight::from_ref_time(100), + }), maybe_periodic: None, }), None, Some(ScheduledV1 { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }), + call: Call::Logger(LoggerCall::log { + i: 69, + weight: Weight::from_ref_time(1000), + }), maybe_periodic: Some((456u64, 10)), }), ]; @@ -718,7 +765,11 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: None, priority: 10, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: Call::Logger(LoggerCall::log { + i: 96, + weight: Weight::from_ref_time(100) + }) + .into(), maybe_periodic: None, origin: root(), _phantom: PhantomData::::default(), @@ -727,7 +778,11 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: Call::Logger(LoggerCall::log { + i: 69, + weight: Weight::from_ref_time(1000) + }) + .into(), maybe_periodic: Some((456u64, 10)), origin: root(), _phantom: PhantomData::::default(), @@ -740,7 +795,11 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: None, priority: 11, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: Call::Logger(LoggerCall::log { + i: 96, + weight: Weight::from_ref_time(100) + }) + .into(), maybe_periodic: None, origin: root(), _phantom: PhantomData::::default(), @@ -749,7 +808,11 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: Call::Logger(LoggerCall::log { + i: 69, + weight: Weight::from_ref_time(1000) + }) + .into(), maybe_periodic: Some((456u64, 10)), origin: root(), _phantom: PhantomData::::default(), @@ -762,7 +825,11 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: None, priority: 12, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: Call::Logger(LoggerCall::log { + i: 96, + weight: Weight::from_ref_time(100) + }) + .into(), maybe_periodic: None, origin: root(), _phantom: PhantomData::::default(), @@ -771,7 +838,11 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: Call::Logger(LoggerCall::log { + i: 69, + weight: Weight::from_ref_time(1000) + }) + .into(), maybe_periodic: Some((456u64, 10)), origin: root(), _phantom: PhantomData::::default(), @@ -794,7 +865,11 @@ fn test_migrate_origin() { Some(Scheduled { maybe_id: None, priority: i as u8 + 10, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: Call::Logger(LoggerCall::log { + i: 96, + weight: Weight::from_ref_time(100), + }) + .into(), origin: 3u32, maybe_periodic: None, _phantom: Default::default(), @@ -804,7 +879,11 @@ fn test_migrate_origin() { maybe_id: Some(b"test".to_vec()), priority: 123, origin: 2u32, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: Call::Logger(LoggerCall::log { + i: 69, + weight: Weight::from_ref_time(1000), + }) + .into(), maybe_periodic: Some((456u64, 10)), _phantom: Default::default(), }), @@ -833,7 +912,11 @@ fn test_migrate_origin() { Some(ScheduledV2::, u64, OriginCaller, u64> { maybe_id: None, priority: 10, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: Call::Logger(LoggerCall::log { + i: 96, + weight: Weight::from_ref_time(100) + }) + .into(), maybe_periodic: None, origin: system::RawOrigin::Root.into(), _phantom: PhantomData::::default(), @@ -842,7 +925,11 @@ fn test_migrate_origin() { Some(ScheduledV2 { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: Call::Logger(LoggerCall::log { + i: 69, + weight: Weight::from_ref_time(1000) + }) + .into(), maybe_periodic: Some((456u64, 10)), origin: system::RawOrigin::None.into(), _phantom: PhantomData::::default(), @@ -855,7 +942,11 @@ fn test_migrate_origin() { Some(ScheduledV2 { maybe_id: None, priority: 11, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: Call::Logger(LoggerCall::log { + i: 96, + weight: Weight::from_ref_time(100) + }) + .into(), maybe_periodic: None, origin: system::RawOrigin::Root.into(), _phantom: PhantomData::::default(), @@ -864,7 +955,11 @@ fn test_migrate_origin() { Some(ScheduledV2 { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: Call::Logger(LoggerCall::log { + i: 69, + weight: Weight::from_ref_time(1000) + }) + .into(), maybe_periodic: Some((456u64, 10)), origin: system::RawOrigin::None.into(), _phantom: PhantomData::::default(), @@ -877,7 +972,11 @@ fn test_migrate_origin() { Some(ScheduledV2 { maybe_id: None, priority: 12, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: Call::Logger(LoggerCall::log { + i: 96, + weight: Weight::from_ref_time(100) + }) + .into(), maybe_periodic: None, origin: system::RawOrigin::Root.into(), _phantom: PhantomData::::default(), @@ -886,7 +985,11 @@ fn test_migrate_origin() { Some(ScheduledV2 { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: Call::Logger(LoggerCall::log { + i: 69, + weight: Weight::from_ref_time(1000) + }) + .into(), maybe_periodic: Some((456u64, 10)), origin: system::RawOrigin::None.into(), _phantom: PhantomData::::default(), diff --git a/frame/scheduler/src/weights.rs b/frame/scheduler/src/weights.rs index dd7ed8104420d..f201c89eaf278 100644 --- a/frame/scheduler/src/weights.rs +++ b/frame/scheduler/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_scheduler. @@ -68,146 +68,146 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) fn on_initialize_periodic_named_resolved(s: u32, ) -> Weight { - (9_994_000 as Weight) + Weight::from_ref_time(9_994_000 as RefTimeWeight) // Standard Error: 20_000 - .saturating_add((19_843_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(19_843_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((3 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((4 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) fn on_initialize_named_resolved(s: u32, ) -> Weight { - (10_318_000 as Weight) + Weight::from_ref_time(10_318_000 as RefTimeWeight) // Standard Error: 17_000 - .saturating_add((15_451_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(15_451_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((3 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:2 w:2) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn on_initialize_periodic_resolved(s: u32, ) -> Weight { - (11_675_000 as Weight) + Weight::from_ref_time(11_675_000 as RefTimeWeight) // Standard Error: 17_000 - .saturating_add((17_019_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(17_019_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((3 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((3 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn on_initialize_resolved(s: u32, ) -> Weight { - (11_934_000 as Weight) + Weight::from_ref_time(11_934_000 as RefTimeWeight) // Standard Error: 11_000 - .saturating_add((14_134_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(14_134_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:2 w:2) // Storage: Preimage PreimageFor (r:1 w:0) // Storage: Scheduler Lookup (r:0 w:1) fn on_initialize_named_aborted(s: u32, ) -> Weight { - (7_279_000 as Weight) + Weight::from_ref_time(7_279_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((5_388_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(5_388_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:2 w:2) // Storage: Preimage PreimageFor (r:1 w:0) fn on_initialize_aborted(s: u32, ) -> Weight { - (8_619_000 as Weight) + Weight::from_ref_time(8_619_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((2_969_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(2_969_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Scheduler Agenda (r:2 w:2) // Storage: Scheduler Lookup (r:0 w:1) fn on_initialize_periodic_named(s: u32, ) -> Weight { - (16_129_000 as Weight) + Weight::from_ref_time(16_129_000 as RefTimeWeight) // Standard Error: 7_000 - .saturating_add((9_772_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(9_772_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:2 w:2) fn on_initialize_periodic(s: u32, ) -> Weight { - (15_785_000 as Weight) + Weight::from_ref_time(15_785_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((7_208_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(7_208_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) fn on_initialize_named(s: u32, ) -> Weight { - (15_778_000 as Weight) + Weight::from_ref_time(15_778_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((5_597_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((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(5_597_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:1 w:1) fn on_initialize(s: u32, ) -> Weight { - (15_912_000 as Weight) + Weight::from_ref_time(15_912_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((4_530_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(Weight::from_ref_time(4_530_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Scheduler Agenda (r:1 w:1) fn schedule(s: u32, ) -> Weight { - (18_013_000 as Weight) + Weight::from_ref_time(18_013_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((87_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(Weight::from_ref_time(87_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) fn cancel(s: u32, ) -> Weight { - (18_131_000 as Weight) + Weight::from_ref_time(18_131_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((595_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(595_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn schedule_named(s: u32, ) -> Weight { - (21_230_000 as Weight) + Weight::from_ref_time(21_230_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((98_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)) + .saturating_add(Weight::from_ref_time(98_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn cancel_named(s: u32, ) -> Weight { - (20_139_000 as Weight) + Weight::from_ref_time(20_139_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((595_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)) + .saturating_add(Weight::from_ref_time(595_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } } @@ -218,145 +218,145 @@ impl WeightInfo for () { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) fn on_initialize_periodic_named_resolved(s: u32, ) -> Weight { - (9_994_000 as Weight) + Weight::from_ref_time(9_994_000 as RefTimeWeight) // Standard Error: 20_000 - .saturating_add((19_843_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((4 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(19_843_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((3 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((4 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) fn on_initialize_named_resolved(s: u32, ) -> Weight { - (10_318_000 as Weight) + Weight::from_ref_time(10_318_000 as RefTimeWeight) // Standard Error: 17_000 - .saturating_add((15_451_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(15_451_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((3 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:2 w:2) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn on_initialize_periodic_resolved(s: u32, ) -> Weight { - (11_675_000 as Weight) + Weight::from_ref_time(11_675_000 as RefTimeWeight) // Standard Error: 17_000 - .saturating_add((17_019_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(17_019_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((3 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((3 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn on_initialize_resolved(s: u32, ) -> Weight { - (11_934_000 as Weight) + Weight::from_ref_time(11_934_000 as RefTimeWeight) // Standard Error: 11_000 - .saturating_add((14_134_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(14_134_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:2 w:2) // Storage: Preimage PreimageFor (r:1 w:0) // Storage: Scheduler Lookup (r:0 w:1) fn on_initialize_named_aborted(s: u32, ) -> Weight { - (7_279_000 as Weight) + Weight::from_ref_time(7_279_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((5_388_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(5_388_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:2 w:2) // Storage: Preimage PreimageFor (r:1 w:0) fn on_initialize_aborted(s: u32, ) -> Weight { - (8_619_000 as Weight) + Weight::from_ref_time(8_619_000 as RefTimeWeight) // Standard Error: 4_000 - .saturating_add((2_969_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(2_969_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Scheduler Agenda (r:2 w:2) // Storage: Scheduler Lookup (r:0 w:1) fn on_initialize_periodic_named(s: u32, ) -> Weight { - (16_129_000 as Weight) + Weight::from_ref_time(16_129_000 as RefTimeWeight) // Standard Error: 7_000 - .saturating_add((9_772_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(9_772_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((2 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:2 w:2) fn on_initialize_periodic(s: u32, ) -> Weight { - (15_785_000 as Weight) + Weight::from_ref_time(15_785_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((7_208_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(7_208_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) fn on_initialize_named(s: u32, ) -> Weight { - (15_778_000 as Weight) + Weight::from_ref_time(15_778_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((5_597_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(5_597_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Scheduler Agenda (r:1 w:1) fn on_initialize(s: u32, ) -> Weight { - (15_912_000 as Weight) + Weight::from_ref_time(15_912_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((4_530_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(4_530_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Scheduler Agenda (r:1 w:1) fn schedule(s: u32, ) -> Weight { - (18_013_000 as Weight) + Weight::from_ref_time(18_013_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((87_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(87_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) fn cancel(s: u32, ) -> Weight { - (18_131_000 as Weight) + Weight::from_ref_time(18_131_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((595_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(595_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn schedule_named(s: u32, ) -> Weight { - (21_230_000 as Weight) + Weight::from_ref_time(21_230_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((98_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(98_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn cancel_named(s: u32, ) -> Weight { - (20_139_000 as Weight) + Weight::from_ref_time(20_139_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((595_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(595_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } } diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index aa4f75255b120..dd96a5df2baf9 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -281,7 +281,7 @@ pub mod pallet { let pool = >::get(); >::refresh_members(pool, ChangeReceiver::MembershipChanged); } - 0 + Weight::zero() } } diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 4fef5385eb2c5..e38e0a18b99c8 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -50,7 +50,7 @@ frame_support::construct_runtime!( parameter_types! { pub const CandidateDeposit: u64 = 25; pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } ord_parameter_types! { pub const KickOrigin: u64 = 2; diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 71ee9d1e0758a..34c560984661d 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -574,7 +574,7 @@ pub mod pallet { // NOTE: the non-database part of the weight for `should_end_session(n)` is // included as weight for empty block, the database part is expected to be in // cache. - 0 + Weight::zero() } } } diff --git a/frame/session/src/migrations/v1.rs b/frame/session/src/migrations/v1.rs index 3c687ea7d9d66..c0dce422fe8b5 100644 --- a/frame/session/src/migrations/v1.rs +++ b/frame/session/src/migrations/v1.rs @@ -47,7 +47,7 @@ pub fn migrate::on_chain_storage_version(); @@ -82,7 +82,7 @@ pub fn migrate sp_io::TestExternalities { parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { diff --git a/frame/session/src/weights.rs b/frame/session/src/weights.rs index 40ae7f1be4265..5208a679c6bb7 100644 --- a/frame/session/src/weights.rs +++ b/frame/session/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_session. @@ -55,17 +55,17 @@ impl WeightInfo for SubstrateWeight { // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:4 w:4) fn set_keys() -> Weight { - (48_484_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(48_484_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:0 w:4) fn purge_keys() -> Weight { - (38_003_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(38_003_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } } @@ -75,16 +75,16 @@ impl WeightInfo for () { // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:4 w:4) fn set_keys() -> Weight { - (48_484_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(48_484_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:0 w:4) fn purge_keys() -> Weight { - (38_003_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(38_003_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } } diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index ec4cca1813ec6..626562f7a45f8 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -614,7 +614,7 @@ pub mod pallet { fn on_initialize(n: T::BlockNumber) -> Weight { let mut members = vec![]; - let mut weight = 0; + let mut weight = Weight::new(); let weights = T::BlockWeights::get(); // Run a candidate/membership rotation diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 04ea705eed556..ed668e79269fd 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -50,7 +50,7 @@ frame_support::construct_runtime!( parameter_types! { pub const SocietyPalletId: PalletId = PalletId(*b"py/socie"); pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } ord_parameter_types! { diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 68aa97db8a324..2a55d3baea2e6 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -1167,7 +1167,7 @@ where disable_strategy: DisableStrategy, ) -> Weight { let reward_proportion = SlashRewardFraction::::get(); - let mut consumed_weight: Weight = 0; + let mut consumed_weight = Weight::from_ref_time(0); let mut add_db_reads_writes = |reads, writes| { consumed_weight += T::DbWeight::get().reads_writes(reads, writes); }; diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 485a9dc3ae66a..cda606008a9cc 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -3759,7 +3759,7 @@ fn payout_stakers_handles_weight_refund() { let half_max_nom_rewarded_weight = ::WeightInfo::payout_stakers_alive_staked(half_max_nom_rewarded); let zero_nom_payouts_weight = ::WeightInfo::payout_stakers_alive_staked(0); - assert!(zero_nom_payouts_weight > 0); + assert!(zero_nom_payouts_weight > Weight::zero()); assert!(half_max_nom_rewarded_weight > zero_nom_payouts_weight); assert!(max_nom_rewarded_weight > half_max_nom_rewarded_weight); @@ -3898,42 +3898,68 @@ fn bond_during_era_correctly_populates_claimed_rewards() { fn offences_weight_calculated_correctly() { ExtBuilder::default().nominate(true).build_and_execute(|| { // On offence with zero offenders: 4 Reads, 1 Write - let zero_offence_weight = ::DbWeight::get().reads_writes(4, 1); - assert_eq!(Staking::on_offence(&[], &[Perbill::from_percent(50)], 0, DisableStrategy::WhenSlashed), zero_offence_weight); + let zero_offence_weight = + ::DbWeight::get().reads_writes(4, 1); + assert_eq!( + Staking::on_offence(&[], &[Perbill::from_percent(50)], 0, DisableStrategy::WhenSlashed), + zero_offence_weight + ); // On Offence with N offenders, Unapplied: 4 Reads, 1 Write + 4 Reads, 5 Writes - let n_offence_unapplied_weight = ::DbWeight::get().reads_writes(4, 1) - + ::DbWeight::get().reads_writes(4, 5); - - let offenders: Vec::AccountId, pallet_session::historical::IdentificationTuple>> - = (1..10).map(|i| - OffenceDetails { - offender: (i, Staking::eras_stakers(active_era(), i)), - reporters: vec![], - } - ).collect(); - assert_eq!(Staking::on_offence(&offenders, &[Perbill::from_percent(50)], 0, DisableStrategy::WhenSlashed), n_offence_unapplied_weight); + let n_offence_unapplied_weight = ::DbWeight::get() + .reads_writes(4, 1) + + ::DbWeight::get().reads_writes(4, 5); + + let offenders: Vec< + OffenceDetails< + ::AccountId, + pallet_session::historical::IdentificationTuple, + >, + > = (1..10) + .map(|i| OffenceDetails { + offender: (i, Staking::eras_stakers(active_era(), i)), + reporters: vec![], + }) + .collect(); + assert_eq!( + Staking::on_offence( + &offenders, + &[Perbill::from_percent(50)], + 0, + DisableStrategy::WhenSlashed + ), + n_offence_unapplied_weight + ); // On Offence with one offenders, Applied - let one_offender = [ - OffenceDetails { - offender: (11, Staking::eras_stakers(active_era(), 11)), - reporters: vec![1], - }, - ]; + let one_offender = [OffenceDetails { + offender: (11, Staking::eras_stakers(active_era(), 11)), + reporters: vec![1], + }]; let n = 1; // Number of offenders let rw = 3 + 3 * n; // rw reads and writes - let one_offence_unapplied_weight = ::DbWeight::get().reads_writes(4, 1) - + ::DbWeight::get().reads_writes(rw, rw) + let one_offence_unapplied_weight = + ::DbWeight::get().reads_writes(4, 1) + + + ::DbWeight::get().reads_writes(rw, rw) // One `slash_cost` + ::DbWeight::get().reads_writes(6, 5) // `slash_cost` * nominators (1) + ::DbWeight::get().reads_writes(6, 5) // `reward_cost` * reporters (1) - + ::DbWeight::get().reads_writes(2, 2); + + ::DbWeight::get().reads_writes(2, 2) + ; - assert_eq!(Staking::on_offence(&one_offender, &[Perbill::from_percent(50)], 0, DisableStrategy::WhenSlashed), one_offence_unapplied_weight); + assert_eq!( + Staking::on_offence( + &one_offender, + &[Perbill::from_percent(50)], + 0, + DisableStrategy::WhenSlashed + ), + one_offence_unapplied_weight + ); }); } diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index 1bdfb01bddc86..c5f584054d1f4 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_staking. @@ -86,9 +86,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - (43_992_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(43_992_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -96,9 +96,9 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList ListNodes (r:3 w:3) // Storage: BagsList ListBags (r:2 w:2) fn bond_extra() -> Weight { - (75_827_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(75_827_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(8 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(7 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) @@ -110,20 +110,20 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Bonded (r:1 w:0) // Storage: BagsList ListBags (r:2 w:2) fn unbond() -> Weight { - (81_075_000 as Weight) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(81_075_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(12 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(8 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn withdraw_unbonded_update(s: u32, ) -> Weight { - (35_763_000 as Weight) + Weight::from_ref_time(35_763_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((57_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(57_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -139,9 +139,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn withdraw_unbonded_kill(_s: u32, ) -> Weight { - (66_938_000 as Weight) - .saturating_add(T::DbWeight::get().reads(13 as Weight)) - .saturating_add(T::DbWeight::get().writes(11 as Weight)) + Weight::from_ref_time(66_938_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(13 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(11 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinValidatorBond (r:1 w:0) @@ -155,19 +155,19 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList CounterForListNodes (r:1 w:1) // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - (52_943_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(52_943_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(11 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) fn kick(k: u32, ) -> Weight { - (23_264_000 as Weight) + Weight::from_ref_time(23_264_000 as RefTimeWeight) // Standard Error: 11_000 - .saturating_add((8_006_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) + .saturating_add(Weight::from_ref_time(8_006_000 as RefTimeWeight).scalar_saturating_mul(k as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(k as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(k as RefTimeWeight))) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinNominatorBond (r:1 w:0) @@ -181,12 +181,12 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList CounterForListNodes (r:1 w:1) // Storage: Staking CounterForNominators (r:1 w:1) fn nominate(n: u32, ) -> Weight { - (56_596_000 as Weight) + Weight::from_ref_time(56_596_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((3_644_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(3_644_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(12 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Validators (r:1 w:0) @@ -196,50 +196,50 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList ListBags (r:1 w:1) // Storage: BagsList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - (51_117_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(51_117_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(8 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) fn set_payee() -> Weight { - (11_223_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(11_223_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (19_826_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(19_826_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - (3_789_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_789_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - (3_793_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_793_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - (3_802_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_802_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (3_762_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_762_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking Invulnerables (r:0 w:1) fn set_invulnerables(v: u32, ) -> Weight { - (4_318_000 as Weight) + Weight::from_ref_time(4_318_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((10_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(10_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking SlashingSpans (r:1 w:0) @@ -255,20 +255,20 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Payee (r:0 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (65_265_000 as Weight) + Weight::from_ref_time(65_265_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_029_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(1_029_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(11 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(12 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (903_312_000 as Weight) + Weight::from_ref_time(903_312_000 as RefTimeWeight) // Standard Error: 56_000 - .saturating_add((4_968_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(Weight::from_ref_time(4_968_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking HistoryDepth (r:1 w:0) @@ -281,13 +281,13 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Payee (r:2 w:0) // Storage: System Account (r:2 w:2) fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (87_569_000 as Weight) + Weight::from_ref_time(87_569_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((24_232_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(24_232_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(10 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((3 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking HistoryDepth (r:1 w:0) @@ -301,13 +301,13 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:2 w:2) // Storage: Balances Locks (r:2 w:2) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (98_839_000 as Weight) + Weight::from_ref_time(98_839_000 as RefTimeWeight) // Standard Error: 21_000 - .saturating_add((34_480_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(34_480_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(11 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((3 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -316,11 +316,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Bonded (r:1 w:0) // Storage: BagsList ListBags (r:2 w:2) fn rebond(l: u32, ) -> Weight { - (74_865_000 as Weight) + Weight::from_ref_time(74_865_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((64_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + .saturating_add(Weight::from_ref_time(64_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(9 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(8 as RefTimeWeight)) } // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking HistoryDepth (r:1 w:1) @@ -332,12 +332,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) fn set_history_depth(e: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 62_000 - .saturating_add((22_829_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) + .saturating_add(Weight::from_ref_time(22_829_000 as RefTimeWeight).scalar_saturating_mul(e as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((7 as RefTimeWeight).saturating_mul(e as RefTimeWeight))) } // Storage: System Account (r:1 w:1) // Storage: Staking Bonded (r:1 w:1) @@ -353,12 +353,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Payee (r:0 w:1) // Storage: Staking SpanSlash (r:0 w:1) fn reap_stash(s: u32, ) -> Weight { - (70_933_000 as Weight) + Weight::from_ref_time(70_933_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_021_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(1_021_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(12 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(12 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: BagsList CounterForListNodes (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) @@ -379,16 +379,16 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) fn new_era(v: u32, n: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 897_000 - .saturating_add((213_100_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(213_100_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 45_000 - .saturating_add((31_123_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(208 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(Weight::from_ref_time(31_123_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(208 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((5 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) + .saturating_add(T::DbWeight::get().reads((4 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((3 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) } // Storage: BagsList CounterForListNodes (r:1 w:0) // Storage: Staking SlashingSpans (r:21 w:0) @@ -399,25 +399,25 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Bonded (r:1500 w:0) // Storage: Staking Ledger (r:1500 w:0) fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 116_000 - .saturating_add((23_745_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(23_745_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 116_000 - .saturating_add((22_497_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(22_497_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 3_968_000 - .saturating_add((20_676_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(202 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(20_676_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(202 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((5 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) + .saturating_add(T::DbWeight::get().reads((4 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Staking Validators (r:501 w:0) fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 36_000 - .saturating_add((8_097_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + .saturating_add(Weight::from_ref_time(8_097_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) } // Storage: Staking MinCommission (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) @@ -426,8 +426,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_set() -> Weight { - (7_041_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(7_041_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Staking MinCommission (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) @@ -436,8 +436,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_remove() -> Weight { - (6_495_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(6_495_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) @@ -450,16 +450,16 @@ impl WeightInfo for SubstrateWeight { // Storage: BagsList ListBags (r:1 w:1) // Storage: BagsList CounterForListNodes (r:1 w:1) fn chill_other() -> Weight { - (62_014_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(62_014_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(11 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Staking MinCommission (r:1 w:0) // Storage: Staking Validators (r:1 w:1) fn force_apply_min_commission() -> Weight { - (12_814_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(12_814_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } } @@ -472,9 +472,9 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - (43_992_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(43_992_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -482,9 +482,9 @@ impl WeightInfo for () { // Storage: BagsList ListNodes (r:3 w:3) // Storage: BagsList ListBags (r:2 w:2) fn bond_extra() -> Weight { - (75_827_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(75_827_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(8 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(7 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) @@ -496,20 +496,20 @@ impl WeightInfo for () { // Storage: Staking Bonded (r:1 w:0) // Storage: BagsList ListBags (r:2 w:2) fn unbond() -> Weight { - (81_075_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(12 as Weight)) - .saturating_add(RocksDbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(81_075_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(12 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(8 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn withdraw_unbonded_update(s: u32, ) -> Weight { - (35_763_000 as Weight) + Weight::from_ref_time(35_763_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((57_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(57_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -525,9 +525,9 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn withdraw_unbonded_kill(_s: u32, ) -> Weight { - (66_938_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(13 as Weight)) - .saturating_add(RocksDbWeight::get().writes(11 as Weight)) + Weight::from_ref_time(66_938_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(13 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(11 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinValidatorBond (r:1 w:0) @@ -541,19 +541,19 @@ impl WeightInfo for () { // Storage: BagsList CounterForListNodes (r:1 w:1) // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - (52_943_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(52_943_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(11 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) fn kick(k: u32, ) -> Weight { - (23_264_000 as Weight) + Weight::from_ref_time(23_264_000 as RefTimeWeight) // Standard Error: 11_000 - .saturating_add((8_006_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) + .saturating_add(Weight::from_ref_time(8_006_000 as RefTimeWeight).scalar_saturating_mul(k as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(k as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(k as RefTimeWeight))) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinNominatorBond (r:1 w:0) @@ -567,12 +567,12 @@ impl WeightInfo for () { // Storage: BagsList CounterForListNodes (r:1 w:1) // Storage: Staking CounterForNominators (r:1 w:1) fn nominate(n: u32, ) -> Weight { - (56_596_000 as Weight) + Weight::from_ref_time(56_596_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((3_644_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(12 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(3_644_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(12 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Validators (r:1 w:0) @@ -582,50 +582,50 @@ impl WeightInfo for () { // Storage: BagsList ListBags (r:1 w:1) // Storage: BagsList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - (51_117_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(51_117_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(8 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) fn set_payee() -> Weight { - (11_223_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(11_223_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (19_826_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(19_826_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - (3_789_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_789_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - (3_793_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_793_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - (3_802_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_802_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (3_762_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(3_762_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking Invulnerables (r:0 w:1) fn set_invulnerables(v: u32, ) -> Weight { - (4_318_000 as Weight) + Weight::from_ref_time(4_318_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((10_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(10_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking SlashingSpans (r:1 w:0) @@ -641,20 +641,20 @@ impl WeightInfo for () { // Storage: Staking Payee (r:0 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (65_265_000 as Weight) + Weight::from_ref_time(65_265_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_029_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().writes(12 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(1_029_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(11 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(12 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (903_312_000 as Weight) + Weight::from_ref_time(903_312_000 as RefTimeWeight) // Standard Error: 56_000 - .saturating_add((4_968_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(4_968_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking HistoryDepth (r:1 w:0) @@ -667,13 +667,13 @@ impl WeightInfo for () { // Storage: Staking Payee (r:2 w:0) // Storage: System Account (r:2 w:2) fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (87_569_000 as Weight) + Weight::from_ref_time(87_569_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((24_232_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(24_232_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(10 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((3 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking HistoryDepth (r:1 w:0) @@ -687,13 +687,13 @@ impl WeightInfo for () { // Storage: System Account (r:2 w:2) // Storage: Balances Locks (r:2 w:2) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (98_839_000 as Weight) + Weight::from_ref_time(98_839_000 as RefTimeWeight) // Standard Error: 21_000 - .saturating_add((34_480_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(Weight::from_ref_time(34_480_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(11 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((5 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((3 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) } // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -702,11 +702,11 @@ impl WeightInfo for () { // Storage: Staking Bonded (r:1 w:0) // Storage: BagsList ListBags (r:2 w:2) fn rebond(l: u32, ) -> Weight { - (74_865_000 as Weight) + Weight::from_ref_time(74_865_000 as RefTimeWeight) // Standard Error: 3_000 - .saturating_add((64_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(RocksDbWeight::get().reads(9 as Weight)) - .saturating_add(RocksDbWeight::get().writes(8 as Weight)) + .saturating_add(Weight::from_ref_time(64_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(9 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(8 as RefTimeWeight)) } // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking HistoryDepth (r:1 w:1) @@ -718,12 +718,12 @@ impl WeightInfo for () { // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) fn set_history_depth(e: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 62_000 - .saturating_add((22_829_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) + .saturating_add(Weight::from_ref_time(22_829_000 as RefTimeWeight).scalar_saturating_mul(e as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((7 as RefTimeWeight).saturating_mul(e as RefTimeWeight))) } // Storage: System Account (r:1 w:1) // Storage: Staking Bonded (r:1 w:1) @@ -739,12 +739,12 @@ impl WeightInfo for () { // Storage: Staking Payee (r:0 w:1) // Storage: Staking SpanSlash (r:0 w:1) fn reap_stash(s: u32, ) -> Weight { - (70_933_000 as Weight) + Weight::from_ref_time(70_933_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_021_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(12 as Weight)) - .saturating_add(RocksDbWeight::get().writes(12 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(1_021_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(12 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(12 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: BagsList CounterForListNodes (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) @@ -765,16 +765,16 @@ impl WeightInfo for () { // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) fn new_era(v: u32, n: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 897_000 - .saturating_add((213_100_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(213_100_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 45_000 - .saturating_add((31_123_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(208 as Weight)) - .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(v as Weight))) - .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(Weight::from_ref_time(31_123_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(208 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((5 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().reads((4 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((3 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) } // Storage: BagsList CounterForListNodes (r:1 w:0) // Storage: Staking SlashingSpans (r:21 w:0) @@ -785,25 +785,25 @@ impl WeightInfo for () { // Storage: Staking Bonded (r:1500 w:0) // Storage: Staking Ledger (r:1500 w:0) fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 116_000 - .saturating_add((23_745_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(23_745_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) // Standard Error: 116_000 - .saturating_add((22_497_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(22_497_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 3_968_000 - .saturating_add((20_676_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(202 as Weight)) - .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(v as Weight))) - .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) + .saturating_add(Weight::from_ref_time(20_676_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(202 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((5 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().reads((4 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(s as RefTimeWeight))) } // Storage: Staking Validators (r:501 w:0) fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 36_000 - .saturating_add((8_097_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + .saturating_add(Weight::from_ref_time(8_097_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(v as RefTimeWeight))) } // Storage: Staking MinCommission (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) @@ -812,8 +812,8 @@ impl WeightInfo for () { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_set() -> Weight { - (7_041_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(7_041_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Staking MinCommission (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) @@ -822,8 +822,8 @@ impl WeightInfo for () { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_remove() -> Weight { - (6_495_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(6_495_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) @@ -836,15 +836,15 @@ impl WeightInfo for () { // Storage: BagsList ListBags (r:1 w:1) // Storage: BagsList CounterForListNodes (r:1 w:1) fn chill_other() -> Weight { - (62_014_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(62_014_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(11 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(6 as RefTimeWeight)) } // Storage: Staking MinCommission (r:1 w:0) // Storage: Staking Validators (r:1 w:1) fn force_apply_min_commission() -> Weight { - (12_814_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(12_814_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } } diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 9b0172bf97aa2..93b5bd3468f6b 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -839,9 +839,10 @@ pub mod pallet { impl Pallet { /// The real weight of a migration of the given number of `items` with total `size`. fn dynamic_weight(items: u32, size: u32) -> frame_support::pallet_prelude::Weight { - let items = items as Weight; - items - .saturating_mul(::DbWeight::get().reads_writes(1, 1)) + let items = items as u64; + ::DbWeight::get() + .reads_writes(1, 1) + .scalar_saturating_mul(items) // we assume that the read/write per-byte weight is the same for child and top tree. .saturating_add(T::WeightInfo::process_top_key(size)) } @@ -1129,25 +1130,25 @@ mod mock { impl WeightInfo for StateMigrationTestWeight { fn process_top_key(_: u32) -> Weight { - 1000000 + Weight::from_ref_time(1000000) } fn continue_migrate() -> Weight { - 1000000 + Weight::from_ref_time(1000000) } fn continue_migrate_wrong_witness() -> Weight { - 1000000 + Weight::from_ref_time(1000000) } fn migrate_custom_top_fail() -> Weight { - 1000000 + Weight::from_ref_time(1000000) } fn migrate_custom_top_success() -> Weight { - 1000000 + Weight::from_ref_time(1000000) } fn migrate_custom_child_fail() -> Weight { - 1000000 + Weight::from_ref_time(1000000) } fn migrate_custom_child_success() -> Weight { - 1000000 + Weight::from_ref_time(1000000) } } @@ -1243,9 +1244,9 @@ mod mock { (custom_storage, version).into() } - pub(crate) fn run_to_block(n: u32) -> (H256, u64) { + pub(crate) fn run_to_block(n: u32) -> (H256, Weight) { let mut root = Default::default(); - let mut weight_sum = 0; + let mut weight_sum = Weight::new(); log::trace!(target: LOG_TARGET, "running from {:?} to {:?}", System::block_number(), n); while System::block_number() < n { System::set_block_number(System::block_number() + 1); @@ -1606,7 +1607,10 @@ pub(crate) mod remote_tests { use crate::{AutoLimits, MigrationLimits, Pallet as StateTrieMigration, LOG_TARGET}; use codec::Encode; use frame_benchmarking::Zero; - use frame_support::traits::{Get, Hooks}; + use frame_support::{ + traits::{Get, Hooks}, + weights::Weight, + }; use frame_system::Pallet as System; use remote_externalities::Mode; use sp_core::H256; @@ -1616,9 +1620,9 @@ pub(crate) mod remote_tests { #[allow(dead_code)] fn run_to_block>( n: ::BlockNumber, - ) -> (H256, u64) { + ) -> (H256, Weight) { let mut root = Default::default(); - let mut weight_sum = 0; + let mut weight_sum = Weight::new(); while System::::block_number() < n { System::::set_block_number(System::::block_number() + One::one()); System::::on_initialize(System::::block_number()); diff --git a/frame/state-trie-migration/src/weights.rs b/frame/state-trie-migration/src/weights.rs index f2566f949c058..6fccc0b68f3d7 100644 --- a/frame/state-trie-migration/src/weights.rs +++ b/frame/state-trie-migration/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_state_trie_migration. @@ -59,40 +59,40 @@ impl WeightInfo for SubstrateWeight { // Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) // Storage: StateTrieMigration MigrationProcess (r:1 w:1) fn continue_migrate() -> Weight { - (19_019_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_019_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) fn continue_migrate_wrong_witness() -> Weight { - (1_874_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(1_874_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) } fn migrate_custom_top_success() -> Weight { - (16_381_000 as Weight) + Weight::from_ref_time(16_381_000 as RefTimeWeight) } // Storage: unknown [0x666f6f] (r:1 w:1) fn migrate_custom_top_fail() -> Weight { - (25_966_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_966_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } fn migrate_custom_child_success() -> Weight { - (16_712_000 as Weight) + Weight::from_ref_time(16_712_000 as RefTimeWeight) } // Storage: unknown [0x666f6f] (r:1 w:1) fn migrate_custom_child_fail() -> Weight { - (29_885_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(29_885_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: unknown [0x6b6579] (r:1 w:1) fn process_top_key(v: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } } @@ -101,39 +101,39 @@ impl WeightInfo for () { // Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) // Storage: StateTrieMigration MigrationProcess (r:1 w:1) fn continue_migrate() -> Weight { - (19_019_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_019_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) fn continue_migrate_wrong_witness() -> Weight { - (1_874_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(1_874_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) } fn migrate_custom_top_success() -> Weight { - (16_381_000 as Weight) + Weight::from_ref_time(16_381_000 as RefTimeWeight) } // Storage: unknown [0x666f6f] (r:1 w:1) fn migrate_custom_top_fail() -> Weight { - (25_966_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_966_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } fn migrate_custom_child_success() -> Weight { - (16_712_000 as Weight) + Weight::from_ref_time(16_712_000 as RefTimeWeight) } // Storage: unknown [0x666f6f] (r:1 w:1) fn migrate_custom_child_fail() -> Weight { - (29_885_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(29_885_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: unknown [0x6b6579] (r:1 w:1) fn process_top_key(v: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } } diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 07fdc56e82da6..bde69f11106dc 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -139,7 +139,7 @@ pub mod pallet { /// # #[pallet::weight({ let dispatch_info = call.get_dispatch_info(); - (dispatch_info.weight.saturating_add(10_000), dispatch_info.class) + (dispatch_info.weight, dispatch_info.class) })] pub fn sudo( origin: OriginFor, @@ -222,7 +222,6 @@ pub mod pallet { let dispatch_info = call.get_dispatch_info(); ( dispatch_info.weight - .saturating_add(10_000) // AccountData for inner call origin accountdata. .saturating_add(T::DbWeight::get().reads_writes(1, 1)), dispatch_info.class, diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 71f0f26b1a1d5..c895eaf830136 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -22,6 +22,7 @@ use crate as sudo; use frame_support::{ parameter_types, traits::{ConstU32, ConstU64, Contains, GenesisBuild}, + weights::Weight, }; use frame_system::limits; use sp_core::H256; @@ -109,7 +110,7 @@ frame_support::construct_runtime!( ); parameter_types! { - pub BlockWeights: limits::BlockWeights = limits::BlockWeights::simple_max(1024); + pub BlockWeights: limits::BlockWeights = limits::BlockWeights::simple_max(Weight::from_ref_time(1024)); } pub struct BlockEverything; diff --git a/frame/sudo/src/tests.rs b/frame/sudo/src/tests.rs index 84c8e0c5c254e..502c6476935a2 100644 --- a/frame/sudo/src/tests.rs +++ b/frame/sudo/src/tests.rs @@ -18,7 +18,7 @@ //! Tests for the module. use super::*; -use frame_support::{assert_noop, assert_ok}; +use frame_support::{assert_noop, assert_ok, weights::Weight}; use mock::{ new_test_ext, Call, Event as TestEvent, Logger, LoggerCall, Origin, Sudo, SudoCall, System, Test, @@ -39,12 +39,18 @@ fn sudo_basics() { // Configure a default test environment and set the root `key` to 1. new_test_ext(1).execute_with(|| { // A privileged function should work when `sudo` is passed the root `key` as `origin`. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); + let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { + i: 42, + weight: Weight::from_ref_time(1_000), + })); assert_ok!(Sudo::sudo(Origin::signed(1), call)); assert_eq!(Logger::i32_log(), vec![42i32]); // A privileged function should not work when `sudo` is passed a non-root `key` as `origin`. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); + let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { + i: 42, + weight: Weight::from_ref_time(1_000), + })); assert_noop!(Sudo::sudo(Origin::signed(2), call), Error::::RequireSudo); }); } @@ -56,7 +62,8 @@ fn sudo_emits_events_correctly() { System::set_block_number(1); // Should emit event to indicate success when called with the root `key` and `call` is `Ok`. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 })); + let call = + Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: Weight::one() })); assert_ok!(Sudo::sudo(Origin::signed(1), call)); System::assert_has_event(TestEvent::Sudo(Event::Sudid { sudo_result: Ok(()) })); }) @@ -66,24 +73,36 @@ fn sudo_emits_events_correctly() { fn sudo_unchecked_weight_basics() { new_test_ext(1).execute_with(|| { // A privileged function should work when `sudo` is passed the root `key` as origin. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); - assert_ok!(Sudo::sudo_unchecked_weight(Origin::signed(1), call, 1_000)); + let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { + i: 42, + weight: Weight::from_ref_time(1_000), + })); + assert_ok!(Sudo::sudo_unchecked_weight( + Origin::signed(1), + call, + Weight::from_ref_time(1_000) + )); assert_eq!(Logger::i32_log(), vec![42i32]); // A privileged function should not work when called with a non-root `key`. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); + let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { + i: 42, + weight: Weight::from_ref_time(1_000), + })); assert_noop!( - Sudo::sudo_unchecked_weight(Origin::signed(2), call, 1_000), + Sudo::sudo_unchecked_weight(Origin::signed(2), call, Weight::from_ref_time(1_000)), Error::::RequireSudo, ); // `I32Log` is unchanged after unsuccessful call. assert_eq!(Logger::i32_log(), vec![42i32]); // Controls the dispatched weight. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 })); - let sudo_unchecked_weight_call = SudoCall::sudo_unchecked_weight { call, weight: 1_000 }; + let call = + Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: Weight::one() })); + let sudo_unchecked_weight_call = + SudoCall::sudo_unchecked_weight { call, weight: Weight::from_ref_time(1_000) }; let info = sudo_unchecked_weight_call.get_dispatch_info(); - assert_eq!(info.weight, 1_000); + assert_eq!(info.weight, Weight::from_ref_time(1_000)); }); } @@ -94,8 +113,13 @@ fn sudo_unchecked_weight_emits_events_correctly() { System::set_block_number(1); // Should emit event to indicate success when called with the root `key` and `call` is `Ok`. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 })); - assert_ok!(Sudo::sudo_unchecked_weight(Origin::signed(1), call, 1_000)); + let call = + Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: Weight::one() })); + assert_ok!(Sudo::sudo_unchecked_weight( + Origin::signed(1), + call, + Weight::from_ref_time(1_000) + )); System::assert_has_event(TestEvent::Sudo(Event::Sudid { sudo_result: Ok(()) })); }) } @@ -134,17 +158,22 @@ fn set_key_emits_events_correctly() { fn sudo_as_basics() { new_test_ext(1).execute_with(|| { // A privileged function will not work when passed to `sudo_as`. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); + let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { + i: 42, + weight: Weight::from_ref_time(1_000), + })); assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call)); assert!(Logger::i32_log().is_empty()); assert!(Logger::account_log().is_empty()); // A non-privileged function should not work when called with a non-root `key`. - let call = Box::new(Call::Logger(LoggerCall::non_privileged_log { i: 42, weight: 1 })); + let call = + Box::new(Call::Logger(LoggerCall::non_privileged_log { i: 42, weight: Weight::one() })); assert_noop!(Sudo::sudo_as(Origin::signed(3), 2, call), Error::::RequireSudo); // A non-privileged function will work when passed to `sudo_as` with the root `key`. - let call = Box::new(Call::Logger(LoggerCall::non_privileged_log { i: 42, weight: 1 })); + let call = + Box::new(Call::Logger(LoggerCall::non_privileged_log { i: 42, weight: Weight::one() })); assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call)); assert_eq!(Logger::i32_log(), vec![42i32]); // The correct user makes the call within `sudo_as`. @@ -159,7 +188,8 @@ fn sudo_as_emits_events_correctly() { System::set_block_number(1); // A non-privileged function will work when passed to `sudo_as` with the root `key`. - let call = Box::new(Call::Logger(LoggerCall::non_privileged_log { i: 42, weight: 1 })); + let call = + Box::new(Call::Logger(LoggerCall::non_privileged_log { i: 42, weight: Weight::one() })); assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call)); System::assert_has_event(TestEvent::Sudo(Event::SudoAsDone { sudo_result: Ok(()) })); }); diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index a658f01fa6854..97312ac3476b5 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -176,18 +176,18 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug + /// ``` /// # #[macro_use] /// # extern crate frame_support; -/// # use frame_support::dispatch::{DispatchResultWithPostInfo, WithPostDispatchInfo}; +/// # use frame_support::{weights::Weight, dispatch::{DispatchResultWithPostInfo, WithPostDispatchInfo}}; /// # use frame_system::{Config, ensure_signed}; /// decl_module! { /// pub struct Module for enum Call where origin: T::Origin { /// #[weight = 1_000_000] /// fn my_long_function(origin, do_expensive_calc: bool) -> DispatchResultWithPostInfo { -/// ensure_signed(origin).map_err(|e| e.with_weight(100_000))?; +/// ensure_signed(origin).map_err(|e| e.with_weight(Weight::from_ref_time(100_000)))?; /// if do_expensive_calc { /// // do the expensive calculation /// // ... /// // return None to indicate that we are using all weight (the default) -/// return Ok(None.into()); +/// return Ok(None::.into()); /// } /// // expensive calculation not executed: use only a portion of the weight /// Ok(Some(100_000).into()) @@ -1614,7 +1614,7 @@ macro_rules! decl_module { pallet_name, ); - 0 + $crate::dispatch::Weight::new() } #[cfg(feature = "try-runtime")] @@ -2649,13 +2649,13 @@ mod tests { #[weight = (5, DispatchClass::Operational)] fn operational(_origin) { unreachable!() } - fn on_initialize(n: T::BlockNumber,) -> Weight { if n.into() == 42 { panic!("on_initialize") } 7 } + fn on_initialize(n: T::BlockNumber,) -> Weight { if n.into() == 42 { panic!("on_initialize") } Weight::from_ref_time(7) } fn on_idle(n: T::BlockNumber, remaining_weight: Weight,) -> Weight { - if n.into() == 42 || remaining_weight == 42 { panic!("on_idle") } - 7 + if n.into() == 42 || remaining_weight == Weight::from_ref_time(42) { panic!("on_idle") } + Weight::from_ref_time(7) } fn on_finalize(n: T::BlockNumber,) { if n.into() == 42 { panic!("on_finalize") } } - fn on_runtime_upgrade() -> Weight { 10 } + fn on_runtime_upgrade() -> Weight { Weight::from_ref_time(10) } fn offchain_worker() {} /// Some doc fn integrity_test() { panic!("integrity_test") } @@ -2814,24 +2814,30 @@ mod tests { #[test] fn on_initialize_should_work_2() { - assert_eq!( as OnInitialize>::on_initialize(10), 7); + assert_eq!( + as OnInitialize>::on_initialize(10), + Weight::from_ref_time(7) + ); } #[test] #[should_panic(expected = "on_idle")] fn on_idle_should_work_1() { - as OnIdle>::on_idle(42, 9); + as OnIdle>::on_idle(42, Weight::from_ref_time(9)); } #[test] #[should_panic(expected = "on_idle")] fn on_idle_should_work_2() { - as OnIdle>::on_idle(9, 42); + as OnIdle>::on_idle(9, Weight::from_ref_time(42)); } #[test] fn on_idle_should_work_3() { - assert_eq!( as OnIdle>::on_idle(10, 11), 7); + assert_eq!( + as OnIdle>::on_idle(10, Weight::from_ref_time(11)), + Weight::from_ref_time(7) + ); } #[test] @@ -2843,7 +2849,10 @@ mod tests { #[test] fn on_runtime_upgrade_should_work() { sp_io::TestExternalities::default().execute_with(|| { - assert_eq!( as OnRuntimeUpgrade>::on_runtime_upgrade(), 10) + assert_eq!( + as OnRuntimeUpgrade>::on_runtime_upgrade(), + Weight::from_ref_time(10) + ) }); } @@ -2852,12 +2861,20 @@ mod tests { // operational. assert_eq!( Call::::operational {}.get_dispatch_info(), - DispatchInfo { weight: 5, class: DispatchClass::Operational, pays_fee: Pays::Yes }, + DispatchInfo { + weight: Weight::from_ref_time(5), + class: DispatchClass::Operational, + pays_fee: Pays::Yes + }, ); // custom basic assert_eq!( Call::::aux_3 {}.get_dispatch_info(), - DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: Pays::Yes }, + DispatchInfo { + weight: Weight::from_ref_time(3), + class: DispatchClass::Normal, + pays_fee: Pays::Yes + }, ); } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 72551980bc7e9..a81a266fb9a3d 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -1374,7 +1374,7 @@ pub mod pallet_prelude { ConstU32, EnsureOrigin, Get, GetDefault, GetStorageVersion, Hooks, IsType, PalletInfoAccess, StorageInfoTrait, StorageVersion, TypedGet, }, - weights::{DispatchClass, Pays, Weight}, + weights::{DispatchClass, Pays, RefTimeWeight, Weight}, Blake2_128, Blake2_128Concat, Blake2_256, CloneNoBound, DebugNoBound, EqNoBound, Identity, PartialEqNoBound, RuntimeDebug, RuntimeDebugNoBound, Twox128, Twox256, Twox64Concat, }; diff --git a/frame/support/src/migrations.rs b/frame/support/src/migrations.rs index f594b98ede4ff..b559d3aca615f 100644 --- a/frame/support/src/migrations.rs +++ b/frame/support/src/migrations.rs @@ -48,7 +48,7 @@ impl PalletVersionToStorageVersionHelpe #[cfg_attr(feature = "tuples-128", impl_for_tuples(128))] impl PalletVersionToStorageVersionHelper for T { fn migrate(db_weight: &RuntimeDbWeight) -> Weight { - let mut weight: Weight = 0; + let mut weight = Weight::new(); for_tuples!( #( weight = weight.saturating_add(T::migrate(db_weight)); )* ); diff --git a/frame/support/src/traits/hooks.rs b/frame/support/src/traits/hooks.rs index 2b7234006e0ff..f8e91886edf0c 100644 --- a/frame/support/src/traits/hooks.rs +++ b/frame/support/src/traits/hooks.rs @@ -17,8 +17,8 @@ //! Traits for hooking tasks to events in a blockchain's lifecycle. +use crate::weights::Weight; use impl_trait_for_tuples::impl_for_tuples; -use sp_arithmetic::traits::Saturating; use sp_runtime::traits::AtLeast32BitUnsigned; /// The block initialization trait. @@ -33,8 +33,8 @@ pub trait OnInitialize { /// NOTE: This function is called BEFORE ANY extrinsic in a block is applied, /// including inherent extrinsics. Hence for instance, if you runtime includes /// `pallet_timestamp`, the `timestamp` is not yet up to date at this point. - fn on_initialize(_n: BlockNumber) -> crate::weights::Weight { - 0 + fn on_initialize(_n: BlockNumber) -> Weight { + Weight::new() } } @@ -42,8 +42,8 @@ pub trait OnInitialize { #[cfg_attr(all(feature = "tuples-96", not(feature = "tuples-128")), impl_for_tuples(96))] #[cfg_attr(feature = "tuples-128", impl_for_tuples(128))] impl OnInitialize for Tuple { - fn on_initialize(n: BlockNumber) -> crate::weights::Weight { - let mut weight = 0; + fn on_initialize(n: BlockNumber) -> Weight { + let mut weight = Weight::new(); for_tuples!( #( weight = weight.saturating_add(Tuple::on_initialize(n.clone())); )* ); weight } @@ -75,11 +75,8 @@ pub trait OnIdle { /// /// NOTE: This function is called AFTER ALL extrinsics - including inherent extrinsics - /// in a block are applied but before `on_finalize` is executed. - fn on_idle( - _n: BlockNumber, - _remaining_weight: crate::weights::Weight, - ) -> crate::weights::Weight { - 0 + fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight { + Weight::new() } } @@ -87,12 +84,10 @@ pub trait OnIdle { #[cfg_attr(all(feature = "tuples-96", not(feature = "tuples-128")), impl_for_tuples(96))] #[cfg_attr(feature = "tuples-128", impl_for_tuples(128))] impl OnIdle for Tuple { - fn on_idle(n: BlockNumber, remaining_weight: crate::weights::Weight) -> crate::weights::Weight { - let on_idle_functions: &[fn( - BlockNumber, - crate::weights::Weight, - ) -> crate::weights::Weight] = &[for_tuples!( #( Tuple::on_idle ),* )]; - let mut weight = 0; + fn on_idle(n: BlockNumber, remaining_weight: Weight) -> Weight { + let on_idle_functions: &[fn(BlockNumber, Weight) -> Weight] = + &[for_tuples!( #( Tuple::on_idle ),* )]; + let mut weight = Weight::new(); let len = on_idle_functions.len(); let start_index = n % (len as u32).into(); let start_index = start_index.try_into().ok().expect( @@ -174,8 +169,8 @@ pub trait OnRuntimeUpgrade { /// block local data are not accessible. /// /// Return the non-negotiable weight consumed for runtime upgrade. - fn on_runtime_upgrade() -> crate::weights::Weight { - 0 + fn on_runtime_upgrade() -> Weight { + Weight::new() } /// Execute some pre-checks prior to a runtime upgrade. @@ -199,8 +194,8 @@ pub trait OnRuntimeUpgrade { #[cfg_attr(all(feature = "tuples-96", not(feature = "tuples-128")), impl_for_tuples(96))] #[cfg_attr(feature = "tuples-128", impl_for_tuples(128))] impl OnRuntimeUpgrade for Tuple { - fn on_runtime_upgrade() -> crate::weights::Weight { - let mut weight = 0; + fn on_runtime_upgrade() -> Weight { + let mut weight = Weight::new(); for_tuples!( #( weight = weight.saturating_add(Tuple::on_runtime_upgrade()); )* ); weight } @@ -243,18 +238,15 @@ pub trait Hooks { /// Will not fire if the remaining weight is 0. /// Return the weight used, the hook will subtract it from current weight used /// and pass the result to the next `on_idle` hook if it exists. - fn on_idle( - _n: BlockNumber, - _remaining_weight: crate::weights::Weight, - ) -> crate::weights::Weight { - 0 + fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight { + Weight::new() } /// The block is being initialized. Implement to have something happen. /// /// Return the non-negotiable weight consumed in the block. - fn on_initialize(_n: BlockNumber) -> crate::weights::Weight { - 0 + fn on_initialize(_n: BlockNumber) -> Weight { + Weight::new() } /// Perform a module upgrade. @@ -276,8 +268,8 @@ pub trait Hooks { /// pallet is discouraged and might get deprecated in the future. Alternatively, export the same /// logic as a free-function from your pallet, and pass it to `type Executive` from the /// top-level runtime. - fn on_runtime_upgrade() -> crate::weights::Weight { - 0 + fn on_runtime_upgrade() -> Weight { + Weight::new() } /// Execute some pre-checks prior to a runtime upgrade. @@ -360,18 +352,18 @@ mod tests { fn on_initialize_and_on_runtime_upgrade_weight_merge_works() { struct Test; impl OnInitialize for Test { - fn on_initialize(_n: u8) -> crate::weights::Weight { - 10 + fn on_initialize(_n: u8) -> Weight { + Weight::from_ref_time(10) } } impl OnRuntimeUpgrade for Test { - fn on_runtime_upgrade() -> crate::weights::Weight { - 20 + fn on_runtime_upgrade() -> Weight { + Weight::from_ref_time(20) } } - assert_eq!(<(Test, Test)>::on_initialize(0), 20); - assert_eq!(<(Test, Test)>::on_runtime_upgrade(), 40); + assert_eq!(<(Test, Test)>::on_initialize(0), Weight::from_ref_time(20)); + assert_eq!(<(Test, Test)>::on_runtime_upgrade(), Weight::from_ref_time(40)); } #[test] @@ -383,48 +375,48 @@ mod tests { struct Test3; type TestTuple = (Test1, Test2, Test3); impl OnIdle for Test1 { - fn on_idle(_n: u32, _weight: crate::weights::Weight) -> crate::weights::Weight { + fn on_idle(_n: u32, _weight: Weight) -> Weight { unsafe { ON_IDLE_INVOCATION_ORDER.push("Test1"); } - 0 + Weight::zero() } } impl OnIdle for Test2 { - fn on_idle(_n: u32, _weight: crate::weights::Weight) -> crate::weights::Weight { + fn on_idle(_n: u32, _weight: Weight) -> Weight { unsafe { ON_IDLE_INVOCATION_ORDER.push("Test2"); } - 0 + Weight::zero() } } impl OnIdle for Test3 { - fn on_idle(_n: u32, _weight: crate::weights::Weight) -> crate::weights::Weight { + fn on_idle(_n: u32, _weight: Weight) -> Weight { unsafe { ON_IDLE_INVOCATION_ORDER.push("Test3"); } - 0 + Weight::zero() } } unsafe { - TestTuple::on_idle(0, 0); + TestTuple::on_idle(0, Weight::zero()); assert_eq!(ON_IDLE_INVOCATION_ORDER, ["Test1", "Test2", "Test3"].to_vec()); ON_IDLE_INVOCATION_ORDER.clear(); - TestTuple::on_idle(1, 0); + TestTuple::on_idle(1, Weight::zero()); assert_eq!(ON_IDLE_INVOCATION_ORDER, ["Test2", "Test3", "Test1"].to_vec()); ON_IDLE_INVOCATION_ORDER.clear(); - TestTuple::on_idle(2, 0); + TestTuple::on_idle(2, Weight::zero()); assert_eq!(ON_IDLE_INVOCATION_ORDER, ["Test3", "Test1", "Test2"].to_vec()); ON_IDLE_INVOCATION_ORDER.clear(); - TestTuple::on_idle(3, 0); + TestTuple::on_idle(3, Weight::zero()); assert_eq!(ON_IDLE_INVOCATION_ORDER, ["Test1", "Test2", "Test3"].to_vec()); ON_IDLE_INVOCATION_ORDER.clear(); - TestTuple::on_idle(4, 0); + TestTuple::on_idle(4, Weight::zero()); assert_eq!(ON_IDLE_INVOCATION_ORDER, ["Test2", "Test3", "Test1"].to_vec()); ON_IDLE_INVOCATION_ORDER.clear(); } diff --git a/frame/support/src/weights.rs b/frame/support/src/weights.rs index fb34484416063..568cb5535ccda 100644 --- a/frame/support/src/weights.rs +++ b/frame/support/src/weights.rs @@ -123,6 +123,7 @@ mod block_weights; mod extrinsic_weights; mod paritydb_weights; mod rocksdb_weights; +mod weight_v2; use crate::{ dispatch::{DispatchError, DispatchErrorWithPostInfo, DispatchResultWithPostInfo}, @@ -146,18 +147,17 @@ use sp_runtime::{ /// Re-export priority as type pub use sp_runtime::transaction_validity::TransactionPriority; -/// Numeric range of a transaction weight. -pub type Weight = u64; +pub use weight_v2::*; /// These constants are specific to FRAME, and the current implementation of its various components. /// For example: FRAME System, FRAME Executive, our FRAME support libraries, etc... pub mod constants { use super::Weight; - pub const WEIGHT_PER_SECOND: Weight = 1_000_000_000_000; - pub const WEIGHT_PER_MILLIS: Weight = WEIGHT_PER_SECOND / 1000; // 1_000_000_000 - pub const WEIGHT_PER_MICROS: Weight = WEIGHT_PER_MILLIS / 1000; // 1_000_000 - pub const WEIGHT_PER_NANOS: Weight = WEIGHT_PER_MICROS / 1000; // 1_000 + pub const WEIGHT_PER_SECOND: Weight = Weight::from_ref_time(1_000_000_000_000); + pub const WEIGHT_PER_MILLIS: Weight = Weight::from_ref_time(1_000_000_000); + pub const WEIGHT_PER_MICROS: Weight = Weight::from_ref_time(1_000_000); + pub const WEIGHT_PER_NANOS: Weight = Weight::from_ref_time(1_000); // Expose the Block and Extrinsic base weights. pub use super::{block_weights::BlockExecutionWeight, extrinsic_weights::ExtrinsicBaseWeight}; @@ -204,6 +204,12 @@ impl Default for Pays { } } +impl From for PostDispatchInfo { + fn from(pays_fee: Pays) -> Self { + Self { actual_weight: None, pays_fee } + } +} + /// A generalized group of dispatch types. /// /// NOTE whenever upgrading the enum make sure to also update @@ -359,25 +365,6 @@ pub fn extract_actual_pays_fee(result: &DispatchResultWithPostInfo, info: &Dispa .pays_fee(info) } -impl From<(Option, Pays)> for PostDispatchInfo { - fn from(post_weight_info: (Option, Pays)) -> Self { - let (actual_weight, pays_fee) = post_weight_info; - Self { actual_weight, pays_fee } - } -} - -impl From for PostDispatchInfo { - fn from(pays_fee: Pays) -> Self { - Self { actual_weight: None, pays_fee } - } -} - -impl From> for PostDispatchInfo { - fn from(actual_weight: Option) -> Self { - Self { actual_weight, pays_fee: Default::default() } - } -} - impl From<()> for PostDispatchInfo { fn from(_: ()) -> Self { Self { actual_weight: None, pays_fee: Default::default() } @@ -407,7 +394,7 @@ pub trait WithPostDispatchInfo { /// # Example /// /// ```ignore - /// let who = ensure_signed(origin).map_err(|e| e.with_weight(100))?; + /// let who = ensure_signed(origin).map_err(|e| e.with_weight(Weight::from_ref_time(100)))?; /// ensure!(who == me, Error::::NotMe.with_weight(200_000)); /// ``` fn with_weight(self, actual_weight: Weight) -> DispatchErrorWithPostInfo; @@ -428,78 +415,6 @@ where } } -impl WeighData for Weight { - fn weigh_data(&self, _: T) -> Weight { - *self - } -} - -impl ClassifyDispatch for Weight { - fn classify_dispatch(&self, _: T) -> DispatchClass { - DispatchClass::Normal - } -} - -impl PaysFee for Weight { - fn pays_fee(&self, _: T) -> Pays { - Pays::Yes - } -} - -impl WeighData for (Weight, DispatchClass, Pays) { - fn weigh_data(&self, _: T) -> Weight { - self.0 - } -} - -impl ClassifyDispatch for (Weight, DispatchClass, Pays) { - fn classify_dispatch(&self, _: T) -> DispatchClass { - self.1 - } -} - -impl PaysFee for (Weight, DispatchClass, Pays) { - fn pays_fee(&self, _: T) -> Pays { - self.2 - } -} - -impl WeighData for (Weight, DispatchClass) { - fn weigh_data(&self, _: T) -> Weight { - self.0 - } -} - -impl ClassifyDispatch for (Weight, DispatchClass) { - fn classify_dispatch(&self, _: T) -> DispatchClass { - self.1 - } -} - -impl PaysFee for (Weight, DispatchClass) { - fn pays_fee(&self, _: T) -> Pays { - Pays::Yes - } -} - -impl WeighData for (Weight, Pays) { - fn weigh_data(&self, _: T) -> Weight { - self.0 - } -} - -impl ClassifyDispatch for (Weight, Pays) { - fn classify_dispatch(&self, _: T) -> DispatchClass { - DispatchClass::Normal - } -} - -impl PaysFee for (Weight, Pays) { - fn pays_fee(&self, _: T) -> Pays { - self.1 - } -} - /// Implementation for unchecked extrinsic. impl GetDispatchInfo for UncheckedExtrinsic @@ -527,30 +442,37 @@ where impl GetDispatchInfo for sp_runtime::testing::TestXt { fn get_dispatch_info(&self) -> DispatchInfo { // for testing: weight == size. - DispatchInfo { weight: self.encode().len() as _, pays_fee: Pays::Yes, ..Default::default() } + DispatchInfo { + weight: Weight::from_ref_time(self.encode().len() as _), + pays_fee: Pays::Yes, + ..Default::default() + } } } /// The weight of database operations that the runtime can invoke. +/// +/// NOTE: This is currently only measured in computational time, and will probably +/// be updated all together once proof size is accounted for. #[derive(Clone, Copy, Eq, PartialEq, Default, RuntimeDebug, Encode, Decode, TypeInfo)] pub struct RuntimeDbWeight { - pub read: Weight, - pub write: Weight, + pub read: RefTimeWeight, + pub write: RefTimeWeight, } impl RuntimeDbWeight { - pub fn reads(self, r: Weight) -> Weight { - self.read.saturating_mul(r) + pub fn reads(self, r: u64) -> Weight { + Weight::from_ref_time(self.read.saturating_mul(r)) } - pub fn writes(self, w: Weight) -> Weight { - self.write.saturating_mul(w) + pub fn writes(self, w: u64) -> Weight { + Weight::from_ref_time(self.write.saturating_mul(w)) } - pub fn reads_writes(self, r: Weight, w: Weight) -> Weight { + pub fn reads_writes(self, r: u64, w: u64) -> Weight { let read_weight = self.read.saturating_mul(r); let write_weight = self.write.saturating_mul(w); - read_weight.saturating_add(write_weight) + Weight::from_ref_time(read_weight.saturating_add(write_weight)) } } @@ -618,7 +540,8 @@ where Self::polynomial() .iter() .fold(Self::Balance::saturated_from(0u32), |mut acc, args| { - let w = Self::Balance::saturated_from(*weight).saturating_pow(args.degree.into()); + let w = Self::Balance::saturated_from(weight.ref_time()) + .saturating_pow(args.degree.into()); // The sum could get negative. Therefore we only sum with the accumulator. // The Perbill Mul implementation is non overflowing. @@ -648,7 +571,7 @@ where type Balance = T; fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(*weight) + Self::Balance::saturated_from(weight.ref_time()) } } @@ -671,7 +594,7 @@ where type Balance = T; fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(*weight).saturating_mul(M::get()) + Self::Balance::saturated_from(weight.ref_time()).saturating_mul(M::get()) } } @@ -727,7 +650,7 @@ impl PerDispatchClass { impl PerDispatchClass { /// Returns the total weight consumed by all extrinsics in the block. pub fn total(&self) -> Weight { - let mut sum = 0; + let mut sum = Weight::new(); for class in DispatchClass::all() { sum = sum.saturating_add(*self.get(*class)); } @@ -744,7 +667,7 @@ impl PerDispatchClass { /// occur. pub fn checked_add(&mut self, weight: Weight, class: DispatchClass) -> Result<(), ()> { let value = self.get_mut(class); - *value = value.checked_add(weight).ok_or(())?; + *value = value.checked_add(&weight).ok_or(())?; Ok(()) } @@ -804,16 +727,16 @@ mod tests { fn f03(_origin) { unimplemented!(); } // weight = a x 10 + b - #[weight = ((_a * 10 + _eb * 1) as Weight, DispatchClass::Normal, Pays::Yes)] + #[weight = ((_a * 10 + _eb * 1) as RefTimeWeight, DispatchClass::Normal, Pays::Yes)] fn f11(_origin, _a: u32, _eb: u32) { unimplemented!(); } #[weight = (0, DispatchClass::Operational, Pays::Yes)] fn f12(_origin, _a: u32, _eb: u32) { unimplemented!(); } - #[weight = T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) + 10_000] + #[weight = T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) + Weight::from_ref_time(10_000)] fn f20(_origin) { unimplemented!(); } - #[weight = T::DbWeight::get().reads_writes(6, 5) + 40_000] + #[weight = T::DbWeight::get().reads_writes(6, 5) + Weight::from_ref_time(40_000)] fn f21(_origin) { unimplemented!(); } } @@ -823,80 +746,98 @@ mod tests { fn weights_are_correct() { // #[weight = 1000] let info = Call::::f00 {}.get_dispatch_info(); - assert_eq!(info.weight, 1000); + assert_eq!(info.weight, Weight::from_ref_time(1000)); assert_eq!(info.class, DispatchClass::Normal); assert_eq!(info.pays_fee, Pays::Yes); // #[weight = (1000, DispatchClass::Mandatory)] let info = Call::::f01 {}.get_dispatch_info(); - assert_eq!(info.weight, 1000); + assert_eq!(info.weight, Weight::from_ref_time(1000)); assert_eq!(info.class, DispatchClass::Mandatory); assert_eq!(info.pays_fee, Pays::Yes); // #[weight = (1000, Pays::No)] let info = Call::::f02 {}.get_dispatch_info(); - assert_eq!(info.weight, 1000); + assert_eq!(info.weight, Weight::from_ref_time(1000)); assert_eq!(info.class, DispatchClass::Normal); assert_eq!(info.pays_fee, Pays::No); // #[weight = (1000, DispatchClass::Operational, Pays::No)] let info = Call::::f03 {}.get_dispatch_info(); - assert_eq!(info.weight, 1000); + assert_eq!(info.weight, Weight::from_ref_time(1000)); assert_eq!(info.class, DispatchClass::Operational); assert_eq!(info.pays_fee, Pays::No); // #[weight = ((_a * 10 + _eb * 1) as Weight, DispatchClass::Normal, Pays::Yes)] let info = Call::::f11 { _a: 13, _eb: 20 }.get_dispatch_info(); - assert_eq!(info.weight, 150); // 13*10 + 20 + assert_eq!(info.weight, Weight::from_ref_time(150)); // 13*10 + 20 assert_eq!(info.class, DispatchClass::Normal); assert_eq!(info.pays_fee, Pays::Yes); // #[weight = (0, DispatchClass::Operational, Pays::Yes)] let info = Call::::f12 { _a: 10, _eb: 20 }.get_dispatch_info(); - assert_eq!(info.weight, 0); + assert_eq!(info.weight, Weight::from_ref_time(0)); assert_eq!(info.class, DispatchClass::Operational); assert_eq!(info.pays_fee, Pays::Yes); // #[weight = T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) + 10_000] let info = Call::::f20 {}.get_dispatch_info(); - assert_eq!(info.weight, 12300); // 100*3 + 1000*2 + 10_1000 + assert_eq!(info.weight, Weight::from_ref_time(12300)); // 100*3 + 1000*2 + 10_1000 assert_eq!(info.class, DispatchClass::Normal); assert_eq!(info.pays_fee, Pays::Yes); // #[weight = T::DbWeight::get().reads_writes(6, 5) + 40_000] let info = Call::::f21 {}.get_dispatch_info(); - assert_eq!(info.weight, 45600); // 100*6 + 1000*5 + 40_1000 + assert_eq!(info.weight, Weight::from_ref_time(45600)); // 100*6 + 1000*5 + 40_1000 assert_eq!(info.class, DispatchClass::Normal); assert_eq!(info.pays_fee, Pays::Yes); } #[test] fn extract_actual_weight_works() { - let pre = DispatchInfo { weight: 1000, ..Default::default() }; - assert_eq!(extract_actual_weight(&Ok(Some(7).into()), &pre), 7); - assert_eq!(extract_actual_weight(&Ok(Some(1000).into()), &pre), 1000); - assert_eq!(extract_actual_weight(&Err(DispatchError::BadOrigin.with_weight(9)), &pre), 9); + let pre = DispatchInfo { weight: Weight::from_ref_time(1000), ..Default::default() }; + assert_eq!(extract_actual_weight(&Ok(Some(7).into()), &pre), Weight::from_ref_time(7)); + assert_eq!( + extract_actual_weight(&Ok(Some(1000).into()), &pre), + Weight::from_ref_time(1000) + ); + assert_eq!( + extract_actual_weight( + &Err(DispatchError::BadOrigin.with_weight(Weight::from_ref_time(9))), + &pre + ), + Weight::from_ref_time(9) + ); } #[test] fn extract_actual_weight_caps_at_pre_weight() { - let pre = DispatchInfo { weight: 1000, ..Default::default() }; - assert_eq!(extract_actual_weight(&Ok(Some(1250).into()), &pre), 1000); + let pre = DispatchInfo { weight: Weight::from_ref_time(1000), ..Default::default() }; assert_eq!( - extract_actual_weight(&Err(DispatchError::BadOrigin.with_weight(1300)), &pre), - 1000 + extract_actual_weight(&Ok(Some(1250).into()), &pre), + Weight::from_ref_time(1000) + ); + assert_eq!( + extract_actual_weight( + &Err(DispatchError::BadOrigin.with_weight(Weight::from_ref_time(1300))), + &pre + ), + Weight::from_ref_time(1000), ); } #[test] fn extract_actual_pays_fee_works() { - let pre = DispatchInfo { weight: 1000, ..Default::default() }; + let pre = DispatchInfo { weight: Weight::from_ref_time(1000), ..Default::default() }; assert_eq!(extract_actual_pays_fee(&Ok(Some(7).into()), &pre), Pays::Yes); assert_eq!(extract_actual_pays_fee(&Ok(Some(1000).into()), &pre), Pays::Yes); assert_eq!(extract_actual_pays_fee(&Ok((Some(1000), Pays::Yes).into()), &pre), Pays::Yes); assert_eq!(extract_actual_pays_fee(&Ok((Some(1000), Pays::No).into()), &pre), Pays::No); assert_eq!( - extract_actual_pays_fee(&Err(DispatchError::BadOrigin.with_weight(9)), &pre), + extract_actual_pays_fee( + &Err(DispatchError::BadOrigin.with_weight(Weight::from_ref_time(9))), + &pre + ), Pays::Yes ); assert_eq!( @@ -910,7 +851,11 @@ mod tests { Pays::No ); - let pre = DispatchInfo { weight: 1000, pays_fee: Pays::No, ..Default::default() }; + let pre = DispatchInfo { + weight: Weight::from_ref_time(1000), + pays_fee: Pays::No, + ..Default::default() + }; assert_eq!(extract_actual_pays_fee(&Ok(Some(7).into()), &pre), Pays::No); assert_eq!(extract_actual_pays_fee(&Ok(Some(1000).into()), &pre), Pays::No); assert_eq!(extract_actual_pays_fee(&Ok((Some(1000), Pays::Yes).into()), &pre), Pays::No); @@ -956,40 +901,52 @@ mod tests { #[test] fn polynomial_works() { // 100^3/2=500000 100^2*(2+1/3)=23333 700 -10000 - assert_eq!(Poly::weight_to_fee(&100), 514033); + assert_eq!(Poly::weight_to_fee(&Weight::from_ref_time(100)), 514033); // 10123^3/2=518677865433 10123^2*(2+1/3)=239108634 70861 -10000 - assert_eq!(Poly::weight_to_fee(&10_123), 518917034928); + assert_eq!(Poly::weight_to_fee(&Weight::from_ref_time(10_123)), 518917034928); } #[test] fn polynomial_does_not_underflow() { - assert_eq!(Poly::weight_to_fee(&0), 0); - assert_eq!(Poly::weight_to_fee(&10), 0); + assert_eq!(Poly::weight_to_fee(&Weight::zero()), 0); + assert_eq!(Poly::weight_to_fee(&Weight::from_ref_time(10)), 0); } #[test] fn polynomial_does_not_overflow() { - assert_eq!(Poly::weight_to_fee(&Weight::max_value()), Balance::max_value() - 10_000); + assert_eq!(Poly::weight_to_fee(&Weight::MAX), Balance::max_value() - 10_000); } #[test] fn identity_fee_works() { - assert_eq!(IdentityFee::::weight_to_fee(&0), 0); - assert_eq!(IdentityFee::::weight_to_fee(&50), 50); - assert_eq!( - IdentityFee::::weight_to_fee(&Weight::max_value()), - Balance::max_value() - ); + assert_eq!(IdentityFee::::weight_to_fee(&Weight::zero()), 0); + assert_eq!(IdentityFee::::weight_to_fee(&Weight::from_ref_time(50)), 50); + assert_eq!(IdentityFee::::weight_to_fee(&Weight::MAX), Balance::max_value()); } #[test] fn constant_fee_works() { use crate::traits::ConstU128; - assert_eq!(ConstantMultiplier::>::weight_to_fee(&0), 0); - assert_eq!(ConstantMultiplier::>::weight_to_fee(&50), 500); - assert_eq!(ConstantMultiplier::>::weight_to_fee(&16), 16384); assert_eq!( - ConstantMultiplier::>::weight_to_fee(&2), + ConstantMultiplier::>::weight_to_fee(&Weight::zero()), + 0 + ); + assert_eq!( + ConstantMultiplier::>::weight_to_fee(&Weight::from_ref_time( + 50 + )), + 500 + ); + assert_eq!( + ConstantMultiplier::>::weight_to_fee(&Weight::from_ref_time( + 16 + )), + 16384 + ); + assert_eq!( + ConstantMultiplier::>::weight_to_fee( + &Weight::from_ref_time(2) + ), u128::MAX ); } diff --git a/frame/support/src/weights/block_weights.rs b/frame/support/src/weights/block_weights.rs index b86334514af2f..93a80d12db96b 100644 --- a/frame/support/src/weights/block_weights.rs +++ b/frame/support/src/weights/block_weights.rs @@ -53,7 +53,7 @@ parameter_types! { /// 99th: 5_489_273 /// 95th: 5_433_314 /// 75th: 5_354_812 - pub const BlockExecutionWeight: Weight = 5_346_284 * WEIGHT_PER_NANOS; + pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.scalar_saturating_mul(5_346_284); } #[cfg(test)] diff --git a/frame/support/src/weights/extrinsic_weights.rs b/frame/support/src/weights/extrinsic_weights.rs index b8a52c164d8fe..d223eb7c10efc 100644 --- a/frame/support/src/weights/extrinsic_weights.rs +++ b/frame/support/src/weights/extrinsic_weights.rs @@ -53,7 +53,7 @@ parameter_types! { /// 99th: 86_924 /// 95th: 86_828 /// 75th: 86_347 - pub const ExtrinsicBaseWeight: Weight = 86_298 * WEIGHT_PER_NANOS; + pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.scalar_saturating_mul(86_298); } #[cfg(test)] diff --git a/frame/support/src/weights/paritydb_weights.rs b/frame/support/src/weights/paritydb_weights.rs index 572187ba78a92..f498991729d7a 100644 --- a/frame/support/src/weights/paritydb_weights.rs +++ b/frame/support/src/weights/paritydb_weights.rs @@ -25,8 +25,8 @@ pub mod constants { /// ParityDB can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 8_000 * constants::WEIGHT_PER_NANOS, - write: 50_000 * constants::WEIGHT_PER_NANOS, + read: 8_000 * constants::WEIGHT_PER_NANOS.ref_time(), + write: 50_000 * constants::WEIGHT_PER_NANOS.ref_time(), }; } diff --git a/frame/support/src/weights/rocksdb_weights.rs b/frame/support/src/weights/rocksdb_weights.rs index f37964dcbd825..67571c4723f94 100644 --- a/frame/support/src/weights/rocksdb_weights.rs +++ b/frame/support/src/weights/rocksdb_weights.rs @@ -25,8 +25,8 @@ pub mod constants { /// By default, Substrate uses RocksDB, so this will be the weight used throughout /// the runtime. pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 25_000 * constants::WEIGHT_PER_NANOS, - write: 100_000 * constants::WEIGHT_PER_NANOS, + read: 25_000 * constants::WEIGHT_PER_NANOS.ref_time(), + write: 100_000 * constants::WEIGHT_PER_NANOS.ref_time(), }; } diff --git a/frame/support/src/weights/weight_v2.rs b/frame/support/src/weights/weight_v2.rs new file mode 100644 index 0000000000000..d02aac3268838 --- /dev/null +++ b/frame/support/src/weights/weight_v2.rs @@ -0,0 +1,483 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 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. + +use codec::{CompactAs, Decode, Encode, MaxEncodedLen}; +use core::ops::{Add, AddAssign, Div, Mul, Sub, SubAssign}; +use sp_runtime::{ + traits::{Bounded, CheckedAdd, CheckedSub, One, Zero}, + Perquintill, RuntimeDebug, +}; + +use super::*; + +/// The unit of measurement for computational time spent when executing runtime logic on reference +/// hardware. +pub type RefTimeWeight = u64; + +#[derive( + Encode, + Decode, + MaxEncodedLen, + TypeInfo, + Eq, + PartialEq, + Copy, + Clone, + RuntimeDebug, + Default, + Ord, + PartialOrd, + CompactAs, +)] +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +pub struct Weight { + /// The weight of computational time used based on some reference hardware. + ref_time: RefTimeWeight, +} + +impl Weight { + /// Create a new Weight with zero. + pub const fn new() -> Self { + Self { ref_time: 0 } + } + + /// Set the reference time part of the weight. + pub const fn set_ref_time(mut self, c: RefTimeWeight) -> Self { + self.ref_time = c; + self + } + + /// Return the reference time part of the weight. + pub const fn ref_time(&self) -> RefTimeWeight { + self.ref_time + } + + /// Return a mutable reference time part of the weight. + pub fn ref_time_mut(&mut self) -> &mut RefTimeWeight { + &mut self.ref_time + } + + pub const MAX: Self = Self { ref_time: RefTimeWeight::MAX }; + + /// Get the conservative min of `self` and `other` weight. + pub fn min(&self, other: Self) -> Self { + Self { ref_time: self.ref_time.min(other.ref_time) } + } + + /// Get the aggressive max of `self` and `other` weight. + pub fn max(&self, other: Self) -> Self { + Self { ref_time: self.ref_time.max(other.ref_time) } + } + + /// Try to add some `other` weight while upholding the `limit`. + pub fn try_add(&self, other: &Self, limit: &Self) -> Option { + let total = self.checked_add(other)?; + if total.ref_time > limit.ref_time { + None + } else { + Some(total) + } + } + + /// Construct with reference time weight. + pub const fn from_ref_time(ref_time: RefTimeWeight) -> Self { + Self { ref_time } + } + + pub fn checked_mul(self, rhs: u64) -> Option { + let ref_time = self.ref_time.checked_mul(rhs)?; + Some(Self { ref_time }) + } + + pub fn checked_div(self, rhs: u64) -> Option { + let ref_time = self.ref_time.checked_div(rhs)?; + Some(Self { ref_time }) + } + + pub const fn scalar_saturating_mul(self, rhs: u64) -> Self { + Self { ref_time: self.ref_time.saturating_mul(rhs) } + } + + pub const fn scalar_div(self, rhs: u64) -> Self { + Self { ref_time: self.ref_time / rhs } + } +} + +impl Zero for Weight { + fn zero() -> Self { + Self::zero() + } + + fn is_zero(&self) -> bool { + self.ref_time == 0 + } +} + +impl One for Weight { + fn one() -> Self { + Self::one() + } +} + +impl Add for Weight { + type Output = Self; + fn add(self, rhs: Self) -> Self { + Self { ref_time: self.ref_time + rhs.ref_time } + } +} + +impl Sub for Weight { + type Output = Self; + fn sub(self, rhs: Self) -> Self { + Self { ref_time: self.ref_time - rhs.ref_time } + } +} + +impl Mul for Weight { + type Output = Self; + fn mul(self, b: Self) -> Self { + Self { ref_time: b.ref_time * self.ref_time } + } +} + +impl Mul for Weight +where + T: Mul + Copy, +{ + type Output = Self; + fn mul(self, b: T) -> Self { + Self { ref_time: b * self.ref_time } + } +} + +impl Mul for Perbill { + type Output = Weight; + fn mul(self, b: Weight) -> Weight { + Weight { ref_time: self * b.ref_time } + } +} + +impl Mul for Perquintill { + type Output = Weight; + fn mul(self, b: Weight) -> Weight { + Weight { ref_time: self * b.ref_time } + } +} + +impl Mul for u64 { + type Output = Weight; + fn mul(self, b: Weight) -> Weight { + Weight { ref_time: self * b.ref_time } + } +} + +impl Div for Weight +where + u64: Div, + T: Copy, +{ + type Output = Self; + fn div(self, b: T) -> Self { + Self { ref_time: self.ref_time / b } + } +} + +impl Saturating for Weight { + fn saturating_add(self, rhs: Self) -> Self { + self.saturating_add(rhs) + } + + fn saturating_sub(self, rhs: Self) -> Self { + self.saturating_sub(rhs) + } + + fn saturating_mul(self, rhs: Self) -> Self { + self.saturating_mul(rhs) + } + + fn saturating_pow(self, exp: usize) -> Self { + self.saturating_pow(exp) + } +} + +impl CheckedAdd for Weight { + fn checked_add(&self, rhs: &Self) -> Option { + self.checked_add(rhs) + } +} + +impl CheckedSub for Weight { + fn checked_sub(&self, rhs: &Self) -> Option { + self.checked_sub(rhs) + } +} + +impl PaysFee for (Weight, DispatchClass, Pays) { + fn pays_fee(&self, _: T) -> Pays { + self.2 + } +} + +impl WeighData for (Weight, DispatchClass) { + fn weigh_data(&self, args: T) -> Weight { + return self.0.weigh_data(args) + } +} + +impl WeighData for (Weight, DispatchClass, Pays) { + fn weigh_data(&self, args: T) -> Weight { + return self.0.weigh_data(args) + } +} + +impl ClassifyDispatch for (Weight, DispatchClass) { + fn classify_dispatch(&self, _: T) -> DispatchClass { + self.1 + } +} + +impl PaysFee for (Weight, DispatchClass) { + fn pays_fee(&self, _: T) -> Pays { + Pays::Yes + } +} + +impl WeighData for (Weight, Pays) { + fn weigh_data(&self, args: T) -> Weight { + return self.0.weigh_data(args) + } +} + +impl ClassifyDispatch for (Weight, Pays) { + fn classify_dispatch(&self, _: T) -> DispatchClass { + DispatchClass::Normal + } +} + +impl PaysFee for (Weight, Pays) { + fn pays_fee(&self, _: T) -> Pays { + self.1 + } +} + +impl From<(Option, Pays)> for PostDispatchInfo { + fn from(post_weight_info: (Option, Pays)) -> Self { + let (actual_weight, pays_fee) = post_weight_info; + Self { actual_weight, pays_fee } + } +} + +impl From> for PostDispatchInfo { + fn from(actual_weight: Option) -> Self { + Self { actual_weight, pays_fee: Default::default() } + } +} + +impl WeighData for Weight { + fn weigh_data(&self, _: T) -> Weight { + return *self + } +} + +impl ClassifyDispatch for Weight { + fn classify_dispatch(&self, _: T) -> DispatchClass { + DispatchClass::Normal + } +} + +impl PaysFee for Weight { + fn pays_fee(&self, _: T) -> Pays { + Pays::Yes + } +} + +impl ClassifyDispatch for (Weight, DispatchClass, Pays) { + fn classify_dispatch(&self, _: T) -> DispatchClass { + self.1 + } +} + +impl core::fmt::Display for Weight { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "Weight(ref_time: {})", self.ref_time) + } +} + +impl Bounded for Weight { + fn min_value() -> Self { + Zero::zero() + } + fn max_value() -> Self { + Self::MAX + } +} + +impl AddAssign for Weight { + fn add_assign(&mut self, other: Self) { + *self = Self { ref_time: self.ref_time + other.ref_time }; + } +} + +impl SubAssign for Weight { + fn sub_assign(&mut self, other: Self) { + *self = Self { ref_time: self.ref_time - other.ref_time }; + } +} + +impl sp_runtime::traits::Printable for Weight { + fn print(&self) { + self.ref_time().print() + } +} + +// Re-export common functions so you do not need to import trait. +impl Weight { + pub const fn zero() -> Self { + Self { ref_time: 0 } + } + + pub const fn one() -> Self { + Self { ref_time: 1 } + } + + pub const fn saturating_add(self, rhs: Self) -> Self { + Self { ref_time: self.ref_time.saturating_add(rhs.ref_time) } + } + + pub const fn saturating_sub(self, rhs: Self) -> Self { + Self { ref_time: self.ref_time.saturating_sub(rhs.ref_time) } + } + + pub const fn saturating_mul(self, rhs: Self) -> Self { + Self { ref_time: self.ref_time.saturating_mul(rhs.ref_time) } + } + + pub const fn saturating_pow(self, exp: usize) -> Self { + Self { ref_time: self.ref_time.saturating_pow(exp as u32) } + } + + pub const fn checked_add(&self, rhs: &Self) -> Option { + match self.ref_time.checked_add(rhs.ref_time) { + Some(ref_time) => Some(Self { ref_time }), + None => None, + } + } + + pub const fn checked_sub(&self, rhs: &Self) -> Option { + match self.ref_time.checked_sub(rhs.ref_time) { + Some(ref_time) => Some(Self { ref_time }), + None => None, + } + } +} + +// TODO: Eventually remove these + +impl From> for PostDispatchInfo { + fn from(maybe_actual_computation: Option) -> Self { + let actual_weight = match maybe_actual_computation { + Some(actual_computation) => Some(Weight::new().set_ref_time(actual_computation)), + None => None, + }; + Self { actual_weight, pays_fee: Default::default() } + } +} + +impl From<(Option, Pays)> for PostDispatchInfo { + fn from(post_weight_info: (Option, Pays)) -> Self { + let (maybe_actual_time, pays_fee) = post_weight_info; + let actual_weight = match maybe_actual_time { + Some(actual_time) => Some(Weight::new().set_ref_time(actual_time)), + None => None, + }; + Self { actual_weight, pays_fee } + } +} + +impl WeighData for RefTimeWeight { + fn weigh_data(&self, _: T) -> Weight { + return Weight::new().set_ref_time(*self) + } +} + +impl ClassifyDispatch for RefTimeWeight { + fn classify_dispatch(&self, _: T) -> DispatchClass { + DispatchClass::Normal + } +} + +impl PaysFee for RefTimeWeight { + fn pays_fee(&self, _: T) -> Pays { + Pays::Yes + } +} + +impl WeighData for (RefTimeWeight, DispatchClass, Pays) { + fn weigh_data(&self, args: T) -> Weight { + return self.0.weigh_data(args) + } +} + +impl ClassifyDispatch for (RefTimeWeight, DispatchClass, Pays) { + fn classify_dispatch(&self, _: T) -> DispatchClass { + self.1 + } +} + +impl PaysFee for (RefTimeWeight, DispatchClass, Pays) { + fn pays_fee(&self, _: T) -> Pays { + self.2 + } +} + +impl WeighData for (RefTimeWeight, DispatchClass) { + fn weigh_data(&self, args: T) -> Weight { + return self.0.weigh_data(args) + } +} + +impl ClassifyDispatch for (RefTimeWeight, DispatchClass) { + fn classify_dispatch(&self, _: T) -> DispatchClass { + self.1 + } +} + +impl PaysFee for (RefTimeWeight, DispatchClass) { + fn pays_fee(&self, _: T) -> Pays { + Pays::Yes + } +} + +impl WeighData for (RefTimeWeight, Pays) { + fn weigh_data(&self, args: T) -> Weight { + return self.0.weigh_data(args) + } +} + +impl ClassifyDispatch for (RefTimeWeight, Pays) { + fn classify_dispatch(&self, _: T) -> DispatchClass { + DispatchClass::Normal + } +} + +impl PaysFee for (RefTimeWeight, Pays) { + fn pays_fee(&self, _: T) -> Pays { + self.1 + } +} + +// END TODO diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index d388127f29abd..aed98579a0fd8 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -503,17 +503,25 @@ fn call_encode_is_correct_and_decode_works() { fn call_weight_should_attach_to_call_enum() { use frame_support::{ dispatch::{DispatchInfo, GetDispatchInfo}, - weights::{DispatchClass, Pays}, + weights::{DispatchClass, Pays, Weight}, }; // operational. assert_eq!( module3::Call::::operational {}.get_dispatch_info(), - DispatchInfo { weight: 5, class: DispatchClass::Operational, pays_fee: Pays::Yes }, + DispatchInfo { + weight: Weight::from_ref_time(5), + class: DispatchClass::Operational, + pays_fee: Pays::Yes + }, ); // custom basic assert_eq!( module3::Call::::aux_4 {}.get_dispatch_info(), - DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: Pays::Yes }, + DispatchInfo { + weight: Weight::from_ref_time(3), + class: DispatchClass::Normal, + pays_fee: Pays::Yes + }, ); } diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 497b7bb04c36a..907a52f1184cc 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -23,7 +23,7 @@ use frame_support::{ ConstU32, GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade, PalletError, PalletInfoAccess, StorageVersion, }, - weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays, RuntimeDbWeight}, + weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays, RuntimeDbWeight, Weight}, }; use scale_info::{meta_type, TypeInfo}; use sp_io::{ @@ -165,7 +165,7 @@ pub mod pallet { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType2); // Test for where clause Self::deposit_event(Event::Something(10)); - 10 + Weight::from_ref_time(10) } fn on_finalize(_: BlockNumberFor) { let _ = T::AccountId::from(SomeType1); // Test for where clause @@ -176,7 +176,7 @@ pub mod pallet { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType2); // Test for where clause Self::deposit_event(Event::Something(30)); - 30 + Weight::from_ref_time(30) } fn integrity_test() { let _ = T::AccountId::from(SomeType1); // Test for where clause @@ -190,7 +190,7 @@ pub mod pallet { T::AccountId: From + From + SomeAssociation1, { /// Doc comment put in metadata - #[pallet::weight(Weight::from(*_foo))] + #[pallet::weight(Weight::from_ref_time(*_foo as u64))] pub fn foo( origin: OriginFor, #[pallet::compact] _foo: u32, @@ -492,14 +492,14 @@ pub mod pallet2 { { fn on_initialize(_: BlockNumberFor) -> Weight { Self::deposit_event(Event::Something(11)); - 0 + Weight::zero() } fn on_finalize(_: BlockNumberFor) { Self::deposit_event(Event::Something(21)); } fn on_runtime_upgrade() -> Weight { Self::deposit_event(Event::Something(31)); - 0 + Weight::zero() } } @@ -668,7 +668,11 @@ fn call_expand() { let call_foo = pallet::Call::::foo { foo: 3, bar: 0 }; assert_eq!( call_foo.get_dispatch_info(), - DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: Pays::Yes } + DispatchInfo { + weight: frame_support::weights::Weight::from_ref_time(3), + class: DispatchClass::Normal, + pays_fee: Pays::Yes + } ); assert_eq!(call_foo.get_call_name(), "foo"); assert_eq!( @@ -1046,10 +1050,10 @@ fn pallet_hooks_expand() { TestExternalities::default().execute_with(|| { frame_system::Pallet::::set_block_number(1); - assert_eq!(AllPalletsWithoutSystem::on_initialize(1), 10); + assert_eq!(AllPalletsWithoutSystem::on_initialize(1), Weight::from_ref_time(10)); AllPalletsWithoutSystem::on_finalize(1); - assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), 30); + assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), Weight::from_ref_time(30)); assert_eq!( frame_system::Pallet::::events()[0].event, @@ -1085,10 +1089,16 @@ fn all_pallets_type_reversed_order_is_correct() { #[allow(deprecated)] { - assert_eq!(AllPalletsWithoutSystemReversed::on_initialize(1), 10); + assert_eq!( + AllPalletsWithoutSystemReversed::on_initialize(1), + Weight::from_ref_time(10) + ); AllPalletsWithoutSystemReversed::on_finalize(1); - assert_eq!(AllPalletsWithoutSystemReversed::on_runtime_upgrade(), 30); + assert_eq!( + AllPalletsWithoutSystemReversed::on_runtime_upgrade(), + Weight::from_ref_time(30) + ); } assert_eq!( @@ -1155,7 +1165,7 @@ fn migrate_from_pallet_version_to_storage_version() { >(&db_weight); // 4 pallets, 2 writes and every write costs 5 weight. - assert_eq!(4 * 2 * 5, weight); + assert_eq!(Weight::from_ref_time(4 * 2 * 5), weight); // All pallet versions should be removed assert!(sp_io::storage::get(&pallet_version_key(Example::name())).is_none()); diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index 9327f5b6a3304..4d597e24356c7 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -31,7 +31,10 @@ impl SomeAssociation for u64 { mod pallet_old { use super::SomeAssociation; use frame_support::{ - decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter, + decl_error, decl_event, decl_module, decl_storage, + traits::Get, + weights::{RefTimeWeight, Weight}, + Parameter, }; use frame_system::ensure_root; @@ -40,7 +43,7 @@ mod pallet_old { type Balance: Parameter + codec::HasCompact + From - + Into + + Into + Default + SomeAssociation; type Event: From> + Into<::Event>; @@ -75,7 +78,7 @@ mod pallet_old { fn deposit_event() = default; const SomeConst: T::Balance = T::SomeConst::get(); - #[weight = >::into(new_value.clone())] + #[weight = >::into(new_value.clone())] fn set_dummy(origin, #[compact] new_value: T::Balance) { ensure_root(origin)?; @@ -85,7 +88,7 @@ mod pallet_old { fn on_initialize(_n: T::BlockNumber) -> Weight { >::put(T::Balance::from(10)); - 10 + Weight::from_ref_time(10) } fn on_finalize(_n: T::BlockNumber) { @@ -113,7 +116,7 @@ pub mod pallet { type Balance: Parameter + codec::HasCompact + From - + Into + + Into + Default + MaybeSerializeDeserialize + SomeAssociation @@ -131,7 +134,7 @@ pub mod pallet { impl Hooks for Pallet { fn on_initialize(_n: T::BlockNumber) -> Weight { >::put(T::Balance::from(10)); - 10 + Weight::from_ref_time(10) } fn on_finalize(_n: T::BlockNumber) { @@ -141,7 +144,7 @@ pub mod pallet { #[pallet::call] impl Pallet { - #[pallet::weight(>::into(new_value.clone()))] + #[pallet::weight(>::into(new_value.clone()))] pub fn set_dummy( origin: OriginFor, #[pallet::compact] new_value: T::Balance, diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 3de45df223674..2fd6833eaa428 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -23,13 +23,16 @@ use frame_support::traits::{ConstU32, ConstU64}; mod pallet_old { use frame_support::{ - decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter, + decl_error, decl_event, decl_module, decl_storage, + traits::Get, + weights::{RefTimeWeight, Weight}, + Parameter, }; use frame_system::ensure_root; pub trait Config: frame_system::Config { type SomeConst: Get; - type Balance: Parameter + codec::HasCompact + From + Into + Default; + type Balance: Parameter + codec::HasCompact + From + Into + Default; type Event: From> + Into<::Event>; } @@ -62,7 +65,7 @@ mod pallet_old { fn deposit_event() = default; const SomeConst: T::Balance = T::SomeConst::get(); - #[weight = >::into(new_value.clone())] + #[weight = >::into(new_value.clone())] fn set_dummy(origin, #[compact] new_value: T::Balance) { ensure_root(origin)?; @@ -72,7 +75,7 @@ mod pallet_old { fn on_initialize(_n: T::BlockNumber) -> Weight { >::put(T::Balance::from(10)); - 10 + Weight::from_ref_time(10) } fn on_finalize(_n: T::BlockNumber) { @@ -99,7 +102,7 @@ pub mod pallet { type Balance: Parameter + codec::HasCompact + From - + Into + + Into + Default + MaybeSerializeDeserialize + scale_info::StaticTypeInfo; @@ -116,7 +119,7 @@ pub mod pallet { impl, I: 'static> Hooks for Pallet { fn on_initialize(_n: T::BlockNumber) -> Weight { >::put(T::Balance::from(10)); - 10 + Weight::from_ref_time(10) } fn on_finalize(_n: T::BlockNumber) { @@ -126,7 +129,7 @@ pub mod pallet { #[pallet::call] impl, I: 'static> Pallet { - #[pallet::weight(>::into(new_value.clone()))] + #[pallet::weight(>::into(new_value.clone()))] pub fn set_dummy( origin: OriginFor, #[pallet::compact] new_value: T::Balance, diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index f4ef5f802c44f..2ae910e73d87e 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -54,10 +54,10 @@ pub mod pallet { fn on_initialize(_: BlockNumberFor) -> Weight { if TypeId::of::() == TypeId::of::<()>() { Self::deposit_event(Event::Something(10)); - 10 + Weight::from_ref_time(10) } else { Self::deposit_event(Event::Something(11)); - 11 + Weight::from_ref_time(11) } } fn on_finalize(_: BlockNumberFor) { @@ -70,10 +70,10 @@ pub mod pallet { fn on_runtime_upgrade() -> Weight { if TypeId::of::() == TypeId::of::<()>() { Self::deposit_event(Event::Something(30)); - 30 + Weight::from_ref_time(30) } else { Self::deposit_event(Event::Something(31)); - 31 + Weight::from_ref_time(31) } } fn integrity_test() {} @@ -82,7 +82,7 @@ pub mod pallet { #[pallet::call] impl, I: 'static> Pallet { /// Doc comment put in metadata - #[pallet::weight(Weight::from(*_foo))] + #[pallet::weight(Weight::from_ref_time(*_foo as u64))] pub fn foo( origin: OriginFor, #[pallet::compact] _foo: u32, @@ -345,12 +345,18 @@ frame_support::construct_runtime!( } ); +use frame_support::weights::Weight; + #[test] fn call_expand() { let call_foo = pallet::Call::::foo { foo: 3 }; assert_eq!( call_foo.get_dispatch_info(), - DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: Pays::Yes } + DispatchInfo { + weight: Weight::from_ref_time(3), + class: DispatchClass::Normal, + pays_fee: Pays::Yes + } ); assert_eq!(call_foo.get_call_name(), "foo"); assert_eq!(pallet::Call::::get_call_names(), &["foo", "foo_storage_layer"]); @@ -358,7 +364,11 @@ fn call_expand() { let call_foo = pallet::Call::::foo { foo: 3 }; assert_eq!( call_foo.get_dispatch_info(), - DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: Pays::Yes } + DispatchInfo { + weight: Weight::from_ref_time(3), + class: DispatchClass::Normal, + pays_fee: Pays::Yes + } ); assert_eq!(call_foo.get_call_name(), "foo"); assert_eq!( @@ -651,10 +661,10 @@ fn pallet_hooks_expand() { TestExternalities::default().execute_with(|| { frame_system::Pallet::::set_block_number(1); - assert_eq!(AllPalletsWithoutSystem::on_initialize(1), 21); + assert_eq!(AllPalletsWithoutSystem::on_initialize(1), Weight::from_ref_time(21)); AllPalletsWithoutSystem::on_finalize(1); - assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), 61); + assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), Weight::from_ref_time(61)); assert_eq!( frame_system::Pallet::::events()[0].event, diff --git a/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.stderr b/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.stderr index 45cdfad67b8ae..e674e49eddbe5 100644 --- a/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.stderr +++ b/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.stderr @@ -28,7 +28,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied <&[(T,)] as EncodeLike>> <&[(T,)] as EncodeLike>> <&[T] as EncodeLike>> - and 278 others + and 279 others = note: required because of the requirements on the impl of `FullEncode` for `Bar` = note: required because of the requirements on the impl of `FullCodec` for `Bar` = note: required because of the requirements on the impl of `PartialStorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>` @@ -69,7 +69,7 @@ error[E0277]: the trait bound `Bar: TypeInfo` is not satisfied (A, B, C, D) (A, B, C, D, E) (A, B, C, D, E, F) - and 158 others + and 159 others = note: required because of the requirements on the impl of `StaticTypeInfo` for `Bar` = note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>` @@ -103,7 +103,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied <&[(T,)] as EncodeLike>> <&[(T,)] as EncodeLike>> <&[T] as EncodeLike>> - and 278 others + and 279 others = note: required because of the requirements on the impl of `FullEncode` for `Bar` = note: required because of the requirements on the impl of `FullCodec` for `Bar` = note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>` diff --git a/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.stderr b/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.stderr index d7441e8b18562..ecdc18263432e 100644 --- a/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.stderr +++ b/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.stderr @@ -28,7 +28,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied <&[(T,)] as EncodeLike>> <&[(T,)] as EncodeLike>> <&[T] as EncodeLike>> - and 278 others + and 279 others = note: required because of the requirements on the impl of `FullEncode` for `Bar` = note: required because of the requirements on the impl of `FullCodec` for `Bar` = note: required because of the requirements on the impl of `PartialStorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>` @@ -69,7 +69,7 @@ error[E0277]: the trait bound `Bar: TypeInfo` is not satisfied (A, B, C, D) (A, B, C, D, E) (A, B, C, D, E, F) - and 158 others + and 159 others = note: required because of the requirements on the impl of `StaticTypeInfo` for `Bar` = note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>` @@ -103,7 +103,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied <&[(T,)] as EncodeLike>> <&[(T,)] as EncodeLike>> <&[T] as EncodeLike>> - and 278 others + and 279 others = note: required because of the requirements on the impl of `FullEncode` for `Bar` = note: required because of the requirements on the impl of `FullCodec` for `Bar` = note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>` diff --git a/frame/support/test/tests/pallet_ui/storage_info_unsatisfied.stderr b/frame/support/test/tests/pallet_ui/storage_info_unsatisfied.stderr index 6c49e1220a3a5..d9cd20711403d 100644 --- a/frame/support/test/tests/pallet_ui/storage_info_unsatisfied.stderr +++ b/frame/support/test/tests/pallet_ui/storage_info_unsatisfied.stderr @@ -13,5 +13,5 @@ error[E0277]: the trait bound `Bar: MaxEncodedLen` is not satisfied (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5) (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6) (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7) - and 75 others + and 76 others = note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>` diff --git a/frame/support/test/tests/pallet_ui/storage_info_unsatisfied_nmap.stderr b/frame/support/test/tests/pallet_ui/storage_info_unsatisfied_nmap.stderr index 9a0731683a953..9a4e8d740cb2c 100644 --- a/frame/support/test/tests/pallet_ui/storage_info_unsatisfied_nmap.stderr +++ b/frame/support/test/tests/pallet_ui/storage_info_unsatisfied_nmap.stderr @@ -13,6 +13,6 @@ error[E0277]: the trait bound `Bar: MaxEncodedLen` is not satisfied (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5) (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6) (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7) - and 75 others + and 76 others = note: required because of the requirements on the impl of `KeyGeneratorMaxEncodedLen` for `Key` = note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageNMap<_GeneratedPrefixForStorageFoo, Key, u32>` diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 7ed8454668327..6415c3c0d2c07 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -54,7 +54,7 @@ frame_support::decl_module! { } fn on_initialize(_n: T::BlockNumber) -> frame_support::weights::Weight { - 0 + frame_support::weights::Weight::zero() } } } diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 0bc34fcbc5be2..017298dab3928 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -16,7 +16,10 @@ // limitations under the License. use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use frame_support::traits::{ConstU32, ConstU64}; +use frame_support::{ + traits::{ConstU32, ConstU64}, + weights::Weight, +}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -61,7 +64,7 @@ frame_support::construct_runtime!( frame_support::parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::with_sensible_defaults( - 4 * 1024 * 1024, Perbill::from_percent(75), + Weight::from_ref_time(4 * 1024 * 1024), Perbill::from_percent(75), ); pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength::max_with_normal_ratio( diff --git a/frame/system/src/extensions/check_mortality.rs b/frame/system/src/extensions/check_mortality.rs index 5090093fe168f..59a6e14aca175 100644 --- a/frame/system/src/extensions/check_mortality.rs +++ b/frame/system/src/extensions/check_mortality.rs @@ -101,7 +101,7 @@ impl SignedExtension for CheckMortality { mod tests { use super::*; use crate::mock::{new_test_ext, System, Test, CALL}; - use frame_support::weights::{DispatchClass, DispatchInfo, Pays}; + use frame_support::weights::{DispatchClass, DispatchInfo, Pays, Weight}; use sp_core::H256; #[test] @@ -126,8 +126,11 @@ mod tests { #[test] fn signed_ext_check_era_should_change_longevity() { new_test_ext().execute_with(|| { - let normal = - DispatchInfo { weight: 100, class: DispatchClass::Normal, pays_fee: Pays::Yes }; + let normal = DispatchInfo { + weight: Weight::from_ref_time(100), + class: DispatchClass::Normal, + pays_fee: Pays::Yes, + }; let len = 0_usize; let ext = ( crate::CheckWeight::::new(), diff --git a/frame/system/src/extensions/check_weight.rs b/frame/system/src/extensions/check_weight.rs index b59c36ecb53b5..b7232c430696d 100644 --- a/frame/system/src/extensions/check_weight.rs +++ b/frame/system/src/extensions/check_weight.rs @@ -19,7 +19,7 @@ use crate::{limits::BlockWeights, Config, Pallet}; use codec::{Decode, Encode}; use frame_support::{ traits::Get, - weights::{DispatchClass, DispatchInfo, PostDispatchInfo}, + weights::{DispatchClass, DispatchInfo, PostDispatchInfo, Weight}, }; use scale_info::TypeInfo; use sp_runtime::{ @@ -238,7 +238,7 @@ where } let unspent = post_info.calc_unspent(info); - if unspent > 0 { + if unspent > Weight::zero() { crate::BlockWeight::::mutate(|current_weight| { current_weight.sub(unspent, info.class); }) @@ -297,7 +297,7 @@ mod tests { fn check(call: impl FnOnce(&DispatchInfo, usize)) { new_test_ext().execute_with(|| { let max = DispatchInfo { - weight: Weight::max_value(), + weight: Weight::MAX, class: DispatchClass::Mandatory, ..Default::default() }; @@ -309,7 +309,7 @@ mod tests { check(|max, len| { assert_ok!(CheckWeight::::do_pre_dispatch(max, len)); - assert_eq!(System::block_weight().total(), Weight::max_value()); + assert_eq!(System::block_weight().total(), Weight::MAX); assert!(System::block_weight().total() > block_weight_limit()); }); check(|max, len| { @@ -321,7 +321,8 @@ mod tests { fn normal_extrinsic_limited_by_maximum_extrinsic_weight() { new_test_ext().execute_with(|| { let max = DispatchInfo { - weight: block_weights().get(DispatchClass::Normal).max_extrinsic.unwrap() + 1, + weight: block_weights().get(DispatchClass::Normal).max_extrinsic.unwrap() + + Weight::one(), class: DispatchClass::Normal, ..Default::default() }; @@ -347,7 +348,7 @@ mod tests { let okay = DispatchInfo { weight, class: DispatchClass::Operational, ..Default::default() }; let max = DispatchInfo { - weight: weight + 1, + weight: weight + Weight::one(), class: DispatchClass::Operational, ..Default::default() }; @@ -364,8 +365,8 @@ mod tests { #[test] fn register_extra_weight_unchecked_doesnt_care_about_limits() { new_test_ext().execute_with(|| { - System::register_extra_weight_unchecked(Weight::max_value(), DispatchClass::Normal); - assert_eq!(System::block_weight().total(), Weight::max_value()); + System::register_extra_weight_unchecked(Weight::MAX, DispatchClass::Normal); + assert_eq!(System::block_weight().total(), Weight::MAX); assert!(System::block_weight().total() > block_weight_limit()); }); } @@ -378,9 +379,10 @@ mod tests { // 10 is taken for block execution weight // So normal extrinsic can be 758 weight (-5 for base extrinsic weight) // And Operational can be 256 to produce a full block (-5 for base) - let max_normal = DispatchInfo { weight: 753, ..Default::default() }; + let max_normal = + DispatchInfo { weight: Weight::from_ref_time(753), ..Default::default() }; let rest_operational = DispatchInfo { - weight: 251, + weight: Weight::from_ref_time(251), class: DispatchClass::Operational, ..Default::default() }; @@ -388,9 +390,9 @@ mod tests { let len = 0_usize; assert_ok!(CheckWeight::::do_pre_dispatch(&max_normal, len)); - assert_eq!(System::block_weight().total(), 768); + assert_eq!(System::block_weight().total(), Weight::from_ref_time(768)); assert_ok!(CheckWeight::::do_pre_dispatch(&rest_operational, len)); - assert_eq!(block_weight_limit(), 1024); + assert_eq!(block_weight_limit(), Weight::from_ref_time(1024)); assert_eq!(System::block_weight().total(), block_weight_limit()); // Checking single extrinsic should not take current block weight into account. assert_eq!(CheckWeight::::check_extrinsic_weight(&rest_operational), Ok(())); @@ -401,9 +403,10 @@ mod tests { fn dispatch_order_does_not_effect_weight_logic() { new_test_ext().execute_with(|| { // We switch the order of `full_block_with_normal_and_operational` - let max_normal = DispatchInfo { weight: 753, ..Default::default() }; + let max_normal = + DispatchInfo { weight: Weight::from_ref_time(753), ..Default::default() }; let rest_operational = DispatchInfo { - weight: 251, + weight: Weight::from_ref_time(251), class: DispatchClass::Operational, ..Default::default() }; @@ -412,9 +415,9 @@ mod tests { assert_ok!(CheckWeight::::do_pre_dispatch(&rest_operational, len)); // Extra 15 here from block execution + base extrinsic weight - assert_eq!(System::block_weight().total(), 266); + assert_eq!(System::block_weight().total(), Weight::from_ref_time(266)); assert_ok!(CheckWeight::::do_pre_dispatch(&max_normal, len)); - assert_eq!(block_weight_limit(), 1024); + assert_eq!(block_weight_limit(), Weight::from_ref_time(1024)); assert_eq!(System::block_weight().total(), block_weight_limit()); }); } @@ -423,11 +426,14 @@ mod tests { fn operational_works_on_full_block() { new_test_ext().execute_with(|| { // An on_initialize takes up the whole block! (Every time!) - System::register_extra_weight_unchecked(Weight::max_value(), DispatchClass::Mandatory); - let dispatch_normal = - DispatchInfo { weight: 251, class: DispatchClass::Normal, ..Default::default() }; + System::register_extra_weight_unchecked(Weight::MAX, DispatchClass::Mandatory); + let dispatch_normal = DispatchInfo { + weight: Weight::from_ref_time(251), + class: DispatchClass::Normal, + ..Default::default() + }; let dispatch_operational = DispatchInfo { - weight: 251, + weight: Weight::from_ref_time(251), class: DispatchClass::Operational, ..Default::default() }; @@ -453,9 +459,9 @@ mod tests { #[test] fn signed_ext_check_weight_works_operational_tx() { new_test_ext().execute_with(|| { - let normal = DispatchInfo { weight: 100, ..Default::default() }; + let normal = DispatchInfo { weight: Weight::from_ref_time(100), ..Default::default() }; let op = DispatchInfo { - weight: 100, + weight: Weight::from_ref_time(100), class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -489,7 +495,7 @@ mod tests { fn signed_ext_check_weight_block_size_works() { new_test_ext().execute_with(|| { let normal = DispatchInfo::default(); - let normal_limit = normal_weight_limit() as usize; + let normal_limit = normal_weight_limit().ref_time() as usize; let reset_check_weight = |tx, s, f| { AllExtrinsicsLen::::put(0); let r = CheckWeight::(PhantomData).pre_dispatch(&1, CALL, tx, s); @@ -505,8 +511,11 @@ mod tests { reset_check_weight(&normal, normal_limit + 1, true); // Operational ones don't have this limit. - let op = - DispatchInfo { weight: 0, class: DispatchClass::Operational, pays_fee: Pays::Yes }; + let op = DispatchInfo { + weight: Weight::zero(), + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; reset_check_weight(&op, normal_limit, false); reset_check_weight(&op, normal_limit + 100, false); reset_check_weight(&op, 1024, false); @@ -518,12 +527,14 @@ mod tests { fn signed_ext_check_weight_works_normal_tx() { new_test_ext().execute_with(|| { let normal_limit = normal_weight_limit(); - let small = DispatchInfo { weight: 100, ..Default::default() }; + let small = DispatchInfo { weight: Weight::from_ref_time(100), ..Default::default() }; let base_extrinsic = block_weights().get(DispatchClass::Normal).base_extrinsic; let medium = DispatchInfo { weight: normal_limit - base_extrinsic, ..Default::default() }; - let big = - DispatchInfo { weight: normal_limit - base_extrinsic + 1, ..Default::default() }; + let big = DispatchInfo { + weight: normal_limit - base_extrinsic + Weight::one(), + ..Default::default() + }; let len = 0_usize; let reset_check_weight = |i, f, s| { @@ -538,9 +549,9 @@ mod tests { } }; - reset_check_weight(&small, false, 0); - reset_check_weight(&medium, false, 0); - reset_check_weight(&big, true, 1); + reset_check_weight(&small, false, Weight::zero()); + reset_check_weight(&medium, false, Weight::zero()); + reset_check_weight(&big, true, Weight::one()); }) } @@ -548,20 +559,26 @@ mod tests { fn signed_ext_check_weight_refund_works() { new_test_ext().execute_with(|| { // This is half of the max block weight - let info = DispatchInfo { weight: 512, ..Default::default() }; - let post_info = - PostDispatchInfo { actual_weight: Some(128), pays_fee: Default::default() }; + let info = DispatchInfo { weight: Weight::from_ref_time(512), ..Default::default() }; + let post_info = PostDispatchInfo { + actual_weight: Some(Weight::from_ref_time(128)), + pays_fee: Default::default(), + }; let len = 0_usize; let base_extrinsic = block_weights().get(DispatchClass::Normal).base_extrinsic; // We allow 75% for normal transaction, so we put 25% - extrinsic base weight BlockWeight::::mutate(|current_weight| { - current_weight.set(0, DispatchClass::Mandatory); - current_weight.set(256 - base_extrinsic, DispatchClass::Normal); + current_weight.set(Weight::zero(), DispatchClass::Mandatory); + current_weight + .set(Weight::from_ref_time(256) - base_extrinsic, DispatchClass::Normal); }); let pre = CheckWeight::(PhantomData).pre_dispatch(&1, CALL, &info, len).unwrap(); - assert_eq!(BlockWeight::::get().total(), info.weight + 256); + assert_eq!( + BlockWeight::::get().total(), + info.weight + Weight::from_ref_time(256) + ); assert_ok!(CheckWeight::::post_dispatch( Some(pre), @@ -570,27 +587,34 @@ mod tests { len, &Ok(()) )); - assert_eq!(BlockWeight::::get().total(), post_info.actual_weight.unwrap() + 256); + assert_eq!( + BlockWeight::::get().total(), + post_info.actual_weight.unwrap() + Weight::from_ref_time(256) + ); }) } #[test] fn signed_ext_check_weight_actual_weight_higher_than_max_is_capped() { new_test_ext().execute_with(|| { - let info = DispatchInfo { weight: 512, ..Default::default() }; - let post_info = - PostDispatchInfo { actual_weight: Some(700), pays_fee: Default::default() }; + let info = DispatchInfo { weight: Weight::from_ref_time(512), ..Default::default() }; + let post_info = PostDispatchInfo { + actual_weight: Some(Weight::from_ref_time(700)), + pays_fee: Default::default(), + }; let len = 0_usize; BlockWeight::::mutate(|current_weight| { - current_weight.set(0, DispatchClass::Mandatory); - current_weight.set(128, DispatchClass::Normal); + current_weight.set(Weight::zero(), DispatchClass::Mandatory); + current_weight.set(Weight::from_ref_time(128), DispatchClass::Normal); }); let pre = CheckWeight::(PhantomData).pre_dispatch(&1, CALL, &info, len).unwrap(); assert_eq!( BlockWeight::::get().total(), - info.weight + 128 + block_weights().get(DispatchClass::Normal).base_extrinsic, + info.weight + + Weight::from_ref_time(128) + + block_weights().get(DispatchClass::Normal).base_extrinsic, ); assert_ok!(CheckWeight::::post_dispatch( @@ -602,7 +626,9 @@ mod tests { )); assert_eq!( BlockWeight::::get().total(), - info.weight + 128 + block_weights().get(DispatchClass::Normal).base_extrinsic, + info.weight + + Weight::from_ref_time(128) + + block_weights().get(DispatchClass::Normal).base_extrinsic, ); }) } @@ -611,7 +637,7 @@ mod tests { fn zero_weight_extrinsic_still_has_base_weight() { new_test_ext().execute_with(|| { let weights = block_weights(); - let free = DispatchInfo { weight: 0, ..Default::default() }; + let free = DispatchInfo { weight: Weight::zero(), ..Default::default() }; let len = 0_usize; // Initial weight from `weights.base_block` @@ -630,9 +656,10 @@ mod tests { // Max block is 1024 // Max normal is 768 (75%) // Max mandatory is unlimited - let max_normal = DispatchInfo { weight: 753, ..Default::default() }; + let max_normal = + DispatchInfo { weight: Weight::from_ref_time(753), ..Default::default() }; let mandatory = DispatchInfo { - weight: 1019, + weight: Weight::from_ref_time(1019), class: DispatchClass::Mandatory, ..Default::default() }; @@ -640,10 +667,10 @@ mod tests { let len = 0_usize; assert_ok!(CheckWeight::::do_pre_dispatch(&max_normal, len)); - assert_eq!(System::block_weight().total(), 768); + assert_eq!(System::block_weight().total(), Weight::from_ref_time(768)); assert_ok!(CheckWeight::::do_pre_dispatch(&mandatory, len)); - assert_eq!(block_weight_limit(), 1024); - assert_eq!(System::block_weight().total(), 1024 + 768); + assert_eq!(block_weight_limit(), Weight::from_ref_time(1024)); + assert_eq!(System::block_weight().total(), Weight::from_ref_time(1024 + 768)); assert_eq!(CheckWeight::::check_extrinsic_weight(&mandatory), Ok(())); }); } @@ -652,30 +679,36 @@ mod tests { fn no_max_total_should_still_be_limited_by_max_block() { // given let maximum_weight = BlockWeights::builder() - .base_block(0) + .base_block(Weight::zero()) .for_class(DispatchClass::non_mandatory(), |w| { - w.base_extrinsic = 0; - w.max_total = Some(20); + w.base_extrinsic = Weight::zero(); + w.max_total = Some(Weight::from_ref_time(20)); }) .for_class(DispatchClass::Mandatory, |w| { - w.base_extrinsic = 0; - w.reserved = Some(5); + w.base_extrinsic = Weight::zero(); + w.reserved = Some(Weight::from_ref_time(5)); w.max_total = None; }) .build_or_panic(); let all_weight = crate::ConsumedWeight::new(|class| match class { - DispatchClass::Normal => 10, - DispatchClass::Operational => 10, - DispatchClass::Mandatory => 0, + DispatchClass::Normal => Weight::from_ref_time(10), + DispatchClass::Operational => Weight::from_ref_time(10), + DispatchClass::Mandatory => Weight::zero(), }); assert_eq!(maximum_weight.max_block, all_weight.total()); // fits into reserved - let mandatory1 = - DispatchInfo { weight: 5, class: DispatchClass::Mandatory, ..Default::default() }; + let mandatory1 = DispatchInfo { + weight: Weight::from_ref_time(5), + class: DispatchClass::Mandatory, + ..Default::default() + }; // does not fit into reserved and the block is full. - let mandatory2 = - DispatchInfo { weight: 6, class: DispatchClass::Mandatory, ..Default::default() }; + let mandatory2 = DispatchInfo { + weight: Weight::from_ref_time(6), + class: DispatchClass::Mandatory, + ..Default::default() + }; // when assert_ok!(calculate_consumed_weight::<::Call>( diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 990e3cdd14de1..d9afa17eec959 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1327,18 +1327,18 @@ impl Pallet { ).deconstruct(), Self::block_weight().get(DispatchClass::Normal), sp_runtime::Percent::from_rational( - *Self::block_weight().get(DispatchClass::Normal), - T::BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap_or(Bounded::max_value()) + Self::block_weight().get(DispatchClass::Normal).ref_time(), + T::BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap_or(Bounded::max_value()).ref_time() ).deconstruct(), Self::block_weight().get(DispatchClass::Operational), sp_runtime::Percent::from_rational( - *Self::block_weight().get(DispatchClass::Operational), - T::BlockWeights::get().get(DispatchClass::Operational).max_total.unwrap_or(Bounded::max_value()) + Self::block_weight().get(DispatchClass::Operational).ref_time(), + T::BlockWeights::get().get(DispatchClass::Operational).max_total.unwrap_or(Bounded::max_value()).ref_time() ).deconstruct(), Self::block_weight().get(DispatchClass::Mandatory), sp_runtime::Percent::from_rational( - *Self::block_weight().get(DispatchClass::Mandatory), - T::BlockWeights::get().get(DispatchClass::Mandatory).max_total.unwrap_or(Bounded::max_value()) + Self::block_weight().get(DispatchClass::Mandatory).ref_time(), + T::BlockWeights::get().get(DispatchClass::Mandatory).max_total.unwrap_or(Bounded::max_value()).ref_time() ).deconstruct(), ); ExecutionPhase::::kill(); diff --git a/frame/system/src/limits.rs b/frame/system/src/limits.rs index 6076414ba6bcb..d9be460b3a4fb 100644 --- a/frame/system/src/limits.rs +++ b/frame/system/src/limits.rs @@ -27,7 +27,7 @@ use frame_support::weights::{constants, DispatchClass, OneOrMany, PerDispatchClass, Weight}; use scale_info::TypeInfo; -use sp_runtime::{Perbill, RuntimeDebug}; +use sp_runtime::{traits::Bounded, Perbill, RuntimeDebug}; /// Block length limit configuration. #[derive(RuntimeDebug, Clone, codec::Encode, codec::Decode, TypeInfo)] @@ -230,14 +230,15 @@ impl BlockWeights { // base_for_class error_assert!( (max_for_class > self.base_block && max_for_class > base_for_class) - || max_for_class == 0, + || max_for_class == Weight::zero(), &mut error, "[{:?}] {:?} (total) has to be greater than {:?} (base block) & {:?} (base extrinsic)", class, max_for_class, self.base_block, base_for_class, ); // Max extrinsic can't be greater than max_for_class. error_assert!( - weights.max_extrinsic.unwrap_or(0) <= max_for_class.saturating_sub(base_for_class), + weights.max_extrinsic.unwrap_or(Weight::zero()) <= + max_for_class.saturating_sub(base_for_class), &mut error, "[{:?}] {:?} (max_extrinsic) can't be greater than {:?} (max for class)", class, @@ -246,14 +247,14 @@ impl BlockWeights { ); // Max extrinsic should not be 0 error_assert!( - weights.max_extrinsic.unwrap_or_else(Weight::max_value) > 0, + weights.max_extrinsic.unwrap_or_else(Weight::max_value) > Weight::zero(), &mut error, "[{:?}] {:?} (max_extrinsic) must not be 0. Check base cost and average initialization cost.", class, weights.max_extrinsic, ); // Make sure that if reserved is set it's greater than base_for_class. error_assert!( - reserved > base_for_class || reserved == 0, + reserved > base_for_class || reserved == Weight::zero(), &mut error, "[{:?}] {:?} (reserved) has to be greater than {:?} (base extrinsic) if set", class, @@ -262,7 +263,7 @@ impl BlockWeights { ); // Make sure max block is greater than max_total if it's set. error_assert!( - self.max_block >= weights.max_total.unwrap_or(0), + self.max_block >= weights.max_total.unwrap_or(Weight::zero()), &mut error, "[{:?}] {:?} (max block) has to be greater than {:?} (max for class)", class, @@ -294,9 +295,9 @@ impl BlockWeights { /// is not suitable for production deployments. pub fn simple_max(block_weight: Weight) -> Self { Self::builder() - .base_block(0) + .base_block(Weight::new()) .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = 0; + weights.base_extrinsic = Weight::new(); }) .for_class(DispatchClass::non_mandatory(), |weights| { weights.max_total = block_weight.into(); @@ -333,9 +334,10 @@ impl BlockWeights { BlockWeightsBuilder { weights: BlockWeights { base_block: constants::BlockExecutionWeight::get(), - max_block: 0, + max_block: Weight::zero(), per_class: PerDispatchClass::new(|class| { - let initial = if class == DispatchClass::Mandatory { None } else { Some(0) }; + let initial = + if class == DispatchClass::Mandatory { None } else { Some(Weight::zero()) }; WeightsPerClass { base_extrinsic: constants::ExtrinsicBaseWeight::get(), max_extrinsic: None, diff --git a/frame/system/src/migrations/mod.rs b/frame/system/src/migrations/mod.rs index f02af7a316fe1..15746d7376ac5 100644 --- a/frame/system/src/migrations/mod.rs +++ b/frame/system/src/migrations/mod.rs @@ -81,7 +81,7 @@ pub fn migrate_from_single_u8_to_triple_ref_count() -> Wei ); >::put(true); >::put(true); - Weight::max_value() + Weight::MAX } /// Migrate from unique `u32` reference counting to triple `u32` reference counting. @@ -99,7 +99,7 @@ pub fn migrate_from_single_to_triple_ref_count() -> Weight translated ); >::put(true); - Weight::max_value() + Weight::MAX } /// Migrate from dual `u32` reference counting to triple `u32` reference counting. @@ -117,5 +117,5 @@ pub fn migrate_from_dual_to_triple_ref_count() -> Weight { translated ); >::put(true); - Weight::max_value() + Weight::MAX } diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index f3f542aa83a9a..23ab3c2af20b0 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -42,7 +42,7 @@ frame_support::construct_runtime!( ); const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); -const MAX_BLOCK_WEIGHT: Weight = 1024; +const MAX_BLOCK_WEIGHT: Weight = Weight::from_ref_time(1024); parameter_types! { pub Version: RuntimeVersion = RuntimeVersion { @@ -60,9 +60,9 @@ parameter_types! { write: 100, }; pub RuntimeBlockWeights: limits::BlockWeights = limits::BlockWeights::builder() - .base_block(10) + .base_block(Weight::from_ref_time(10)) .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = 5; + weights.base_extrinsic = Weight::from_ref_time(5); }) .for_class(DispatchClass::Normal, |weights| { weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAX_BLOCK_WEIGHT); diff --git a/frame/system/src/tests.rs b/frame/system/src/tests.rs index 417dca12045ee..f82ea338bd146 100644 --- a/frame/system/src/tests.rs +++ b/frame/system/src/tests.rs @@ -224,7 +224,7 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { System::initialize(&1, &[0u8; 32].into(), &Default::default()); System::note_finished_initialize(); - let pre_info = DispatchInfo { weight: 1000, ..Default::default() }; + let pre_info = DispatchInfo { weight: Weight::from_ref_time(1000), ..Default::default() }; System::note_applied_extrinsic(&Ok(Some(300).into()), pre_info); System::note_applied_extrinsic(&Ok(Some(1000).into()), pre_info); System::note_applied_extrinsic( @@ -236,7 +236,10 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { System::note_applied_extrinsic(&Ok(Pays::No.into()), pre_info); System::note_applied_extrinsic(&Ok((Some(2_500_000), Pays::No).into()), pre_info); System::note_applied_extrinsic(&Ok((Some(500), Pays::No).into()), pre_info); - System::note_applied_extrinsic(&Err(DispatchError::BadOrigin.with_weight(999)), pre_info); + System::note_applied_extrinsic( + &Err(DispatchError::BadOrigin.with_weight(Weight::from_ref_time(999))), + pre_info, + ); System::note_applied_extrinsic( &Err(DispatchErrorWithPostInfo { @@ -247,14 +250,20 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { ); System::note_applied_extrinsic( &Err(DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { actual_weight: Some(800), pays_fee: Pays::Yes }, + post_info: PostDispatchInfo { + actual_weight: Some(Weight::from_ref_time(800)), + pays_fee: Pays::Yes, + }, error: DispatchError::BadOrigin, }), pre_info, ); System::note_applied_extrinsic( &Err(DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { actual_weight: Some(800), pays_fee: Pays::No }, + post_info: PostDispatchInfo { + actual_weight: Some(Weight::from_ref_time(800)), + pays_fee: Pays::No, + }, error: DispatchError::BadOrigin, }), pre_info, @@ -266,7 +275,10 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { EventRecord { phase: Phase::ApplyExtrinsic(0), event: SysEvent::ExtrinsicSuccess { - dispatch_info: DispatchInfo { weight: 300, ..Default::default() }, + dispatch_info: DispatchInfo { + weight: Weight::from_ref_time(300), + ..Default::default() + }, } .into(), topics: vec![] @@ -274,7 +286,10 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { EventRecord { phase: Phase::ApplyExtrinsic(1), event: SysEvent::ExtrinsicSuccess { - dispatch_info: DispatchInfo { weight: 1000, ..Default::default() }, + dispatch_info: DispatchInfo { + weight: Weight::from_ref_time(1000), + ..Default::default() + }, } .into(), topics: vec![] @@ -282,7 +297,10 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { EventRecord { phase: Phase::ApplyExtrinsic(2), event: SysEvent::ExtrinsicSuccess { - dispatch_info: DispatchInfo { weight: 1000, ..Default::default() }, + dispatch_info: DispatchInfo { + weight: Weight::from_ref_time(1000), + ..Default::default() + }, } .into(), topics: vec![] @@ -291,7 +309,7 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { phase: Phase::ApplyExtrinsic(3), event: SysEvent::ExtrinsicSuccess { dispatch_info: DispatchInfo { - weight: 1000, + weight: Weight::from_ref_time(1000), pays_fee: Pays::Yes, ..Default::default() }, @@ -303,7 +321,7 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { phase: Phase::ApplyExtrinsic(4), event: SysEvent::ExtrinsicSuccess { dispatch_info: DispatchInfo { - weight: 1000, + weight: Weight::from_ref_time(1000), pays_fee: Pays::No, ..Default::default() }, @@ -315,7 +333,7 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { phase: Phase::ApplyExtrinsic(5), event: SysEvent::ExtrinsicSuccess { dispatch_info: DispatchInfo { - weight: 1000, + weight: Weight::from_ref_time(1000), pays_fee: Pays::No, ..Default::default() }, @@ -327,7 +345,7 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { phase: Phase::ApplyExtrinsic(6), event: SysEvent::ExtrinsicSuccess { dispatch_info: DispatchInfo { - weight: 500, + weight: Weight::from_ref_time(500), pays_fee: Pays::No, ..Default::default() }, @@ -339,7 +357,10 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { phase: Phase::ApplyExtrinsic(7), event: SysEvent::ExtrinsicFailed { dispatch_error: DispatchError::BadOrigin.into(), - dispatch_info: DispatchInfo { weight: 999, ..Default::default() }, + dispatch_info: DispatchInfo { + weight: Weight::from_ref_time(999), + ..Default::default() + }, } .into(), topics: vec![] @@ -349,7 +370,7 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { event: SysEvent::ExtrinsicFailed { dispatch_error: DispatchError::BadOrigin.into(), dispatch_info: DispatchInfo { - weight: 1000, + weight: Weight::from_ref_time(1000), pays_fee: Pays::Yes, ..Default::default() }, @@ -362,7 +383,7 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { event: SysEvent::ExtrinsicFailed { dispatch_error: DispatchError::BadOrigin.into(), dispatch_info: DispatchInfo { - weight: 800, + weight: Weight::from_ref_time(800), pays_fee: Pays::Yes, ..Default::default() }, @@ -375,7 +396,7 @@ fn deposit_event_uses_actual_weight_and_pays_fee() { event: SysEvent::ExtrinsicFailed { dispatch_error: DispatchError::BadOrigin.into(), dispatch_info: DispatchInfo { - weight: 800, + weight: Weight::from_ref_time(800), pays_fee: Pays::No, ..Default::default() }, diff --git a/frame/system/src/weights.rs b/frame/system/src/weights.rs index 19719032587ef..4f7f168eb55ab 100644 --- a/frame/system/src/weights.rs +++ b/frame/system/src/weights.rs @@ -41,7 +41,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for frame_system. @@ -59,44 +59,44 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// The range of component `b` is `[0, 3932160]`. fn remark(_b: u32, ) -> Weight { - (1_000_000 as Weight) + Weight::from_ref_time(1_000_000 as RefTimeWeight) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) } // Storage: System Digest (r:1 w:1) // Storage: unknown [0x3a686561707061676573] (r:0 w:1) fn set_heap_pages() -> Weight { - (5_367_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(5_367_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `i` is `[1, 1000]`. fn set_storage(i: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((603_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + .saturating_add(Weight::from_ref_time(603_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `i` is `[1, 1000]`. fn kill_storage(i: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((513_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + .saturating_add(Weight::from_ref_time(513_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `p` is `[1, 1000]`. fn kill_prefix(p: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_026_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + .saturating_add(Weight::from_ref_time(1_026_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) } } @@ -104,43 +104,43 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { /// The range of component `b` is `[0, 3932160]`. fn remark(_b: u32, ) -> Weight { - (1_000_000 as Weight) + Weight::from_ref_time(1_000_000 as RefTimeWeight) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight)) } // Storage: System Digest (r:1 w:1) // Storage: unknown [0x3a686561707061676573] (r:0 w:1) fn set_heap_pages() -> Weight { - (5_367_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(5_367_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `i` is `[1, 1000]`. fn set_storage(i: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((603_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + .saturating_add(Weight::from_ref_time(603_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `i` is `[1, 1000]`. fn kill_storage(i: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((513_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + .saturating_add(Weight::from_ref_time(513_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `p` is `[1, 1000]`. fn kill_prefix(p: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((1_026_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + .saturating_add(Weight::from_ref_time(1_026_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) } } diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index 0da94deb7112a..b4c377cfa30ef 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -49,7 +49,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; diff --git a/frame/timestamp/src/weights.rs b/frame/timestamp/src/weights.rs index 6b4ebfa74dd87..f71a0f753a43e 100644 --- a/frame/timestamp/src/weights.rs +++ b/frame/timestamp/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_timestamp. @@ -54,12 +54,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:1) // Storage: Babe CurrentSlot (r:1 w:0) fn set() -> Weight { - (8_080_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(8_080_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } fn on_finalize() -> Weight { - (2_681_000 as Weight) + Weight::from_ref_time(2_681_000 as RefTimeWeight) } } @@ -68,11 +68,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:1) // Storage: Babe CurrentSlot (r:1 w:0) fn set() -> Weight { - (8_080_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(8_080_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } fn on_finalize() -> Weight { - (2_681_000 as Weight) + Weight::from_ref_time(2_681_000 as RefTimeWeight) } } diff --git a/frame/tips/src/migrations/v4.rs b/frame/tips/src/migrations/v4.rs index 34f7a43ec12de..5e10fa7dd2c6d 100644 --- a/frame/tips/src/migrations/v4.rs +++ b/frame/tips/src/migrations/v4.rs @@ -49,7 +49,7 @@ pub fn migrate::on_chain_storage_version(); @@ -84,7 +84,7 @@ pub fn migrate WeightInfo for SubstrateWeight { // Storage: Tips Reasons (r:1 w:1) // Storage: Tips Tips (r:1 w:1) fn report_awesome(r: u32, ) -> Weight { - (30_669_000 as Weight) + Weight::from_ref_time(30_669_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(4_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn retract_tip() -> Weight { - (28_768_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(28_768_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Members (r:1 w:0) // Storage: Tips Reasons (r:1 w:1) // Storage: Tips Tips (r:0 w:1) fn tip_new(r: u32, t: u32, ) -> Weight { - (20_385_000 as Weight) + Weight::from_ref_time(20_385_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 3_000 - .saturating_add((166_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(166_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Members (r:1 w:0) // Storage: Tips Tips (r:1 w:1) fn tip(t: u32, ) -> Weight { - (12_287_000 as Weight) + Weight::from_ref_time(12_287_000 as RefTimeWeight) // Standard Error: 6_000 - .saturating_add((363_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(363_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Tips Tips (r:1 w:1) // Storage: Elections Members (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn close_tip(t: u32, ) -> Weight { - (45_656_000 as Weight) + Weight::from_ref_time(45_656_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((276_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(276_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn slash_tip(t: u32, ) -> Weight { - (18_525_000 as Weight) + Weight::from_ref_time(18_525_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((37_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(37_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } } @@ -119,58 +119,58 @@ impl WeightInfo for () { // Storage: Tips Reasons (r:1 w:1) // Storage: Tips Tips (r:1 w:1) fn report_awesome(r: u32, ) -> Weight { - (30_669_000 as Weight) + Weight::from_ref_time(30_669_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(4_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn retract_tip() -> Weight { - (28_768_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(28_768_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Members (r:1 w:0) // Storage: Tips Reasons (r:1 w:1) // Storage: Tips Tips (r:0 w:1) fn tip_new(r: u32, t: u32, ) -> Weight { - (20_385_000 as Weight) + Weight::from_ref_time(20_385_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(r as RefTimeWeight)) // Standard Error: 3_000 - .saturating_add((166_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(166_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Elections Members (r:1 w:0) // Storage: Tips Tips (r:1 w:1) fn tip(t: u32, ) -> Weight { - (12_287_000 as Weight) + Weight::from_ref_time(12_287_000 as RefTimeWeight) // Standard Error: 6_000 - .saturating_add((363_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(363_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Tips Tips (r:1 w:1) // Storage: Elections Members (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn close_tip(t: u32, ) -> Weight { - (45_656_000 as Weight) + Weight::from_ref_time(45_656_000 as RefTimeWeight) // Standard Error: 14_000 - .saturating_add((276_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(276_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn slash_tip(t: u32, ) -> Weight { - (18_525_000 as Weight) + Weight::from_ref_time(18_525_000 as RefTimeWeight) // Standard Error: 5_000 - .saturating_add((37_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(37_000 as RefTimeWeight).scalar_saturating_mul(t as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } } diff --git a/frame/transaction-payment/asset-tx-payment/src/tests.rs b/frame/transaction-payment/asset-tx-payment/src/tests.rs index 08b17a6bf459c..a296a52b5e840 100644 --- a/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -59,19 +59,19 @@ const CALL: &::Call = &Call::Balances(BalancesCall::transfer { dest: 2, value: 69 }); thread_local! { - static EXTRINSIC_BASE_WEIGHT: RefCell = RefCell::new(0); + static EXTRINSIC_BASE_WEIGHT: RefCell = RefCell::new(Weight::new()); } pub struct BlockWeights; impl Get for BlockWeights { fn get() -> frame_system::limits::BlockWeights { frame_system::limits::BlockWeights::builder() - .base_block(0) + .base_block(Weight::zero()) .for_class(DispatchClass::all(), |weights| { weights.base_extrinsic = EXTRINSIC_BASE_WEIGHT.with(|v| *v.borrow()).into(); }) .for_class(DispatchClass::non_mandatory(), |weights| { - weights.max_total = 1024.into(); + weights.max_total = Weight::from_ref_time(1024).into(); }) .build_or_panic() } @@ -129,7 +129,8 @@ impl WeightToFeeT for WeightToFee { type Balance = u64; fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(*weight).saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) + Self::Balance::saturated_from(weight.ref_time()) + .saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) } } @@ -137,7 +138,7 @@ impl WeightToFeeT for TransactionByteFee { type Balance = u64; fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(*weight) + Self::Balance::saturated_from(weight.ref_time()) .saturating_mul(TRANSACTION_BYTE_FEE.with(|v| *v.borrow())) } } @@ -208,19 +209,24 @@ impl Config for Runtime { pub struct ExtBuilder { balance_factor: u64, - base_weight: u64, + base_weight: Weight, byte_fee: u64, weight_to_fee: u64, } impl Default for ExtBuilder { fn default() -> Self { - Self { balance_factor: 1, base_weight: 0, byte_fee: 1, weight_to_fee: 1 } + Self { + balance_factor: 1, + base_weight: Weight::from_ref_time(0), + byte_fee: 1, + weight_to_fee: 1, + } } } impl ExtBuilder { - pub fn base_weight(mut self, base_weight: u64) -> Self { + pub fn base_weight(mut self, base_weight: Weight) -> Self { self.base_weight = base_weight; self } @@ -283,19 +289,19 @@ fn transaction_payment_in_native_possible() { let balance_factor = 100; ExtBuilder::default() .balance_factor(balance_factor) - .base_weight(5) + .base_weight(Weight::from_ref_time(5)) .build() .execute_with(|| { let len = 10; let pre = ChargeAssetTxPayment::::from(0, None) - .pre_dispatch(&1, CALL, &info_from_weight(5), len) + .pre_dispatch(&1, CALL, &info_from_weight(Weight::from_ref_time(5)), len) .unwrap(); let initial_balance = 10 * balance_factor; assert_eq!(Balances::free_balance(1), initial_balance - 5 - 5 - 10); assert_ok!(ChargeAssetTxPayment::::post_dispatch( Some(pre), - &info_from_weight(5), + &info_from_weight(Weight::from_ref_time(5)), &default_post_info(), len, &Ok(()) @@ -303,15 +309,15 @@ fn transaction_payment_in_native_possible() { assert_eq!(Balances::free_balance(1), initial_balance - 5 - 5 - 10); let pre = ChargeAssetTxPayment::::from(5 /* tipped */, None) - .pre_dispatch(&2, CALL, &info_from_weight(100), len) + .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) .unwrap(); let initial_balance_for_2 = 20 * balance_factor; assert_eq!(Balances::free_balance(2), initial_balance_for_2 - 5 - 10 - 100 - 5); assert_ok!(ChargeAssetTxPayment::::post_dispatch( Some(pre), - &info_from_weight(100), - &post_info_from_weight(50), + &info_from_weight(Weight::from_ref_time(100)), + &post_info_from_weight(Weight::from_ref_time(50)), len, &Ok(()) )); @@ -325,7 +331,7 @@ fn transaction_payment_in_asset_possible() { let balance_factor = 100; ExtBuilder::default() .balance_factor(balance_factor) - .base_weight(base_weight) + .base_weight(Weight::from_ref_time(base_weight)) .build() .execute_with(|| { // create the asset @@ -351,7 +357,7 @@ fn transaction_payment_in_asset_possible() { // existential deposit let fee = (base_weight + weight + len as u64) * min_balance / ExistentialDeposit::get(); let pre = ChargeAssetTxPayment::::from(0, Some(asset_id)) - .pre_dispatch(&caller, CALL, &info_from_weight(weight), len) + .pre_dispatch(&caller, CALL, &info_from_weight(Weight::from_ref_time(weight)), len) .unwrap(); // assert that native balance is not used assert_eq!(Balances::free_balance(caller), 10 * balance_factor); @@ -361,7 +367,7 @@ fn transaction_payment_in_asset_possible() { assert_ok!(ChargeAssetTxPayment::::post_dispatch( Some(pre), - &info_from_weight(weight), + &info_from_weight(Weight::from_ref_time(weight)), &default_post_info(), len, &Ok(()) @@ -378,7 +384,7 @@ fn transaction_payment_without_fee() { let balance_factor = 100; ExtBuilder::default() .balance_factor(balance_factor) - .base_weight(base_weight) + .base_weight(Weight::from_ref_time(base_weight)) .build() .execute_with(|| { // create the asset @@ -404,7 +410,7 @@ fn transaction_payment_without_fee() { // existential deposit let fee = (base_weight + weight + len as u64) * min_balance / ExistentialDeposit::get(); let pre = ChargeAssetTxPayment::::from(0, Some(asset_id)) - .pre_dispatch(&caller, CALL, &info_from_weight(weight), len) + .pre_dispatch(&caller, CALL, &info_from_weight(Weight::from_ref_time(weight)), len) .unwrap(); // assert that native balance is not used assert_eq!(Balances::free_balance(caller), 10 * balance_factor); @@ -414,7 +420,7 @@ fn transaction_payment_without_fee() { assert_ok!(ChargeAssetTxPayment::::post_dispatch( Some(pre), - &info_from_weight(weight), + &info_from_weight(Weight::from_ref_time(weight)), &post_info_from_pays(Pays::No), len, &Ok(()) @@ -431,7 +437,7 @@ fn asset_transaction_payment_with_tip_and_refund() { let base_weight = 5; ExtBuilder::default() .balance_factor(100) - .base_weight(base_weight) + .base_weight(Weight::from_ref_time(base_weight)) .build() .execute_with(|| { // create the asset @@ -459,15 +465,15 @@ fn asset_transaction_payment_with_tip_and_refund() { let fee_with_tip = (base_weight + weight + len as u64 + tip) * min_balance / ExistentialDeposit::get(); let pre = ChargeAssetTxPayment::::from(tip, Some(asset_id)) - .pre_dispatch(&caller, CALL, &info_from_weight(weight), len) + .pre_dispatch(&caller, CALL, &info_from_weight(Weight::from_ref_time(weight)), len) .unwrap(); assert_eq!(Assets::balance(asset_id, caller), balance - fee_with_tip); let final_weight = 50; assert_ok!(ChargeAssetTxPayment::::post_dispatch( Some(pre), - &info_from_weight(weight), - &post_info_from_weight(final_weight), + &info_from_weight(Weight::from_ref_time(weight)), + &post_info_from_weight(Weight::from_ref_time(final_weight)), len, &Ok(()) )); @@ -483,7 +489,7 @@ fn payment_from_account_with_only_assets() { let base_weight = 5; ExtBuilder::default() .balance_factor(100) - .base_weight(base_weight) + .base_weight(Weight::from_ref_time(base_weight)) .build() .execute_with(|| { // create the asset @@ -511,7 +517,7 @@ fn payment_from_account_with_only_assets() { // existential deposit let fee = (base_weight + weight + len as u64) * min_balance / ExistentialDeposit::get(); let pre = ChargeAssetTxPayment::::from(0, Some(asset_id)) - .pre_dispatch(&caller, CALL, &info_from_weight(weight), len) + .pre_dispatch(&caller, CALL, &info_from_weight(Weight::from_ref_time(weight)), len) .unwrap(); assert_eq!(Balances::free_balance(caller), 0); // check that fee was charged in the given asset @@ -519,7 +525,7 @@ fn payment_from_account_with_only_assets() { assert_ok!(ChargeAssetTxPayment::::post_dispatch( Some(pre), - &info_from_weight(weight), + &info_from_weight(Weight::from_ref_time(weight)), &default_post_info(), len, &Ok(()) @@ -534,7 +540,7 @@ fn payment_only_with_existing_sufficient_asset() { let base_weight = 5; ExtBuilder::default() .balance_factor(100) - .base_weight(base_weight) + .base_weight(Weight::from_ref_time(base_weight)) .build() .execute_with(|| { let asset_id = 1; @@ -543,7 +549,7 @@ fn payment_only_with_existing_sufficient_asset() { let len = 10; // pre_dispatch fails for non-existent asset assert!(ChargeAssetTxPayment::::from(0, Some(asset_id)) - .pre_dispatch(&caller, CALL, &info_from_weight(weight), len) + .pre_dispatch(&caller, CALL, &info_from_weight(Weight::from_ref_time(weight)), len) .is_err()); // create the non-sufficient asset @@ -557,7 +563,7 @@ fn payment_only_with_existing_sufficient_asset() { )); // pre_dispatch fails for non-sufficient asset assert!(ChargeAssetTxPayment::::from(0, Some(asset_id)) - .pre_dispatch(&caller, CALL, &info_from_weight(weight), len) + .pre_dispatch(&caller, CALL, &info_from_weight(Weight::from_ref_time(weight)), len) .is_err()); }); } @@ -567,7 +573,7 @@ fn converted_fee_is_never_zero_if_input_fee_is_not() { let base_weight = 1; ExtBuilder::default() .balance_factor(100) - .base_weight(base_weight) + .base_weight(Weight::from_ref_time(base_weight)) .build() .execute_with(|| { // create the asset @@ -611,14 +617,14 @@ fn converted_fee_is_never_zero_if_input_fee_is_not() { assert_eq!(Assets::balance(asset_id, caller), balance); } let pre = ChargeAssetTxPayment::::from(0, Some(asset_id)) - .pre_dispatch(&caller, CALL, &info_from_weight(weight), len) + .pre_dispatch(&caller, CALL, &info_from_weight(Weight::from_ref_time(weight)), len) .unwrap(); // check that at least one coin was charged in the given asset assert_eq!(Assets::balance(asset_id, caller), balance - 1); assert_ok!(ChargeAssetTxPayment::::post_dispatch( Some(pre), - &info_from_weight(weight), + &info_from_weight(Weight::from_ref_time(weight)), &default_post_info(), len, &Ok(()) @@ -632,7 +638,7 @@ fn post_dispatch_fee_is_zero_if_pre_dispatch_fee_is_zero() { let base_weight = 1; ExtBuilder::default() .balance_factor(100) - .base_weight(base_weight) + .base_weight(Weight::from_ref_time(base_weight)) .build() .execute_with(|| { // create the asset @@ -689,7 +695,7 @@ fn post_dispatch_fee_is_zero_if_unsigned_pre_dispatch_fee_is_zero() { let base_weight = 1; ExtBuilder::default() .balance_factor(100) - .base_weight(base_weight) + .base_weight(Weight::from_ref_time(base_weight)) .build() .execute_with(|| { // create the asset @@ -713,7 +719,7 @@ fn post_dispatch_fee_is_zero_if_unsigned_pre_dispatch_fee_is_zero() { let len = 1; ChargeAssetTxPayment::::pre_dispatch_unsigned( CALL, - &info_from_weight(weight), + &info_from_weight(Weight::from_ref_time(weight)), len, ) .unwrap(); @@ -724,7 +730,7 @@ fn post_dispatch_fee_is_zero_if_unsigned_pre_dispatch_fee_is_zero() { // initial fee) assert_ok!(ChargeAssetTxPayment::::post_dispatch( None, - &info_from_weight(weight), + &info_from_weight(Weight::from_ref_time(weight)), &post_info_from_pays(Pays::Yes), len, &Ok(()) diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 707f7d8a22065..9777d7d240491 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -66,7 +66,8 @@ use frame_support::{ dispatch::DispatchResult, traits::{EstimateCallFee, Get}, weights::{ - DispatchClass, DispatchInfo, GetDispatchInfo, Pays, PostDispatchInfo, Weight, WeightToFee, + DispatchClass, DispatchInfo, GetDispatchInfo, Pays, PostDispatchInfo, RefTimeWeight, + Weight, WeightToFee, }, }; @@ -189,7 +190,11 @@ where weights.get(DispatchClass::Normal).max_total.unwrap_or(weights.max_block); let current_block_weight = >::block_weight(); let normal_block_weight = - *current_block_weight.get(DispatchClass::Normal).min(&normal_max_weight); + current_block_weight.get(DispatchClass::Normal).min(normal_max_weight); + + // TODO: Handle all weight dimensions + let normal_max_weight = normal_max_weight.ref_time(); + let normal_block_weight = normal_block_weight.ref_time(); let s = S::get(); let v = V::get(); @@ -347,7 +352,7 @@ pub mod pallet { assert!( ::max_value() >= Multiplier::checked_from_integer::( - T::BlockWeights::get().max_block.try_into().unwrap() + T::BlockWeights::get().max_block.ref_time().try_into().unwrap() ) .unwrap(), ); @@ -359,7 +364,7 @@ pub mod pallet { ); // add 1 percent; let addition = target / 100; - if addition == 0 { + if addition == Weight::zero() { // this is most likely because in a test setup we set everything to (). return } @@ -554,7 +559,7 @@ where } fn length_to_fee(length: u32) -> BalanceOf { - T::LengthToFee::weight_to_fee(&(length as Weight)) + T::LengthToFee::weight_to_fee(&Weight::from_ref_time(length as RefTimeWeight)) } fn weight_to_fee(weight: Weight) -> BalanceOf { @@ -655,7 +660,11 @@ where let max_block_weight = T::BlockWeights::get().max_block; let max_block_length = *T::BlockLength::get().max.get(info.class) as u64; - let bounded_weight = info.weight.max(1).min(max_block_weight); + // TODO: Take into account all dimensions of weight + let max_block_weight = max_block_weight.ref_time(); + let info_weight = info.weight.ref_time(); + + let bounded_weight = info_weight.max(1).min(max_block_weight); let bounded_length = (len as u64).max(1).min(max_block_length); let max_tx_per_block_weight = max_block_weight / bounded_weight; @@ -836,19 +845,19 @@ mod tests { &Call::Balances(BalancesCall::transfer { dest: 2, value: 69 }); thread_local! { - static EXTRINSIC_BASE_WEIGHT: RefCell = RefCell::new(0); + static EXTRINSIC_BASE_WEIGHT: RefCell = RefCell::new(Weight::new()); } pub struct BlockWeights; impl Get for BlockWeights { fn get() -> frame_system::limits::BlockWeights { frame_system::limits::BlockWeights::builder() - .base_block(0) + .base_block(Weight::zero()) .for_class(DispatchClass::all(), |weights| { weights.base_extrinsic = EXTRINSIC_BASE_WEIGHT.with(|v| *v.borrow()).into(); }) .for_class(DispatchClass::non_mandatory(), |weights| { - weights.max_total = 1024.into(); + weights.max_total = Weight::from_ref_time(1024).into(); }) .build_or_panic() } @@ -903,7 +912,7 @@ mod tests { type Balance = u64; fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(*weight) + Self::Balance::saturated_from(weight.ref_time()) .saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) } } @@ -912,7 +921,7 @@ mod tests { type Balance = u64; fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(*weight) + Self::Balance::saturated_from(weight.ref_time()) .saturating_mul(TRANSACTION_BYTE_FEE.with(|v| *v.borrow())) } } @@ -947,19 +956,19 @@ mod tests { pub struct ExtBuilder { balance_factor: u64, - base_weight: u64, + base_weight: Weight, byte_fee: u64, weight_to_fee: u64, } impl Default for ExtBuilder { fn default() -> Self { - Self { balance_factor: 1, base_weight: 0, byte_fee: 1, weight_to_fee: 1 } + Self { balance_factor: 1, base_weight: Weight::zero(), byte_fee: 1, weight_to_fee: 1 } } } impl ExtBuilder { - pub fn base_weight(mut self, base_weight: u64) -> Self { + pub fn base_weight(mut self, base_weight: Weight) -> Self { self.base_weight = base_weight; self } @@ -1025,18 +1034,18 @@ mod tests { fn signed_extension_transaction_payment_work() { ExtBuilder::default() .balance_factor(10) - .base_weight(5) + .base_weight(Weight::from_ref_time(5)) .build() .execute_with(|| { let len = 10; let pre = ChargeTransactionPayment::::from(0) - .pre_dispatch(&1, CALL, &info_from_weight(5), len) + .pre_dispatch(&1, CALL, &info_from_weight(Weight::from_ref_time(5)), len) .unwrap(); assert_eq!(Balances::free_balance(1), 100 - 5 - 5 - 10); assert_ok!(ChargeTransactionPayment::::post_dispatch( Some(pre), - &info_from_weight(5), + &info_from_weight(Weight::from_ref_time(5)), &default_post_info(), len, &Ok(()) @@ -1048,14 +1057,14 @@ mod tests { FEE_UNBALANCED_AMOUNT.with(|a| *a.borrow_mut() = 0); let pre = ChargeTransactionPayment::::from(5 /* tipped */) - .pre_dispatch(&2, CALL, &info_from_weight(100), len) + .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) .unwrap(); assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); assert_ok!(ChargeTransactionPayment::::post_dispatch( Some(pre), - &info_from_weight(100), - &post_info_from_weight(50), + &info_from_weight(Weight::from_ref_time(100)), + &post_info_from_weight(Weight::from_ref_time(50)), len, &Ok(()) )); @@ -1069,22 +1078,22 @@ mod tests { fn signed_extension_transaction_payment_multiplied_refund_works() { ExtBuilder::default() .balance_factor(10) - .base_weight(5) + .base_weight(Weight::from_ref_time(5)) .build() .execute_with(|| { let len = 10; >::put(Multiplier::saturating_from_rational(3, 2)); let pre = ChargeTransactionPayment::::from(5 /* tipped */) - .pre_dispatch(&2, CALL, &info_from_weight(100), len) + .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) .unwrap(); // 5 base fee, 10 byte fee, 3/2 * 100 weight fee, 5 tip assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 150 - 5); assert_ok!(ChargeTransactionPayment::::post_dispatch( Some(pre), - &info_from_weight(100), - &post_info_from_weight(50), + &info_from_weight(Weight::from_ref_time(100)), + &post_info_from_weight(Weight::from_ref_time(50)), len, &Ok(()) )); @@ -1100,13 +1109,14 @@ mod tests { assert_ok!(ChargeTransactionPayment::::from(0).pre_dispatch( &1, CALL, - &info_from_weight(Weight::max_value()), + &info_from_weight(Weight::MAX), 10 )); // fee will be proportional to what is the actual maximum weight in the runtime. assert_eq!( Balances::free_balance(&1), - (10000 - ::BlockWeights::get().max_block) as u64 + (10000 - + ::BlockWeights::get().max_block.ref_time()) as u64 ); }); } @@ -1114,7 +1124,7 @@ mod tests { #[test] fn signed_extension_allows_free_transactions() { ExtBuilder::default() - .base_weight(100) + .base_weight(Weight::from_ref_time(100)) .balance_factor(0) .build() .execute_with(|| { @@ -1125,7 +1135,7 @@ mod tests { // This is a completely free (and thus wholly insecure/DoS-ridden) transaction. let operational_transaction = DispatchInfo { - weight: 0, + weight: Weight::from_ref_time(0), class: DispatchClass::Operational, pays_fee: Pays::No, }; @@ -1137,8 +1147,11 @@ mod tests { )); // like a InsecureFreeNormal - let free_transaction = - DispatchInfo { weight: 0, class: DispatchClass::Normal, pays_fee: Pays::Yes }; + let free_transaction = DispatchInfo { + weight: Weight::from_ref_time(0), + class: DispatchClass::Normal, + pays_fee: Pays::Yes, + }; assert_noop!( ChargeTransactionPayment::::from(0).validate( &1, @@ -1154,7 +1167,7 @@ mod tests { #[test] fn signed_ext_length_fee_is_also_updated_per_congestion() { ExtBuilder::default() - .base_weight(5) + .base_weight(Weight::from_ref_time(5)) .balance_factor(10) .build() .execute_with(|| { @@ -1162,8 +1175,10 @@ mod tests { >::put(Multiplier::saturating_from_rational(3, 2)); let len = 10; - assert_ok!(ChargeTransactionPayment::::from(10) // tipped - .pre_dispatch(&1, CALL, &info_from_weight(3), len)); + assert_ok!( + ChargeTransactionPayment::::from(10) // tipped + .pre_dispatch(&1, CALL, &info_from_weight(Weight::from_ref_time(3)), len) + ); assert_eq!( Balances::free_balance(1), 100 // original @@ -1188,48 +1203,54 @@ mod tests { let unsigned_xt = TestXt::<_, ()>::new(call, None); let unsigned_xt_info = unsigned_xt.get_dispatch_info(); - ExtBuilder::default().base_weight(5).weight_fee(2).build().execute_with(|| { - // all fees should be x1.5 - >::put(Multiplier::saturating_from_rational(3, 2)); + ExtBuilder::default() + .base_weight(Weight::from_ref_time(5)) + .weight_fee(2) + .build() + .execute_with(|| { + // all fees should be x1.5 + >::put(Multiplier::saturating_from_rational(3, 2)); - assert_eq!( - TransactionPayment::query_info(xt.clone(), len), - RuntimeDispatchInfo { - weight: info.weight, - class: info.class, - partial_fee: 5 * 2 /* base * weight_fee */ + assert_eq!( + TransactionPayment::query_info(xt.clone(), len), + RuntimeDispatchInfo { + weight: info.weight, + class: info.class, + partial_fee: 5 * 2 /* base * weight_fee */ + len as u64 /* len * 1 */ - + info.weight.min(BlockWeights::get().max_block) as u64 * 2 * 3 / 2 /* weight */ - }, - ); + + info.weight.min(BlockWeights::get().max_block).ref_time() as u64 * 2 * 3 / 2 /* weight */ + }, + ); - assert_eq!( - TransactionPayment::query_info(unsigned_xt.clone(), len), - RuntimeDispatchInfo { - weight: unsigned_xt_info.weight, - class: unsigned_xt_info.class, - partial_fee: 0, - }, - ); + assert_eq!( + TransactionPayment::query_info(unsigned_xt.clone(), len), + RuntimeDispatchInfo { + weight: unsigned_xt_info.weight, + class: unsigned_xt_info.class, + partial_fee: 0, + }, + ); - assert_eq!( - TransactionPayment::query_fee_details(xt, len), - FeeDetails { - inclusion_fee: Some(InclusionFee { - base_fee: 5 * 2, - len_fee: len as u64, - adjusted_weight_fee: info.weight.min(BlockWeights::get().max_block) as u64 * - 2 * 3 / 2 - }), - tip: 0, - }, - ); + assert_eq!( + TransactionPayment::query_fee_details(xt, len), + FeeDetails { + inclusion_fee: Some(InclusionFee { + base_fee: 5 * 2, + len_fee: len as u64, + adjusted_weight_fee: info + .weight + .min(BlockWeights::get().max_block) + .ref_time() as u64 * 2 * 3 / 2 + }), + tip: 0, + }, + ); - assert_eq!( - TransactionPayment::query_fee_details(unsigned_xt, len), - FeeDetails { inclusion_fee: None, tip: 0 }, - ); - }); + assert_eq!( + TransactionPayment::query_fee_details(unsigned_xt, len), + FeeDetails { inclusion_fee: None, tip: 0 }, + ); + }); } #[test] @@ -1239,40 +1260,46 @@ mod tests { let encoded_call = call.encode(); let len = encoded_call.len() as u32; - ExtBuilder::default().base_weight(5).weight_fee(2).build().execute_with(|| { - // all fees should be x1.5 - >::put(Multiplier::saturating_from_rational(3, 2)); + ExtBuilder::default() + .base_weight(Weight::from_ref_time(5)) + .weight_fee(2) + .build() + .execute_with(|| { + // all fees should be x1.5 + >::put(Multiplier::saturating_from_rational(3, 2)); - assert_eq!( - TransactionPayment::query_call_info(call.clone(), len), - RuntimeDispatchInfo { - weight: info.weight, - class: info.class, - partial_fee: 5 * 2 /* base * weight_fee */ + assert_eq!( + TransactionPayment::query_call_info(call.clone(), len), + RuntimeDispatchInfo { + weight: info.weight, + class: info.class, + partial_fee: 5 * 2 /* base * weight_fee */ + len as u64 /* len * 1 */ - + info.weight.min(BlockWeights::get().max_block) as u64 * 2 * 3 / 2 /* weight */ - }, - ); + + info.weight.min(BlockWeights::get().max_block).ref_time() as u64 * 2 * 3 / 2 /* weight */ + }, + ); - assert_eq!( - TransactionPayment::query_call_fee_details(call, len), - FeeDetails { - inclusion_fee: Some(InclusionFee { - base_fee: 5 * 2, /* base * weight_fee */ - len_fee: len as u64, /* len * 1 */ - adjusted_weight_fee: info.weight.min(BlockWeights::get().max_block) as u64 * - 2 * 3 / 2 /* weight * weight_fee * multipler */ - }), - tip: 0, - }, - ); - }); + assert_eq!( + TransactionPayment::query_call_fee_details(call, len), + FeeDetails { + inclusion_fee: Some(InclusionFee { + base_fee: 5 * 2, /* base * weight_fee */ + len_fee: len as u64, /* len * 1 */ + adjusted_weight_fee: info + .weight + .min(BlockWeights::get().max_block) + .ref_time() as u64 * 2 * 3 / 2 /* weight * weight_fee * multipler */ + }), + tip: 0, + }, + ); + }); } #[test] fn compute_fee_works_without_multiplier() { ExtBuilder::default() - .base_weight(100) + .base_weight(Weight::from_ref_time(100)) .byte_fee(10) .balance_factor(0) .build() @@ -1282,14 +1309,14 @@ mod tests { // Tip only, no fees works let dispatch_info = DispatchInfo { - weight: 0, + weight: Weight::from_ref_time(0), class: DispatchClass::Operational, pays_fee: Pays::No, }; assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 10), 10); // No tip, only base fee works let dispatch_info = DispatchInfo { - weight: 0, + weight: Weight::from_ref_time(0), class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -1300,7 +1327,7 @@ mod tests { assert_eq!(Pallet::::compute_fee(42, &dispatch_info, 0), 520); // Weight fee + base fee works let dispatch_info = DispatchInfo { - weight: 1000, + weight: Weight::from_ref_time(1000), class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -1311,7 +1338,7 @@ mod tests { #[test] fn compute_fee_works_with_multiplier() { ExtBuilder::default() - .base_weight(100) + .base_weight(Weight::from_ref_time(100)) .byte_fee(10) .balance_factor(0) .build() @@ -1320,7 +1347,7 @@ mod tests { >::put(Multiplier::saturating_from_rational(3, 2)); // Base fee is unaffected by multiplier let dispatch_info = DispatchInfo { - weight: 0, + weight: Weight::from_ref_time(0), class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -1328,7 +1355,7 @@ mod tests { // Everything works together :) let dispatch_info = DispatchInfo { - weight: 123, + weight: Weight::from_ref_time(123), class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -1343,7 +1370,7 @@ mod tests { #[test] fn compute_fee_works_with_negative_multiplier() { ExtBuilder::default() - .base_weight(100) + .base_weight(Weight::from_ref_time(100)) .byte_fee(10) .balance_factor(0) .build() @@ -1353,7 +1380,7 @@ mod tests { // Base fee is unaffected by multiplier. let dispatch_info = DispatchInfo { - weight: 0, + weight: Weight::from_ref_time(0), class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -1361,7 +1388,7 @@ mod tests { // Everything works together. let dispatch_info = DispatchInfo { - weight: 123, + weight: Weight::from_ref_time(123), class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -1376,14 +1403,14 @@ mod tests { #[test] fn compute_fee_does_not_overflow() { ExtBuilder::default() - .base_weight(100) + .base_weight(Weight::from_ref_time(100)) .byte_fee(10) .balance_factor(0) .build() .execute_with(|| { // Overflow is handled let dispatch_info = DispatchInfo { - weight: Weight::max_value(), + weight: Weight::MAX, class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -1398,14 +1425,14 @@ mod tests { fn refund_does_not_recreate_account() { ExtBuilder::default() .balance_factor(10) - .base_weight(5) + .base_weight(Weight::from_ref_time(5)) .build() .execute_with(|| { // So events are emitted System::set_block_number(10); let len = 10; let pre = ChargeTransactionPayment::::from(5 /* tipped */) - .pre_dispatch(&2, CALL, &info_from_weight(100), len) + .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) .unwrap(); assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); @@ -1415,8 +1442,8 @@ mod tests { assert_ok!(ChargeTransactionPayment::::post_dispatch( Some(pre), - &info_from_weight(100), - &post_info_from_weight(50), + &info_from_weight(Weight::from_ref_time(100)), + &post_info_from_weight(Weight::from_ref_time(50)), len, &Ok(()) )); @@ -1438,19 +1465,19 @@ mod tests { fn actual_weight_higher_than_max_refunds_nothing() { ExtBuilder::default() .balance_factor(10) - .base_weight(5) + .base_weight(Weight::from_ref_time(5)) .build() .execute_with(|| { let len = 10; let pre = ChargeTransactionPayment::::from(5 /* tipped */) - .pre_dispatch(&2, CALL, &info_from_weight(100), len) + .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) .unwrap(); assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); assert_ok!(ChargeTransactionPayment::::post_dispatch( Some(pre), - &info_from_weight(100), - &post_info_from_weight(101), + &info_from_weight(Weight::from_ref_time(100)), + &post_info_from_weight(Weight::from_ref_time(101)), len, &Ok(()) )); @@ -1462,14 +1489,17 @@ mod tests { fn zero_transfer_on_free_transaction() { ExtBuilder::default() .balance_factor(10) - .base_weight(5) + .base_weight(Weight::from_ref_time(5)) .build() .execute_with(|| { // So events are emitted System::set_block_number(10); let len = 10; - let dispatch_info = - DispatchInfo { weight: 100, pays_fee: Pays::No, class: DispatchClass::Normal }; + let dispatch_info = DispatchInfo { + weight: Weight::from_ref_time(100), + pays_fee: Pays::No, + class: DispatchClass::Normal, + }; let user = 69; let pre = ChargeTransactionPayment::::from(0) .pre_dispatch(&user, CALL, &dispatch_info, len) @@ -1498,11 +1528,11 @@ mod tests { fn refund_consistent_with_actual_weight() { ExtBuilder::default() .balance_factor(10) - .base_weight(7) + .base_weight(Weight::from_ref_time(7)) .build() .execute_with(|| { - let info = info_from_weight(100); - let post_info = post_info_from_weight(33); + let info = info_from_weight(Weight::from_ref_time(100)); + let post_info = post_info_from_weight(Weight::from_ref_time(33)); let prev_balance = Balances::free_balance(2); let len = 10; let tip = 5; @@ -1538,8 +1568,11 @@ mod tests { let len = 10; ExtBuilder::default().balance_factor(100).build().execute_with(|| { - let normal = - DispatchInfo { weight: 100, class: DispatchClass::Normal, pays_fee: Pays::Yes }; + let normal = DispatchInfo { + weight: Weight::from_ref_time(100), + class: DispatchClass::Normal, + pays_fee: Pays::Yes, + }; let priority = ChargeTransactionPayment::(tip) .validate(&2, CALL, &normal, len) .unwrap() @@ -1557,7 +1590,7 @@ mod tests { ExtBuilder::default().balance_factor(100).build().execute_with(|| { let op = DispatchInfo { - weight: 100, + weight: Weight::from_ref_time(100), class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -1581,8 +1614,11 @@ mod tests { let len = 10; ExtBuilder::default().balance_factor(100).build().execute_with(|| { - let normal = - DispatchInfo { weight: 100, class: DispatchClass::Normal, pays_fee: Pays::Yes }; + let normal = DispatchInfo { + weight: Weight::from_ref_time(100), + class: DispatchClass::Normal, + pays_fee: Pays::Yes, + }; let priority = ChargeTransactionPayment::(tip) .validate(&2, CALL, &normal, len) .unwrap() @@ -1593,7 +1629,7 @@ mod tests { ExtBuilder::default().balance_factor(100).build().execute_with(|| { let op = DispatchInfo { - weight: 100, + weight: Weight::from_ref_time(100), class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -1612,8 +1648,11 @@ mod tests { let mut priority2 = 0; let len = 10; ExtBuilder::default().balance_factor(100).build().execute_with(|| { - let normal = - DispatchInfo { weight: 100, class: DispatchClass::Normal, pays_fee: Pays::Yes }; + let normal = DispatchInfo { + weight: Weight::from_ref_time(100), + class: DispatchClass::Normal, + pays_fee: Pays::Yes, + }; priority1 = ChargeTransactionPayment::(tip) .validate(&2, CALL, &normal, len) .unwrap() @@ -1622,7 +1661,7 @@ mod tests { ExtBuilder::default().balance_factor(100).build().execute_with(|| { let op = DispatchInfo { - weight: 100, + weight: Weight::from_ref_time(100), class: DispatchClass::Operational, pays_fee: Pays::Yes, }; @@ -1649,10 +1688,10 @@ mod tests { fn post_info_can_change_pays_fee() { ExtBuilder::default() .balance_factor(10) - .base_weight(7) + .base_weight(Weight::from_ref_time(7)) .build() .execute_with(|| { - let info = info_from_weight(100); + let info = info_from_weight(Weight::from_ref_time(100)); let post_info = post_info_from_pays(Pays::No); let prev_balance = Balances::free_balance(2); let len = 10; diff --git a/frame/transaction-payment/src/types.rs b/frame/transaction-payment/src/types.rs index 3faebfed48946..5e915d62a26d4 100644 --- a/frame/transaction-payment/src/types.rs +++ b/frame/transaction-payment/src/types.rs @@ -135,12 +135,12 @@ mod tests { #[test] fn should_serialize_and_deserialize_properly_with_string() { let info = RuntimeDispatchInfo { - weight: 5, + weight: Weight::from_ref_time(5), class: DispatchClass::Normal, partial_fee: 1_000_000_u64, }; - let json_str = r#"{"weight":5,"class":"normal","partialFee":"1000000"}"#; + let json_str = r#"{"weight":{"ref_time":5},"class":"normal","partialFee":"1000000"}"#; assert_eq!(serde_json::to_string(&info).unwrap(), json_str); assert_eq!(serde_json::from_str::>(json_str).unwrap(), info); @@ -152,12 +152,12 @@ mod tests { #[test] fn should_serialize_and_deserialize_properly_large_value() { let info = RuntimeDispatchInfo { - weight: 5, + weight: Weight::from_ref_time(5), class: DispatchClass::Normal, partial_fee: u128::max_value(), }; - let json_str = r#"{"weight":5,"class":"normal","partialFee":"340282366920938463463374607431768211455"}"#; + let json_str = r#"{"weight":{"ref_time":5},"class":"normal","partialFee":"340282366920938463463374607431768211455"}"#; assert_eq!(serde_json::to_string(&info).unwrap(), json_str); assert_eq!(serde_json::from_str::>(json_str).unwrap(), info); diff --git a/frame/transaction-storage/src/weights.rs b/frame/transaction-storage/src/weights.rs index b8bc4890a416e..54d5b0723aad6 100644 --- a/frame/transaction-storage/src/weights.rs +++ b/frame/transaction-storage/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_transaction_storage. @@ -59,11 +59,11 @@ impl WeightInfo for SubstrateWeight { // Storage: TransactionStorage BlockTransactions (r:1 w:1) // Storage: TransactionStorage MaxBlockTransactions (r:1 w:0) fn store(l: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(5_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: TransactionStorage Transactions (r:1 w:0) // Storage: TransactionStorage ByteFee (r:1 w:0) @@ -72,9 +72,9 @@ impl WeightInfo for SubstrateWeight { // Storage: TransactionStorage BlockTransactions (r:1 w:1) // Storage: TransactionStorage MaxBlockTransactions (r:1 w:0) fn renew() -> Weight { - (50_978_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(50_978_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: TransactionStorage ProofChecked (r:1 w:1) // Storage: TransactionStorage StoragePeriod (r:1 w:0) @@ -82,9 +82,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System ParentHash (r:1 w:0) // Storage: TransactionStorage Transactions (r:1 w:0) fn check_proof_max() -> Weight { - (106_990_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(106_990_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } } @@ -97,11 +97,11 @@ impl WeightInfo for () { // Storage: TransactionStorage BlockTransactions (r:1 w:1) // Storage: TransactionStorage MaxBlockTransactions (r:1 w:0) fn store(l: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(5_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: TransactionStorage Transactions (r:1 w:0) // Storage: TransactionStorage ByteFee (r:1 w:0) @@ -110,9 +110,9 @@ impl WeightInfo for () { // Storage: TransactionStorage BlockTransactions (r:1 w:1) // Storage: TransactionStorage MaxBlockTransactions (r:1 w:0) fn renew() -> Weight { - (50_978_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(50_978_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: TransactionStorage ProofChecked (r:1 w:1) // Storage: TransactionStorage StoragePeriod (r:1 w:0) @@ -120,8 +120,8 @@ impl WeightInfo for () { // Storage: System ParentHash (r:1 w:0) // Storage: TransactionStorage Transactions (r:1 w:0) fn check_proof_max() -> Weight { - (106_990_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(106_990_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } } diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index ed38177e1c499..eecf225beea9b 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -319,7 +319,7 @@ pub mod pallet { if (n % T::SpendPeriod::get()).is_zero() { Self::spend_funds() } else { - 0 + Weight::zero() } } } @@ -500,7 +500,7 @@ impl, I: 'static> Pallet { /// Spend some money! returns number of approvals before spend. pub fn spend_funds() -> Weight { - let mut total_weight: Weight = Zero::zero(); + let mut total_weight = Weight::new(); let mut budget_remaining = Self::pot(); Self::deposit_event(Event::Spending { budget_remaining }); diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 61eafb652427b..bec96daf576e3 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -55,7 +55,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index f6b5414a05652..74e6e9779000e 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_treasury. @@ -58,51 +58,51 @@ impl WeightInfo for SubstrateWeight { // Storage: Treasury ProposalCount (r:1 w:1) // Storage: Treasury Proposals (r:0 w:1) fn spend() -> Weight { - (22_063_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(22_063_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Treasury ProposalCount (r:1 w:1) // Storage: Treasury Proposals (r:0 w:1) fn propose_spend() -> Weight { - (26_473_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(26_473_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Treasury Proposals (r:1 w:1) // Storage: System Account (r:1 w:1) fn reject_proposal() -> Weight { - (29_955_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(29_955_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Treasury Proposals (r:1 w:0) // Storage: Treasury Approvals (r:1 w:1) fn approve_proposal(p: u32, ) -> Weight { - (10_786_000 as Weight) + Weight::from_ref_time(10_786_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((110_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(110_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Treasury Approvals (r:1 w:1) fn remove_approval() -> Weight { - (6_647_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(6_647_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Treasury Approvals (r:1 w:1) // Storage: Bounties BountyApprovals (r:1 w:1) // Storage: Treasury Proposals (r:2 w:2) // Storage: System Account (r:4 w:4) fn on_initialize_proposals(p: u32, ) -> Weight { - (25_805_000 as Weight) + Weight::from_ref_time(25_805_000 as RefTimeWeight) // Standard Error: 18_000 - .saturating_add((28_473_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(p as Weight))) + .saturating_add(Weight::from_ref_time(28_473_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((3 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((3 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) } } @@ -111,50 +111,50 @@ impl WeightInfo for () { // Storage: Treasury ProposalCount (r:1 w:1) // Storage: Treasury Proposals (r:0 w:1) fn spend() -> Weight { - (22_063_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(22_063_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Treasury ProposalCount (r:1 w:1) // Storage: Treasury Proposals (r:0 w:1) fn propose_spend() -> Weight { - (26_473_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(26_473_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Treasury Proposals (r:1 w:1) // Storage: System Account (r:1 w:1) fn reject_proposal() -> Weight { - (29_955_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(29_955_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Treasury Proposals (r:1 w:0) // Storage: Treasury Approvals (r:1 w:1) fn approve_proposal(p: u32, ) -> Weight { - (10_786_000 as Weight) + Weight::from_ref_time(10_786_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((110_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(110_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Treasury Approvals (r:1 w:1) fn remove_approval() -> Weight { - (6_647_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(6_647_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Treasury Approvals (r:1 w:1) // Storage: Bounties BountyApprovals (r:1 w:1) // Storage: Treasury Proposals (r:2 w:2) // Storage: System Account (r:4 w:4) fn on_initialize_proposals(p: u32, ) -> Weight { - (25_805_000 as Weight) + Weight::from_ref_time(25_805_000 as RefTimeWeight) // Standard Error: 18_000 - .saturating_add((28_473_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(p as Weight))) + .saturating_add(Weight::from_ref_time(28_473_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((3 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((3 as RefTimeWeight).saturating_mul(p as RefTimeWeight))) } } diff --git a/frame/uniques/src/migration.rs b/frame/uniques/src/migration.rs index d301f0a3d1eb1..8a2a0ef808d90 100644 --- a/frame/uniques/src/migration.rs +++ b/frame/uniques/src/migration.rs @@ -17,10 +17,7 @@ //! Various pieces of common functionality. use super::*; -use frame_support::{ - traits::{Get, GetStorageVersion, PalletInfoAccess, StorageVersion}, - weights::Weight, -}; +use frame_support::traits::{Get, GetStorageVersion, PalletInfoAccess, StorageVersion}; /// Migrate the pallet storage to v1. pub fn migrate_to_v1, I: 'static, P: GetStorageVersion + PalletInfoAccess>( @@ -45,7 +42,7 @@ pub fn migrate_to_v1, I: 'static, P: GetStorageVersion + PalletInfo on_chain_storage_version, ); // calculate and return migration weights - T::DbWeight::get().reads_writes(count as Weight + 1, count as Weight + 1) + T::DbWeight::get().reads_writes(count as u64 + 1, count as u64 + 1) } else { log::warn!( target: "runtime::uniques", diff --git a/frame/uniques/src/weights.rs b/frame/uniques/src/weights.rs index 7c8cb170b1b1d..4ed01e463cc86 100644 --- a/frame/uniques/src/weights.rs +++ b/frame/uniques/src/weights.rs @@ -41,7 +41,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_uniques. @@ -80,16 +80,16 @@ impl WeightInfo for SubstrateWeight { // Storage: Uniques Class (r:1 w:1) // Storage: Uniques ClassAccount (r:0 w:1) fn create() -> Weight { - (33_075_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(33_075_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques ClassAccount (r:0 w:1) fn force_create() -> Weight { - (19_528_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(19_528_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques Asset (r:1 w:0) @@ -103,192 +103,192 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 25_000 - .saturating_add((13_639_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(13_639_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 25_000 - .saturating_add((2_393_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(2_393_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 25_000 - .saturating_add((2_217_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(m as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(a as Weight))) + .saturating_add(Weight::from_ref_time(2_217_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((2 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(m as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(a as RefTimeWeight))) } // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques Class (r:1 w:1) // Storage: Uniques CollectionMaxSupply (r:1 w:0) // Storage: Uniques Account (r:0 w:1) fn mint() -> Weight { - (42_146_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(42_146_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques Account (r:0 w:1) // Storage: Uniques ItemPriceOf (r:0 w:1) fn burn() -> Weight { - (42_960_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(42_960_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:0) // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques Account (r:0 w:2) // Storage: Uniques ItemPriceOf (r:0 w:1) fn transfer() -> Weight { - (33_025_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(33_025_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques Asset (r:100 w:100) /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 24_000 - .saturating_add((15_540_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + .saturating_add(Weight::from_ref_time(15_540_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) } // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques Class (r:1 w:0) fn freeze() -> Weight { - (25_194_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_194_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques Class (r:1 w:0) fn thaw() -> Weight { - (25_397_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_397_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) fn freeze_collection() -> Weight { - (19_278_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_278_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) fn thaw_collection() -> Weight { - (19_304_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_304_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques OwnershipAcceptance (r:1 w:1) // Storage: Uniques Class (r:1 w:1) // Storage: Uniques ClassAccount (r:0 w:2) fn transfer_ownership() -> Weight { - (28_615_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(28_615_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) fn set_team() -> Weight { - (19_943_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_943_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques ClassAccount (r:0 w:1) fn force_item_status() -> Weight { - (22_583_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(22_583_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques InstanceMetadataOf (r:1 w:0) // Storage: Uniques Attribute (r:1 w:1) fn set_attribute() -> Weight { - (47_520_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(47_520_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques InstanceMetadataOf (r:1 w:0) // Storage: Uniques Attribute (r:1 w:1) fn clear_attribute() -> Weight { - (45_316_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(45_316_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques InstanceMetadataOf (r:1 w:1) fn set_metadata() -> Weight { - (38_391_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_391_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques InstanceMetadataOf (r:1 w:1) fn clear_metadata() -> Weight { - (38_023_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_023_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques ClassMetadataOf (r:1 w:1) fn set_collection_metadata() -> Weight { - (37_398_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(37_398_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:0) // Storage: Uniques ClassMetadataOf (r:1 w:1) fn clear_collection_metadata() -> Weight { - (35_621_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(35_621_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:0) // Storage: Uniques Asset (r:1 w:1) fn approve_transfer() -> Weight { - (25_856_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_856_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:0) // Storage: Uniques Asset (r:1 w:1) fn cancel_approval() -> Weight { - (26_098_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(26_098_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques OwnershipAcceptance (r:1 w:1) fn set_accept_ownership() -> Weight { - (24_076_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(24_076_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques CollectionMaxSupply (r:1 w:1) // Storage: Uniques Class (r:1 w:0) fn set_collection_max_supply() -> Weight { - (22_035_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_035_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Asset (r:1 w:0) // Storage: Uniques ItemPriceOf (r:0 w:1) fn set_price() -> Weight { - (22_534_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_534_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques ItemPriceOf (r:1 w:1) // Storage: Uniques Class (r:1 w:0) // Storage: Uniques Account (r:0 w:2) fn buy_item() -> Weight { - (45_272_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(45_272_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } } @@ -297,16 +297,16 @@ impl WeightInfo for () { // Storage: Uniques Class (r:1 w:1) // Storage: Uniques ClassAccount (r:0 w:1) fn create() -> Weight { - (33_075_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(33_075_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques ClassAccount (r:0 w:1) fn force_create() -> Weight { - (19_528_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(19_528_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques Asset (r:1 w:0) @@ -320,191 +320,191 @@ impl WeightInfo for () { /// The range of component `m` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 25_000 - .saturating_add((13_639_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(Weight::from_ref_time(13_639_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) // Standard Error: 25_000 - .saturating_add((2_393_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(2_393_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight)) // Standard Error: 25_000 - .saturating_add((2_217_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(m as Weight))) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(a as Weight))) + .saturating_add(Weight::from_ref_time(2_217_000 as RefTimeWeight).scalar_saturating_mul(a as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((2 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(m as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(a as RefTimeWeight))) } // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques Class (r:1 w:1) // Storage: Uniques CollectionMaxSupply (r:1 w:0) // Storage: Uniques Account (r:0 w:1) fn mint() -> Weight { - (42_146_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(42_146_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques Account (r:0 w:1) // Storage: Uniques ItemPriceOf (r:0 w:1) fn burn() -> Weight { - (42_960_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(42_960_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:0) // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques Account (r:0 w:2) // Storage: Uniques ItemPriceOf (r:0 w:1) fn transfer() -> Weight { - (33_025_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(33_025_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques Asset (r:100 w:100) /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { - (0 as Weight) + Weight::from_ref_time(0 as RefTimeWeight) // Standard Error: 24_000 - .saturating_add((15_540_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(i as Weight))) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + .saturating_add(Weight::from_ref_time(15_540_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight))) } // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques Class (r:1 w:0) fn freeze() -> Weight { - (25_194_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_194_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques Class (r:1 w:0) fn thaw() -> Weight { - (25_397_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_397_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) fn freeze_collection() -> Weight { - (19_278_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_278_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) fn thaw_collection() -> Weight { - (19_304_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_304_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques OwnershipAcceptance (r:1 w:1) // Storage: Uniques Class (r:1 w:1) // Storage: Uniques ClassAccount (r:0 w:2) fn transfer_ownership() -> Weight { - (28_615_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(28_615_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) fn set_team() -> Weight { - (19_943_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_943_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques ClassAccount (r:0 w:1) fn force_item_status() -> Weight { - (22_583_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(22_583_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques InstanceMetadataOf (r:1 w:0) // Storage: Uniques Attribute (r:1 w:1) fn set_attribute() -> Weight { - (47_520_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(47_520_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques InstanceMetadataOf (r:1 w:0) // Storage: Uniques Attribute (r:1 w:1) fn clear_attribute() -> Weight { - (45_316_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(45_316_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques InstanceMetadataOf (r:1 w:1) fn set_metadata() -> Weight { - (38_391_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_391_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques InstanceMetadataOf (r:1 w:1) fn clear_metadata() -> Weight { - (38_023_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_023_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:1) // Storage: Uniques ClassMetadataOf (r:1 w:1) fn set_collection_metadata() -> Weight { - (37_398_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(37_398_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:0) // Storage: Uniques ClassMetadataOf (r:1 w:1) fn clear_collection_metadata() -> Weight { - (35_621_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(35_621_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:0) // Storage: Uniques Asset (r:1 w:1) fn approve_transfer() -> Weight { - (25_856_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(25_856_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Class (r:1 w:0) // Storage: Uniques Asset (r:1 w:1) fn cancel_approval() -> Weight { - (26_098_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(26_098_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques OwnershipAcceptance (r:1 w:1) fn set_accept_ownership() -> Weight { - (24_076_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(24_076_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques CollectionMaxSupply (r:1 w:1) // Storage: Uniques Class (r:1 w:0) fn set_collection_max_supply() -> Weight { - (22_035_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_035_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Asset (r:1 w:0) // Storage: Uniques ItemPriceOf (r:0 w:1) fn set_price() -> Weight { - (22_534_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_534_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight)) } // Storage: Uniques Asset (r:1 w:1) // Storage: Uniques ItemPriceOf (r:1 w:1) // Storage: Uniques Class (r:1 w:0) // Storage: Uniques Account (r:0 w:2) fn buy_item() -> Weight { - (45_272_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(45_272_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } } diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 0aae2615702dd..3df12d69e84eb 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -185,7 +185,7 @@ pub mod pallet { let dispatch_infos = calls.iter().map(|call| call.get_dispatch_info()).collect::>(); let dispatch_weight = dispatch_infos.iter() .map(|di| di.weight) - .fold(0, |total: Weight, weight: Weight| total.saturating_add(weight)) + .fold(Weight::new(), |total: Weight, weight: Weight| total.saturating_add(weight)) .saturating_add(T::WeightInfo::batch(calls.len() as u32)); let dispatch_class = { let all_operational = dispatch_infos.iter() @@ -208,7 +208,7 @@ pub mod pallet { ensure!(calls_len <= Self::batched_calls_limit() as usize, Error::::TooManyCalls); // Track the actual weight of each of the batch calls. - let mut weight: Weight = 0; + let mut weight = Weight::new(); for (index, call) in calls.into_iter().enumerate() { let info = call.get_dispatch_info(); // If origin is root, don't apply any dispatch filters; root can call anything. @@ -253,9 +253,9 @@ pub mod pallet { let dispatch_info = call.get_dispatch_info(); ( T::WeightInfo::as_derivative() - .saturating_add(dispatch_info.weight) // AccountData for inner call origin accountdata. - .saturating_add(T::DbWeight::get().reads_writes(1, 1)), + .saturating_add(T::DbWeight::get().reads_writes(1, 1)) + .saturating_add(dispatch_info.weight), dispatch_info.class, ) })] @@ -301,7 +301,7 @@ pub mod pallet { let dispatch_infos = calls.iter().map(|call| call.get_dispatch_info()).collect::>(); let dispatch_weight = dispatch_infos.iter() .map(|di| di.weight) - .fold(0, |total: Weight, weight: Weight| total.saturating_add(weight)) + .fold(Weight::new(), |total: Weight, weight: Weight| total.saturating_add(weight)) .saturating_add(T::WeightInfo::batch_all(calls.len() as u32)); let dispatch_class = { let all_operational = dispatch_infos.iter() @@ -324,7 +324,7 @@ pub mod pallet { ensure!(calls_len <= Self::batched_calls_limit() as usize, Error::::TooManyCalls); // Track the actual weight of each of the batch calls. - let mut weight: Weight = 0; + let mut weight = Weight::new(); for (index, call) in calls.into_iter().enumerate() { let info = call.get_dispatch_info(); // If origin is root, bypass any dispatch filter; root can call anything. @@ -352,7 +352,7 @@ pub mod pallet { } Self::deposit_event(Event::BatchCompleted); let base_weight = T::WeightInfo::batch_all(calls_len as u32); - Ok(Some(base_weight + weight).into()) + Ok(Some(base_weight.saturating_add(weight)).into()) } /// Dispatches a function call with a provided origin. @@ -406,7 +406,7 @@ pub mod pallet { let dispatch_infos = calls.iter().map(|call| call.get_dispatch_info()).collect::>(); let dispatch_weight = dispatch_infos.iter() .map(|di| di.weight) - .fold(0, |total: Weight, weight: Weight| total.saturating_add(weight)) + .fold(Weight::zero(), |total: Weight, weight: Weight| total.saturating_add(weight)) .saturating_add(T::WeightInfo::force_batch(calls.len() as u32)); let dispatch_class = { let all_operational = dispatch_infos.iter() @@ -429,7 +429,7 @@ pub mod pallet { ensure!(calls_len <= Self::batched_calls_limit() as usize, Error::::TooManyCalls); // Track the actual weight of each of the batch calls. - let mut weight: Weight = 0; + let mut weight = Weight::new(); // Track failed dispatch occur. let mut has_error: bool = false; for call in calls.into_iter() { @@ -455,7 +455,7 @@ pub mod pallet { Self::deposit_event(Event::BatchCompleted); } let base_weight = T::WeightInfo::batch(calls_len as u32); - Ok(Some(base_weight + weight).into()) + Ok(Some(base_weight.saturating_add(weight)).into()) } } } diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 6368473ac8708..e3b16b5244fc0 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -99,7 +99,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(Weight::max_value()); + frame_system::limits::BlockWeights::simple_max(Weight::MAX); } impl frame_system::Config for Test { type BaseCallFilter = TestBaseCallFilter; @@ -191,7 +191,7 @@ fn call_transfer(dest: u64, value: u64) -> Call { Call::Balances(BalancesCall::transfer { dest, value }) } -fn call_foobar(err: bool, start_weight: u64, end_weight: Option) -> Call { +fn call_foobar(err: bool, start_weight: Weight, end_weight: Option) -> Call { Call::Example(ExampleCall::foobar { err, start_weight, end_weight }) } @@ -213,8 +213,8 @@ fn as_derivative_works() { #[test] fn as_derivative_handles_weight_refund() { new_test_ext().execute_with(|| { - let start_weight = 100; - let end_weight = 75; + let start_weight = Weight::from_ref_time(100); + let end_weight = Weight::from_ref_time(75); let diff = start_weight - end_weight; // Full weight when ok @@ -364,24 +364,24 @@ fn batch_weight_calculation_doesnt_overflow() { use sp_runtime::Perbill; new_test_ext().execute_with(|| { let big_call = Call::System(SystemCall::fill_block { ratio: Perbill::from_percent(50) }); - assert_eq!(big_call.get_dispatch_info().weight, Weight::max_value() / 2); + assert_eq!(big_call.get_dispatch_info().weight, Weight::MAX / 2); // 3 * 50% saturates to 100% let batch_call = Call::Utility(crate::Call::batch { calls: vec![big_call.clone(), big_call.clone(), big_call.clone()], }); - assert_eq!(batch_call.get_dispatch_info().weight, Weight::max_value()); + assert_eq!(batch_call.get_dispatch_info().weight, Weight::MAX); }); } #[test] fn batch_handles_weight_refund() { new_test_ext().execute_with(|| { - let start_weight = 100; - let end_weight = 75; + let start_weight = Weight::from_ref_time(100); + let end_weight = Weight::from_ref_time(75); let diff = start_weight - end_weight; - let batch_len: Weight = 4; + let batch_len = 4; // Full weight when ok let inner_call = call_foobar(false, start_weight, None); @@ -420,7 +420,7 @@ fn batch_handles_weight_refund() { let good_call = call_foobar(false, start_weight, Some(end_weight)); let bad_call = call_foobar(true, start_weight, Some(end_weight)); let batch_calls = vec![good_call, bad_call]; - let batch_len = batch_calls.len() as Weight; + let batch_len = Weight::from_ref_time(batch_calls.len() as u64); let call = Call::Utility(UtilityCall::batch { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); @@ -494,10 +494,10 @@ fn batch_all_revert() { #[test] fn batch_all_handles_weight_refund() { new_test_ext().execute_with(|| { - let start_weight = 100; - let end_weight = 75; + let start_weight = Weight::from_ref_time(100); + let end_weight = Weight::from_ref_time(75); let diff = start_weight - end_weight; - let batch_len: Weight = 4; + let batch_len = 4; // Full weight when ok let inner_call = call_foobar(false, start_weight, None); @@ -533,7 +533,7 @@ fn batch_all_handles_weight_refund() { let good_call = call_foobar(false, start_weight, Some(end_weight)); let bad_call = call_foobar(true, start_weight, Some(end_weight)); let batch_calls = vec![good_call, bad_call]; - let batch_len = batch_calls.len() as Weight; + let batch_len = Weight::from_ref_time(batch_calls.len() as u64); let call = Call::Utility(UtilityCall::batch_all { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); @@ -616,7 +616,7 @@ fn force_batch_works() { Origin::signed(1), vec![ call_transfer(2, 5), - call_foobar(true, 75, None), + call_foobar(true, Weight::from_ref_time(75), None), call_transfer(2, 10), call_transfer(2, 5), ] diff --git a/frame/utility/src/weights.rs b/frame/utility/src/weights.rs index 3660a54fb6a8f..0f0d171d8d4ee 100644 --- a/frame/utility/src/weights.rs +++ b/frame/utility/src/weights.rs @@ -41,7 +41,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_utility. @@ -58,27 +58,27 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 1000]`. fn batch(c: u32, ) -> Weight { - (23_113_000 as Weight) + Weight::from_ref_time(23_113_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((2_701_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(Weight::from_ref_time(2_701_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) } fn as_derivative() -> Weight { - (4_182_000 as Weight) + Weight::from_ref_time(4_182_000 as RefTimeWeight) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { - (18_682_000 as Weight) + Weight::from_ref_time(18_682_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((2_794_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(Weight::from_ref_time(2_794_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) } fn dispatch_as() -> Weight { - (12_049_000 as Weight) + Weight::from_ref_time(12_049_000 as RefTimeWeight) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { - (19_136_000 as Weight) + Weight::from_ref_time(19_136_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((2_697_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(Weight::from_ref_time(2_697_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) } } @@ -86,26 +86,26 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { /// The range of component `c` is `[0, 1000]`. fn batch(c: u32, ) -> Weight { - (23_113_000 as Weight) + Weight::from_ref_time(23_113_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((2_701_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(Weight::from_ref_time(2_701_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) } fn as_derivative() -> Weight { - (4_182_000 as Weight) + Weight::from_ref_time(4_182_000 as RefTimeWeight) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { - (18_682_000 as Weight) + Weight::from_ref_time(18_682_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((2_794_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(Weight::from_ref_time(2_794_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) } fn dispatch_as() -> Weight { - (12_049_000 as Weight) + Weight::from_ref_time(12_049_000 as RefTimeWeight) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { - (19_136_000 as Weight) + Weight::from_ref_time(19_136_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((2_697_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(Weight::from_ref_time(2_697_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight)) } } diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 9ad8e57500e89..8875404f03fa2 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -45,7 +45,7 @@ frame_support::construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type AccountData = pallet_balances::AccountData; diff --git a/frame/vesting/src/weights.rs b/frame/vesting/src/weights.rs index 4596157e63b7b..bd3af72cdd182 100644 --- a/frame/vesting/src/weights.rs +++ b/frame/vesting/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_vesting. @@ -60,96 +60,96 @@ impl WeightInfo for SubstrateWeight { // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vest_locked(l: u32, s: u32, ) -> Weight { - (32_978_000 as Weight) + Weight::from_ref_time(32_978_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((82_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(82_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((88_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)) + .saturating_add(Weight::from_ref_time(88_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vest_unlocked(l: u32, s: u32, ) -> Weight { - (32_856_000 as Weight) + Weight::from_ref_time(32_856_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((79_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(79_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((56_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)) + .saturating_add(Weight::from_ref_time(56_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn vest_other_locked(l: u32, s: u32, ) -> Weight { - (33_522_000 as Weight) + Weight::from_ref_time(33_522_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((74_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(74_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((72_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(72_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn vest_other_unlocked(l: u32, s: u32, ) -> Weight { - (32_558_000 as Weight) + Weight::from_ref_time(32_558_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((78_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(78_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((61_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(61_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vested_transfer(l: u32, s: u32, ) -> Weight { - (49_260_000 as Weight) + Weight::from_ref_time(49_260_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((80_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(80_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 3_000 - .saturating_add((55_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(55_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:2 w:2) // Storage: Balances Locks (r:1 w:1) fn force_vested_transfer(l: u32, s: u32, ) -> Weight { - (49_166_000 as Weight) + Weight::from_ref_time(49_166_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((77_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(77_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 4_000 - .saturating_add((43_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(43_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - (34_042_000 as Weight) + Weight::from_ref_time(34_042_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((83_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(83_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((80_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(80_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - (33_937_000 as Weight) + Weight::from_ref_time(33_937_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((78_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(78_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((73_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(73_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } } @@ -158,95 +158,95 @@ impl WeightInfo for () { // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vest_locked(l: u32, s: u32, ) -> Weight { - (32_978_000 as Weight) + Weight::from_ref_time(32_978_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((82_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(82_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((88_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(88_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vest_unlocked(l: u32, s: u32, ) -> Weight { - (32_856_000 as Weight) + Weight::from_ref_time(32_856_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((79_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(79_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((56_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(56_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn vest_other_locked(l: u32, s: u32, ) -> Weight { - (33_522_000 as Weight) + Weight::from_ref_time(33_522_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((74_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(74_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((72_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(72_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn vest_other_unlocked(l: u32, s: u32, ) -> Weight { - (32_558_000 as Weight) + Weight::from_ref_time(32_558_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((78_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(78_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((61_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(61_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vested_transfer(l: u32, s: u32, ) -> Weight { - (49_260_000 as Weight) + Weight::from_ref_time(49_260_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((80_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(80_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 3_000 - .saturating_add((55_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(55_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:2 w:2) // Storage: Balances Locks (r:1 w:1) fn force_vested_transfer(l: u32, s: u32, ) -> Weight { - (49_166_000 as Weight) + Weight::from_ref_time(49_166_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add((77_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(77_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 4_000 - .saturating_add((43_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + .saturating_add(Weight::from_ref_time(43_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - (34_042_000 as Weight) + Weight::from_ref_time(34_042_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((83_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(83_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((80_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(80_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - (33_937_000 as Weight) + Weight::from_ref_time(33_937_000 as RefTimeWeight) // Standard Error: 1_000 - .saturating_add((78_000 as Weight).saturating_mul(l as Weight)) + .saturating_add(Weight::from_ref_time(78_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight)) // Standard Error: 2_000 - .saturating_add((73_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(73_000 as RefTimeWeight).scalar_saturating_mul(s as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } } diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index 634db53a09a4e..b18236099d445 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -51,7 +51,7 @@ construct_runtime!( parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024)); } impl frame_system::Config for Test { type BaseCallFilter = Nothing; diff --git a/frame/whitelist/src/tests.rs b/frame/whitelist/src/tests.rs index 67bccaeaeebe1..3e20cd29efb4f 100644 --- a/frame/whitelist/src/tests.rs +++ b/frame/whitelist/src/tests.rs @@ -19,7 +19,9 @@ use crate::mock::*; use codec::Encode; -use frame_support::{assert_noop, assert_ok, dispatch::GetDispatchInfo, traits::PreimageProvider}; +use frame_support::{ + assert_noop, assert_ok, dispatch::GetDispatchInfo, traits::PreimageProvider, weights::Weight, +}; use sp_runtime::{traits::Hash, DispatchError}; #[test] @@ -94,7 +96,11 @@ fn test_whitelist_call_and_execute() { assert!(Preimage::preimage_requested(&call_hash)); assert_noop!( - Whitelist::dispatch_whitelisted_call(Origin::root(), call_hash, call_weight - 1), + Whitelist::dispatch_whitelisted_call( + Origin::root(), + call_hash, + call_weight - Weight::one() + ), crate::Error::::InvalidCallWeightWitness, ); @@ -114,7 +120,7 @@ fn test_whitelist_call_and_execute_failing_call() { new_test_ext().execute_with(|| { let call = Call::Whitelist(crate::Call::dispatch_whitelisted_call { call_hash: Default::default(), - call_weight_witness: 0, + call_weight_witness: Weight::zero(), }); let call_weight = call.get_dispatch_info().weight; let encoded_call = call.encode(); diff --git a/frame/whitelist/src/weights.rs b/frame/whitelist/src/weights.rs index 81482c35e3de8..bb2ed9700c833 100644 --- a/frame/whitelist/src/weights.rs +++ b/frame/whitelist/src/weights.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_whitelist. @@ -56,35 +56,35 @@ impl WeightInfo for SubstrateWeight { // Storage: Whitelist WhitelistedCall (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn whitelist_call() -> Weight { - (20_938_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(20_938_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Whitelist WhitelistedCall (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn remove_whitelisted_call() -> Weight { - (22_332_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(22_332_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Whitelist WhitelistedCall (r:1 w:1) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn dispatch_whitelisted_call() -> Weight { - (5_989_917_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(5_989_917_000 as RefTimeWeight) + .saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Whitelist WhitelistedCall (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight { - (25_325_000 as Weight) + Weight::from_ref_time(25_325_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight)) } } @@ -93,34 +93,34 @@ impl WeightInfo for () { // Storage: Whitelist WhitelistedCall (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn whitelist_call() -> Weight { - (20_938_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(20_938_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight)) } // Storage: Whitelist WhitelistedCall (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn remove_whitelisted_call() -> Weight { - (22_332_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(22_332_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Whitelist WhitelistedCall (r:1 w:1) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn dispatch_whitelisted_call() -> Weight { - (5_989_917_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(5_989_917_000 as RefTimeWeight) + .saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } // Storage: Whitelist WhitelistedCall (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight { - (25_325_000 as Weight) + Weight::from_ref_time(25_325_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight)) + .saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight)) } } diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index aa436f1ad2a91..181e3fec62b24 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -39,7 +39,7 @@ use cfg_if::cfg_if; use frame_support::{ parameter_types, traits::{ConstU32, ConstU64, CrateVersion, KeyOwnerProofSystem}, - weights::RuntimeDbWeight, + weights::{RuntimeDbWeight, Weight}, }; use frame_system::limits::{BlockLength, BlockWeights}; use sp_api::{decl_runtime_apis, impl_runtime_apis}; @@ -577,7 +577,7 @@ parameter_types! { pub RuntimeBlockLength: BlockLength = BlockLength::max(4 * 1024 * 1024); pub RuntimeBlockWeights: BlockWeights = - BlockWeights::with_sensible_defaults(4 * 1024 * 1024, Perbill::from_percent(75)); + BlockWeights::with_sensible_defaults(Weight::from_ref_time(4 * 1024 * 1024), Perbill::from_percent(75)); } impl frame_system::Config for Runtime { diff --git a/utils/frame/benchmarking-cli/src/block/bench.rs b/utils/frame/benchmarking-cli/src/block/bench.rs index e48a7e8b3c6f5..36215c8a0586d 100644 --- a/utils/frame/benchmarking-cli/src/block/bench.rs +++ b/utils/frame/benchmarking-cli/src/block/bench.rs @@ -142,7 +142,8 @@ where let weight = ConsumedWeight::decode_all(&mut raw_weight)?; // Should be divisible, but still use floats in case we ever change that. - Ok((weight.total() as f64 / WEIGHT_PER_NANOS as f64).floor() as NanoSeconds) + Ok((weight.total().ref_time() as f64 / WEIGHT_PER_NANOS.ref_time() as f64).floor() + as NanoSeconds) } /// Prints the weight info of a block to the console. diff --git a/utils/frame/benchmarking-cli/src/overhead/README.md b/utils/frame/benchmarking-cli/src/overhead/README.md index 6f41e881d0572..a1da5da0d0792 100644 --- a/utils/frame/benchmarking-cli/src/overhead/README.md +++ b/utils/frame/benchmarking-cli/src/overhead/README.md @@ -1,21 +1,21 @@ # The `benchmark overhead` command -Each time an extrinsic or a block is executed, a fixed weight is charged as "execution overhead". -This is necessary since the weight that is calculated by the pallet benchmarks does not include this overhead. -The exact overhead to can vary per Substrate chain and needs to be calculated per chain. +Each time an extrinsic or a block is executed, a fixed weight is charged as "execution overhead". +This is necessary since the weight that is calculated by the pallet benchmarks does not include this overhead. +The exact overhead to can vary per Substrate chain and needs to be calculated per chain. This command calculates the exact values of these overhead weights for any Substrate chain that supports it. ## How does it work? -The benchmark consists of two parts; the [`BlockExecutionWeight`] and the [`ExtrinsicBaseWeight`]. +The benchmark consists of two parts; the [`BlockExecutionWeight`] and the [`ExtrinsicBaseWeight`]. Both are executed sequentially when invoking the command. ## BlockExecutionWeight -The block execution weight is defined as the weight that it takes to execute an *empty block*. -It is measured by constructing an empty block and measuring its executing time. -The result are written to a `block_weights.rs` file which is created from a template. -The file will contain the concrete weight value and various statistics about the measurements. For example: +The block execution weight is defined as the weight that it takes to execute an *empty block*. +It is measured by constructing an empty block and measuring its executing time. +The result are written to a `block_weights.rs` file which is created from a template. +The file will contain the concrete weight value and various statistics about the measurements. For example: ```rust /// Time to execute an empty block. /// Calculated by multiplying the *Average* with `1` and adding `0`. @@ -30,21 +30,21 @@ The file will contain the concrete weight value and various statistics about the /// 99th: 3_631_863 /// 95th: 3_595_674 /// 75th: 3_526_435 -pub const BlockExecutionWeight: Weight = 3_532_484 * WEIGHT_PER_NANOS; +pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.scalar_saturating_mul(3_532_484); ``` -In this example it takes 3.5 ms to execute an empty block. That means that it always takes at least 3.5 ms to execute *any* block. +In this example it takes 3.5 ms to execute an empty block. That means that it always takes at least 3.5 ms to execute *any* block. This constant weight is therefore added to each block to ensure that Substrate budgets enough time to execute it. ## ExtrinsicBaseWeight -The extrinsic base weight is defined as the weight that it takes to execute an *empty* extrinsic. -An *empty* extrinsic is also called a *NO-OP*. It does nothing and is the equivalent to the empty block form above. +The extrinsic base weight is defined as the weight that it takes to execute an *empty* extrinsic. +An *empty* extrinsic is also called a *NO-OP*. It does nothing and is the equivalent to the empty block form above. The benchmark now constructs a block which is filled with only NO-OP extrinsics. -This block is then executed many times and the weights are measured. -The result is divided by the number of extrinsics in that block and the results are written to `extrinsic_weights.rs`. +This block is then executed many times and the weights are measured. +The result is divided by the number of extrinsics in that block and the results are written to `extrinsic_weights.rs`. -The relevant section in the output file looks like this: +The relevant section in the output file looks like this: ```rust /// Time to execute a NO-OP extrinsic, for example `System::remark`. /// Calculated by multiplying the *Average* with `1` and adding `0`. @@ -59,10 +59,10 @@ The relevant section in the output file looks like this: /// 99th: 68_758 /// 95th: 67_843 /// 75th: 67_749 -pub const ExtrinsicBaseWeight: Weight = 67_745 * WEIGHT_PER_NANOS; +pub const ExtrinsicBaseWeight: Weight = Weight::from_ref_time(67_745 * WEIGHT_PER_NANOS); ``` -In this example it takes 67.7 µs to execute a NO-OP extrinsic. That means that it always takes at least 67.7 µs to execute *any* extrinsic. +In this example it takes 67.7 µs to execute a NO-OP extrinsic. That means that it always takes at least 67.7 µs to execute *any* extrinsic. This constant weight is therefore added to each extrinsic to ensure that Substrate budgets enough time to execute it. ## Invocation @@ -76,48 +76,48 @@ Output: ```pre # BlockExecutionWeight Running 10 warmups... -Executing block 100 times +Executing block 100 times Per-block execution overhead [ns]: Total: 353248430 Min: 3508416, Max: 3680498 Average: 3532484, Median: 3522111, Stddev: 27070.23 -Percentiles 99th, 95th, 75th: 3631863, 3595674, 3526435 +Percentiles 99th, 95th, 75th: 3631863, 3595674, 3526435 Writing weights to "block_weights.rs" # Setup -Building block, this takes some time... +Building block, this takes some time... Extrinsics per block: 12000 # ExtrinsicBaseWeight Running 10 warmups... -Executing block 100 times +Executing block 100 times Per-extrinsic execution overhead [ns]: Total: 6774590 Min: 67561, Max: 69855 Average: 67745, Median: 67701, Stddev: 264.68 -Percentiles 99th, 95th, 75th: 68758, 67843, 67749 +Percentiles 99th, 95th, 75th: 68758, 67843, 67749 Writing weights to "extrinsic_weights.rs" ``` -The complete command for Polkadot looks like this: +The complete command for Polkadot looks like this: ```sh cargo run --profile=production -- benchmark overhead --chain=polkadot-dev --execution=wasm --wasm-execution=compiled --weight-path=runtime/polkadot/constants/src/weights/ ``` -This will overwrite the the [block_weights.rs](https://github.com/paritytech/polkadot/blob/c254e5975711a6497af256f6831e9a6c752d28f5/runtime/polkadot/constants/src/weights/block_weights.rs) and [extrinsic_weights.rs](https://github.com/paritytech/polkadot/blob/c254e5975711a6497af256f6831e9a6c752d28f5/runtime/polkadot/constants/src/weights/extrinsic_weights.rs) files in the Polkadot runtime directory. -You can try the same for *Rococo* and to see that the results slightly differ. +This will overwrite the the [block_weights.rs](https://github.com/paritytech/polkadot/blob/c254e5975711a6497af256f6831e9a6c752d28f5/runtime/polkadot/constants/src/weights/block_weights.rs) and [extrinsic_weights.rs](https://github.com/paritytech/polkadot/blob/c254e5975711a6497af256f6831e9a6c752d28f5/runtime/polkadot/constants/src/weights/extrinsic_weights.rs) files in the Polkadot runtime directory. +You can try the same for *Rococo* and to see that the results slightly differ. 👉 It is paramount to use `--profile=production`, `--execution=wasm` and `--wasm-execution=compiled` as the results are otherwise useless. ## Output Interpretation -Lower is better. The less weight the execution overhead needs, the better. -Since the weights of the overhead is charged per extrinsic and per block, a larger weight results in less extrinsics per block. +Lower is better. The less weight the execution overhead needs, the better. +Since the weights of the overhead is charged per extrinsic and per block, a larger weight results in less extrinsics per block. Minimizing this is important to have a large transaction throughput. ## Arguments -- `--chain` / `--dev` Set the chain specification. -- `--weight-path` Set the output directory or file to write the weights to. +- `--chain` / `--dev` Set the chain specification. +- `--weight-path` Set the output directory or file to write the weights to. - `--repeat` Set the repetitions of both benchmarks. - `--warmup` Set the rounds of warmup before measuring. - `--execution` Should be set to `wasm` for correct results. diff --git a/utils/frame/benchmarking-cli/src/overhead/weights.hbs b/utils/frame/benchmarking-cli/src/overhead/weights.hbs index f8312b0052592..d07533e9dbaa8 100644 --- a/utils/frame/benchmarking-cli/src/overhead/weights.hbs +++ b/utils/frame/benchmarking-cli/src/overhead/weights.hbs @@ -52,11 +52,12 @@ parameter_types! { /// 99th: {{underscore stats.p99}} /// 95th: {{underscore stats.p95}} /// 75th: {{underscore stats.p75}} - pub const {{long_name}}Weight: Weight = {{underscore weight}} * WEIGHT_PER_NANOS; + pub const {{long_name}}Weight: Weight = WEIGHT_PER_NANOS.scalar_saturating_mul({{underscore weight}}); } #[cfg(test)] mod test_weights { + use super::*; use frame_support::weights::constants; /// Checks that the weight exists and is sane. @@ -68,14 +69,14 @@ mod test_weights { {{#if (eq short_name "block")}} // At least 100 µs. - assert!(w >= 100 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs."); + assert!(w >= Weight::from_ref_time(100 * constants::WEIGHT_PER_MICROS), "Weight should be at least 100 µs."); // At most 50 ms. - assert!(w <= 50 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); + assert!(w <= Weight::from_ref_time(50 * constants::WEIGHT_PER_MILLIS), "Weight should be at most 50 ms."); {{else}} // At least 10 µs. - assert!(w >= 10 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); + assert!(w >= Weight::from_ref_time(10 * constants::WEIGHT_PER_MICROS), "Weight should be at least 10 µs."); // At most 1 ms. - assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); + assert!(w <= Weight::from_ref_time(constants::WEIGHT_PER_MILLIS), "Weight should be at most 1 ms."); {{/if}} } } diff --git a/utils/frame/benchmarking-cli/src/pallet/template.hbs b/utils/frame/benchmarking-cli/src/pallet/template.hbs index 688ad4d3934f5..bf18e23367bc9 100644 --- a/utils/frame/benchmarking-cli/src/pallet/template.hbs +++ b/utils/frame/benchmarking-cli/src/pallet/template.hbs @@ -15,7 +15,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight}}; use sp_std::marker::PhantomData; /// Weight functions for `{{pallet}}`. @@ -33,22 +33,22 @@ impl {{pallet}}::WeightInfo for WeightInfo { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - ({{underscore benchmark.base_weight}} as Weight) + Weight::from_ref_time({{underscore benchmark.base_weight}} as RefTimeWeight) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + .saturating_add(Weight::from_ref_time({{underscore cw.slope}} as RefTimeWeight).scalar_saturating_mul({{cw.name}} as RefTimeWeight)) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as RefTimeWeight)) {{/if}} {{#each benchmark.component_reads as |cr|}} - .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as RefTimeWeight).saturating_mul({{cr.name}} as RefTimeWeight))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight)) + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as RefTimeWeight)) {{/if}} {{#each benchmark.component_writes as |cw|}} - .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as RefTimeWeight).saturating_mul({{cw.name}} as RefTimeWeight))) {{/each}} } {{/each}}