mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 00:17:56 +00:00
Introduce sensible weight constants (#12868)
* Introduce sensible weight constants * cargo fmt * Remove unused import * Add missing import * ".git/.scripts/bench-bot.sh" pallet dev pallet_lottery Co-authored-by: command-bot <>
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
//! This file was not auto-generated.
|
||||
|
||||
use frame_support::weights::{
|
||||
constants::{RocksDbWeight as DbWeight, WEIGHT_PER_MICROS, WEIGHT_PER_NANOS},
|
||||
constants::{RocksDbWeight as DbWeight, WEIGHT_REF_TIME_PER_MICROS, WEIGHT_REF_TIME_PER_NANOS},
|
||||
Weight,
|
||||
};
|
||||
|
||||
@@ -38,17 +38,20 @@ impl crate::WeightInfo for () {
|
||||
const MAX_NOMINATORS: u64 = 200;
|
||||
|
||||
// checking membership proof
|
||||
let ref_time_weight = (35u64 * WEIGHT_PER_MICROS)
|
||||
.saturating_add((175u64 * WEIGHT_PER_NANOS).saturating_mul(validator_count))
|
||||
Weight::from_ref_time(35u64 * WEIGHT_REF_TIME_PER_MICROS)
|
||||
.saturating_add(
|
||||
Weight::from_ref_time(175u64 * WEIGHT_REF_TIME_PER_NANOS)
|
||||
.saturating_mul(validator_count),
|
||||
)
|
||||
.saturating_add(DbWeight::get().reads(5))
|
||||
// check equivocation proof
|
||||
.saturating_add(110u64 * WEIGHT_PER_MICROS)
|
||||
.saturating_add(Weight::from_ref_time(110u64 * WEIGHT_REF_TIME_PER_MICROS))
|
||||
// report offence
|
||||
.saturating_add(110u64 * WEIGHT_PER_MICROS)
|
||||
.saturating_add(25u64 * WEIGHT_PER_MICROS * MAX_NOMINATORS)
|
||||
.saturating_add(Weight::from_ref_time(110u64 * WEIGHT_REF_TIME_PER_MICROS))
|
||||
.saturating_add(Weight::from_ref_time(
|
||||
25u64 * WEIGHT_REF_TIME_PER_MICROS * MAX_NOMINATORS,
|
||||
))
|
||||
.saturating_add(DbWeight::get().reads(14 + 3 * MAX_NOMINATORS))
|
||||
.saturating_add(DbWeight::get().writes(10 + 3 * MAX_NOMINATORS));
|
||||
|
||||
ref_time_weight
|
||||
.saturating_add(DbWeight::get().writes(10 + 3 * MAX_NOMINATORS))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ use frame_support::{
|
||||
fungibles::Lockable, BalanceStatus, ConstU32, ConstU64, Contains, Currency, Get, OnIdle,
|
||||
OnInitialize, ReservableCurrency, WithdrawReasons,
|
||||
},
|
||||
weights::{constants::WEIGHT_PER_SECOND, Weight},
|
||||
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
|
||||
};
|
||||
use frame_system::{self as system, EventRecord, Phase};
|
||||
use pretty_assertions::{assert_eq, assert_ne};
|
||||
@@ -285,7 +285,7 @@ impl RegisteredChainExtension<Test> for TempStorageExtension {
|
||||
parameter_types! {
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
frame_system::limits::BlockWeights::simple_max(
|
||||
(2u64 * WEIGHT_PER_SECOND).set_proof_size(u64::MAX),
|
||||
Weight::from_parts(2u64 * WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
|
||||
);
|
||||
pub static ExistentialDeposit: u64 = 1;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,9 @@ impl Contains<RuntimeCall> for BaseFilter {
|
||||
|
||||
parameter_types! {
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
frame_system::limits::BlockWeights::simple_max(frame_support::weights::constants::WEIGHT_PER_SECOND.set_proof_size(u64::MAX));
|
||||
frame_system::limits::BlockWeights::simple_max(
|
||||
Weight::from_parts(frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
|
||||
);
|
||||
}
|
||||
impl frame_system::Config for Test {
|
||||
type BaseCallFilter = BaseFilter;
|
||||
|
||||
@@ -239,7 +239,7 @@ parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights
|
||||
::with_sensible_defaults(
|
||||
Weight::from_parts(2u64 * constants::WEIGHT_PER_SECOND.ref_time(), u64::MAX),
|
||||
Weight::from_parts(2u64 * constants::WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
|
||||
NORMAL_DISPATCH_RATIO,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ use frame_support::{
|
||||
pallet_prelude::*,
|
||||
parameter_types,
|
||||
traits::{ConstU64, Currency},
|
||||
weights::constants::WEIGHT_PER_SECOND,
|
||||
weights::constants::WEIGHT_REF_TIME_PER_SECOND,
|
||||
};
|
||||
use sp_runtime::traits::{Convert, IdentityLookup};
|
||||
|
||||
@@ -37,7 +37,7 @@ pub type T = Runtime;
|
||||
parameter_types! {
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
frame_system::limits::BlockWeights::simple_max(
|
||||
(2u64 * WEIGHT_PER_SECOND).set_proof_size(u64::MAX),
|
||||
Weight::from_parts(2u64 * WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//! This file was not auto-generated.
|
||||
|
||||
use frame_support::weights::{
|
||||
constants::{RocksDbWeight as DbWeight, WEIGHT_PER_MICROS, WEIGHT_PER_NANOS},
|
||||
constants::{RocksDbWeight as DbWeight, WEIGHT_REF_TIME_PER_MICROS, WEIGHT_REF_TIME_PER_NANOS},
|
||||
Weight,
|
||||
};
|
||||
|
||||
@@ -34,14 +34,19 @@ impl crate::WeightInfo for () {
|
||||
const MAX_NOMINATORS: u64 = 200;
|
||||
|
||||
// checking membership proof
|
||||
(35u64 * WEIGHT_PER_MICROS)
|
||||
.saturating_add((175u64 * WEIGHT_PER_NANOS).saturating_mul(validator_count))
|
||||
Weight::from_ref_time(35u64 * WEIGHT_REF_TIME_PER_MICROS)
|
||||
.saturating_add(
|
||||
Weight::from_ref_time(175u64 * WEIGHT_REF_TIME_PER_NANOS)
|
||||
.saturating_mul(validator_count),
|
||||
)
|
||||
.saturating_add(DbWeight::get().reads(5))
|
||||
// check equivocation proof
|
||||
.saturating_add(95u64 * WEIGHT_PER_MICROS)
|
||||
.saturating_add(Weight::from_ref_time(95u64 * WEIGHT_REF_TIME_PER_MICROS))
|
||||
// report offence
|
||||
.saturating_add(110u64 * WEIGHT_PER_MICROS)
|
||||
.saturating_add(25u64 * WEIGHT_PER_MICROS * MAX_NOMINATORS)
|
||||
.saturating_add(Weight::from_ref_time(110u64 * WEIGHT_REF_TIME_PER_MICROS))
|
||||
.saturating_add(Weight::from_ref_time(
|
||||
25u64 * WEIGHT_REF_TIME_PER_MICROS * MAX_NOMINATORS,
|
||||
))
|
||||
.saturating_add(DbWeight::get().reads(14 + 3 * MAX_NOMINATORS))
|
||||
.saturating_add(DbWeight::get().writes(10 + 3 * MAX_NOMINATORS))
|
||||
// fetching set id -> session index mappings
|
||||
@@ -49,6 +54,7 @@ impl crate::WeightInfo for () {
|
||||
}
|
||||
|
||||
fn note_stalled() -> Weight {
|
||||
(3u64 * WEIGHT_PER_MICROS).saturating_add(DbWeight::get().writes(1))
|
||||
Weight::from_ref_time(3u64 * WEIGHT_REF_TIME_PER_MICROS)
|
||||
.saturating_add(DbWeight::get().writes(1))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//! Autogenerated weights for pallet_lottery
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-11-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! DATE: 2022-12-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
|
||||
|
||||
@@ -67,33 +67,33 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: System Account (r:1 w:1)
|
||||
// Storage: Lottery Tickets (r:0 w:1)
|
||||
fn buy_ticket() -> Weight {
|
||||
// Minimum execution time: 53_735 nanoseconds.
|
||||
Weight::from_ref_time(54_235_000)
|
||||
// Minimum execution time: 52_479 nanoseconds.
|
||||
Weight::from_ref_time(53_225_000)
|
||||
.saturating_add(T::DbWeight::get().reads(6))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
// Storage: Lottery CallIndices (r:0 w:1)
|
||||
/// The range of component `n` is `[0, 10]`.
|
||||
fn set_calls(n: u32, ) -> Weight {
|
||||
// Minimum execution time: 15_065 nanoseconds.
|
||||
Weight::from_ref_time(16_467_398)
|
||||
// Standard Error: 5_392
|
||||
.saturating_add(Weight::from_ref_time(294_914).saturating_mul(n.into()))
|
||||
// Minimum execution time: 14_433 nanoseconds.
|
||||
Weight::from_ref_time(15_660_780)
|
||||
// Standard Error: 5_894
|
||||
.saturating_add(Weight::from_ref_time(290_482).saturating_mul(n.into()))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// 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 {
|
||||
// Minimum execution time: 45_990 nanoseconds.
|
||||
Weight::from_ref_time(46_789_000)
|
||||
// Minimum execution time: 43_683 nanoseconds.
|
||||
Weight::from_ref_time(44_580_000)
|
||||
.saturating_add(T::DbWeight::get().reads(3))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
// Storage: Lottery Lottery (r:1 w:1)
|
||||
fn stop_repeat() -> Weight {
|
||||
// Minimum execution time: 10_783 nanoseconds.
|
||||
Weight::from_ref_time(11_180_000)
|
||||
// Minimum execution time: 10_514 nanoseconds.
|
||||
Weight::from_ref_time(10_821_000)
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
@@ -103,8 +103,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Lottery TicketsCount (r:1 w:1)
|
||||
// Storage: Lottery Tickets (r:1 w:0)
|
||||
fn on_initialize_end() -> Weight {
|
||||
// Minimum execution time: 62_088 nanoseconds.
|
||||
Weight::from_ref_time(63_670_000)
|
||||
// Minimum execution time: 60_254 nanoseconds.
|
||||
Weight::from_ref_time(61_924_000)
|
||||
.saturating_add(T::DbWeight::get().reads(6))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
@@ -115,8 +115,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Lottery Tickets (r:1 w:0)
|
||||
// Storage: Lottery LotteryIndex (r:1 w:1)
|
||||
fn on_initialize_repeat() -> Weight {
|
||||
// Minimum execution time: 64_953 nanoseconds.
|
||||
Weight::from_ref_time(65_465_000)
|
||||
// Minimum execution time: 61_552 nanoseconds.
|
||||
Weight::from_ref_time(62_152_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(5))
|
||||
}
|
||||
@@ -132,33 +132,33 @@ impl WeightInfo for () {
|
||||
// Storage: System Account (r:1 w:1)
|
||||
// Storage: Lottery Tickets (r:0 w:1)
|
||||
fn buy_ticket() -> Weight {
|
||||
// Minimum execution time: 53_735 nanoseconds.
|
||||
Weight::from_ref_time(54_235_000)
|
||||
// Minimum execution time: 52_479 nanoseconds.
|
||||
Weight::from_ref_time(53_225_000)
|
||||
.saturating_add(RocksDbWeight::get().reads(6))
|
||||
.saturating_add(RocksDbWeight::get().writes(4))
|
||||
}
|
||||
// Storage: Lottery CallIndices (r:0 w:1)
|
||||
/// The range of component `n` is `[0, 10]`.
|
||||
fn set_calls(n: u32, ) -> Weight {
|
||||
// Minimum execution time: 15_065 nanoseconds.
|
||||
Weight::from_ref_time(16_467_398)
|
||||
// Standard Error: 5_392
|
||||
.saturating_add(Weight::from_ref_time(294_914).saturating_mul(n.into()))
|
||||
// Minimum execution time: 14_433 nanoseconds.
|
||||
Weight::from_ref_time(15_660_780)
|
||||
// Standard Error: 5_894
|
||||
.saturating_add(Weight::from_ref_time(290_482).saturating_mul(n.into()))
|
||||
.saturating_add(RocksDbWeight::get().writes(1))
|
||||
}
|
||||
// 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 {
|
||||
// Minimum execution time: 45_990 nanoseconds.
|
||||
Weight::from_ref_time(46_789_000)
|
||||
// Minimum execution time: 43_683 nanoseconds.
|
||||
Weight::from_ref_time(44_580_000)
|
||||
.saturating_add(RocksDbWeight::get().reads(3))
|
||||
.saturating_add(RocksDbWeight::get().writes(3))
|
||||
}
|
||||
// Storage: Lottery Lottery (r:1 w:1)
|
||||
fn stop_repeat() -> Weight {
|
||||
// Minimum execution time: 10_783 nanoseconds.
|
||||
Weight::from_ref_time(11_180_000)
|
||||
// Minimum execution time: 10_514 nanoseconds.
|
||||
Weight::from_ref_time(10_821_000)
|
||||
.saturating_add(RocksDbWeight::get().reads(1))
|
||||
.saturating_add(RocksDbWeight::get().writes(1))
|
||||
}
|
||||
@@ -168,8 +168,8 @@ impl WeightInfo for () {
|
||||
// Storage: Lottery TicketsCount (r:1 w:1)
|
||||
// Storage: Lottery Tickets (r:1 w:0)
|
||||
fn on_initialize_end() -> Weight {
|
||||
// Minimum execution time: 62_088 nanoseconds.
|
||||
Weight::from_ref_time(63_670_000)
|
||||
// Minimum execution time: 60_254 nanoseconds.
|
||||
Weight::from_ref_time(61_924_000)
|
||||
.saturating_add(RocksDbWeight::get().reads(6))
|
||||
.saturating_add(RocksDbWeight::get().writes(4))
|
||||
}
|
||||
@@ -180,8 +180,8 @@ impl WeightInfo for () {
|
||||
// Storage: Lottery Tickets (r:1 w:0)
|
||||
// Storage: Lottery LotteryIndex (r:1 w:1)
|
||||
fn on_initialize_repeat() -> Weight {
|
||||
// Minimum execution time: 64_953 nanoseconds.
|
||||
Weight::from_ref_time(65_465_000)
|
||||
// Minimum execution time: 61_552 nanoseconds.
|
||||
Weight::from_ref_time(62_152_000)
|
||||
.saturating_add(RocksDbWeight::get().reads(7))
|
||||
.saturating_add(RocksDbWeight::get().writes(5))
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//! This file was not auto-generated.
|
||||
|
||||
use frame_support::weights::{
|
||||
constants::{RocksDbWeight as DbWeight, WEIGHT_PER_NANOS},
|
||||
constants::{RocksDbWeight as DbWeight, WEIGHT_REF_TIME_PER_NANOS},
|
||||
Weight,
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ impl crate::WeightInfo for () {
|
||||
// Reading the parent hash.
|
||||
let leaf_weight = DbWeight::get().reads(1);
|
||||
// Blake2 hash cost.
|
||||
let hash_weight = 2u64 * WEIGHT_PER_NANOS;
|
||||
let hash_weight = Weight::from_ref_time(2u64 * WEIGHT_REF_TIME_PER_NANOS);
|
||||
// No-op hook.
|
||||
let hook_weight = Weight::zero();
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ use frame_election_provider_support::{onchain, SequentialPhragmen};
|
||||
use frame_support::{
|
||||
parameter_types,
|
||||
traits::{ConstU32, ConstU64},
|
||||
weights::constants::WEIGHT_PER_SECOND,
|
||||
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
|
||||
};
|
||||
use frame_system as system;
|
||||
use pallet_session::historical as pallet_session_historical;
|
||||
@@ -41,7 +41,7 @@ type Balance = u64;
|
||||
parameter_types! {
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
frame_system::limits::BlockWeights::simple_max(
|
||||
2u64 * WEIGHT_PER_SECOND
|
||||
Weight::from_parts(2u64 * WEIGHT_REF_TIME_PER_SECOND, u64::MAX)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ use frame_support::{
|
||||
parameter_types,
|
||||
traits::{ConstU32, ConstU64},
|
||||
weights::{
|
||||
constants::{RocksDbWeight, WEIGHT_PER_SECOND},
|
||||
constants::{RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND},
|
||||
Weight,
|
||||
},
|
||||
};
|
||||
@@ -85,7 +85,9 @@ frame_support::construct_runtime!(
|
||||
|
||||
parameter_types! {
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
frame_system::limits::BlockWeights::simple_max(2u64 * WEIGHT_PER_SECOND);
|
||||
frame_system::limits::BlockWeights::simple_max(
|
||||
Weight::from_parts(2u64 * WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
|
||||
);
|
||||
}
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
|
||||
@@ -115,7 +115,7 @@ impl FindAuthor<AccountId> for Author11 {
|
||||
parameter_types! {
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
frame_system::limits::BlockWeights::simple_max(
|
||||
frame_support::weights::constants::WEIGHT_PER_SECOND * 2
|
||||
Weight::from_parts(frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND * 2, u64::MAX),
|
||||
);
|
||||
pub static SessionsPerEra: SessionIndex = 3;
|
||||
pub static ExistentialDeposit: Balance = 1;
|
||||
|
||||
@@ -4365,9 +4365,10 @@ mod election_data_provider {
|
||||
#[test]
|
||||
fn targets_2sec_block() {
|
||||
let mut validators = 1000;
|
||||
while <Test as Config>::WeightInfo::get_npos_targets(validators)
|
||||
.all_lt(2u64 * frame_support::weights::constants::WEIGHT_PER_SECOND)
|
||||
{
|
||||
while <Test as Config>::WeightInfo::get_npos_targets(validators).all_lt(Weight::from_parts(
|
||||
2u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND,
|
||||
u64::MAX,
|
||||
)) {
|
||||
validators += 1;
|
||||
}
|
||||
|
||||
@@ -4384,8 +4385,10 @@ mod election_data_provider {
|
||||
let mut nominators = 1000;
|
||||
|
||||
while <Test as Config>::WeightInfo::get_npos_voters(validators, nominators, slashing_spans)
|
||||
.all_lt(2u64 * frame_support::weights::constants::WEIGHT_PER_SECOND)
|
||||
{
|
||||
.all_lt(Weight::from_parts(
|
||||
2u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND,
|
||||
u64::MAX,
|
||||
)) {
|
||||
nominators += 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
// --repeat=100
|
||||
|
||||
use sp_core::parameter_types;
|
||||
use sp_weights::{constants::WEIGHT_PER_NANOS, Weight};
|
||||
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
|
||||
|
||||
parameter_types! {
|
||||
/// Time to execute an empty block.
|
||||
@@ -53,7 +53,8 @@ parameter_types! {
|
||||
/// 99th: 390_723
|
||||
/// 95th: 365_799
|
||||
/// 75th: 361_582
|
||||
pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(358_523);
|
||||
pub const BlockExecutionWeight: Weight =
|
||||
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(358_523));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -69,12 +70,12 @@ mod test_weights {
|
||||
|
||||
// At least 100 µs.
|
||||
assert!(
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Weight should be at least 100 µs."
|
||||
);
|
||||
// At most 50 ms.
|
||||
assert!(
|
||||
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Weight should be at most 50 ms."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
// --repeat=100
|
||||
|
||||
use sp_core::parameter_types;
|
||||
use sp_weights::{constants::WEIGHT_PER_NANOS, Weight};
|
||||
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
|
||||
|
||||
parameter_types! {
|
||||
/// Time to execute a NO-OP extrinsic, for example `System::remark`.
|
||||
@@ -53,7 +53,8 @@ parameter_types! {
|
||||
/// 99th: 99_202
|
||||
/// 95th: 99_163
|
||||
/// 75th: 99_030
|
||||
pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(98_974);
|
||||
pub const ExtrinsicBaseWeight: Weight =
|
||||
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(98_974));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -69,12 +70,12 @@ mod test_weights {
|
||||
|
||||
// At least 10 µs.
|
||||
assert!(
|
||||
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Weight should be at least 10 µs."
|
||||
);
|
||||
// At most 1 ms.
|
||||
assert!(
|
||||
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Weight should be at most 1 ms."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,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.ref_time(),
|
||||
write: 50_000 * constants::WEIGHT_PER_NANOS.ref_time(),
|
||||
read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,20 +41,20 @@ pub mod constants {
|
||||
fn sane() {
|
||||
// At least 1 µs.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Read weight should be at least 1 µs."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Write weight should be at least 1 µs."
|
||||
);
|
||||
// At most 1 ms.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Read weight should be at most 1 ms."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Write weight should be at most 1 ms."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,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.ref_time(),
|
||||
write: 100_000 * constants::WEIGHT_PER_NANOS.ref_time(),
|
||||
read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,20 +41,20 @@ pub mod constants {
|
||||
fn sane() {
|
||||
// At least 1 µs.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Read weight should be at least 1 µs."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Write weight should be at least 1 µs."
|
||||
);
|
||||
// At most 1 ms.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Read weight should be at most 1 ms."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Write weight should be at most 1 ms."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ pub struct BlockWeights {
|
||||
impl Default for BlockWeights {
|
||||
fn default() -> Self {
|
||||
Self::with_sensible_defaults(
|
||||
Weight::from_parts(constants::WEIGHT_PER_SECOND.ref_time(), u64::MAX),
|
||||
Weight::from_parts(constants::WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
|
||||
DEFAULT_NORMAL_RATIO,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user