Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Replace WEIGHT_PER_* with WEIGHT_REF_TIME_PER_*
  • Loading branch information
KiChjang committed Dec 7, 2022
commit 5c22da4ec4d85b281cddee1682dd355889e94ca7
4 changes: 2 additions & 2 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod mock;
use frame_support::{
parameter_types,
traits::{ConstU32, Currency, OneSessionHandler},
weights::{constants::WEIGHT_PER_SECOND, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
};
use frame_system::limits;
use primitives::v2::{AssignmentId, Balance, BlockNumber, ValidatorId, MAX_POV_SIZE};
Expand Down Expand Up @@ -71,7 +71,7 @@ pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(1);
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// The storage proof size is not limited so far.
pub const MAXIMUM_BLOCK_WEIGHT: Weight =
WEIGHT_PER_SECOND.saturating_mul(2).set_proof_size(MAX_POV_SIZE as u64);
Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), MAX_POV_SIZE as u64);

const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct());

Expand Down
9 changes: 5 additions & 4 deletions runtime/kusama/constants/src/weights/block_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

use frame_support::{
parameter_types,
weights::{constants::WEIGHT_PER_NANOS, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight},
};

parameter_types! {
Expand All @@ -54,7 +54,8 @@ parameter_types! {
/// 99th: 6_332_047
/// 95th: 6_308_225
/// 75th: 6_236_204
pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(6_192_341);
pub const BlockExecutionWeight: Weight =
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(6_192_341));
}

#[cfg(test)]
Expand All @@ -70,12 +71,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."
);
}
Expand Down
9 changes: 5 additions & 4 deletions runtime/kusama/constants/src/weights/extrinsic_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

use frame_support::{
parameter_types,
weights::{constants::WEIGHT_PER_NANOS, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight},
};

parameter_types! {
Expand All @@ -53,7 +53,8 @@ parameter_types! {
/// 99th: 87_527
/// 95th: 86_901
/// 75th: 86_308
pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(86_309);
pub const ExtrinsicBaseWeight: Weight =
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(86_309));
}

#[cfg(test)]
Expand All @@ -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."
);
}
Expand Down
12 changes: 6 additions & 6 deletions runtime/kusama/constants/src/weights/paritydb_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.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,
};
}

Expand All @@ -42,20 +42,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."
);
}
Expand Down
12 changes: 6 additions & 6 deletions runtime/kusama/constants/src/weights/rocksdb_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.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,
};
}

Expand All @@ -42,20 +42,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."
);
}
Expand Down
6 changes: 3 additions & 3 deletions runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! Configuration can change only at session boundaries and is buffered until then.

use crate::shared;
use frame_support::{pallet_prelude::*, weights::constants::WEIGHT_PER_MILLIS};
use frame_support::{pallet_prelude::*, weights::constants::WEIGHT_REF_TIME_PER_MILLIS};
use frame_system::pallet_prelude::*;
use parity_scale_codec::{Decode, Encode};
use primitives::v2::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE};
Expand Down Expand Up @@ -285,8 +285,8 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
hrmp_max_parachain_outbound_channels: Default::default(),
hrmp_max_parathread_outbound_channels: Default::default(),
hrmp_max_message_num_per_candidate: Default::default(),
ump_max_individual_weight: (20u64 * WEIGHT_PER_MILLIS)
.set_proof_size(MAX_POV_SIZE as u64),
ump_max_individual_weight:
Weight::from_parts(20u64 * WEIGHT_REF_TIME_PER_MILLIS, MAX_POV_SIZE as u64),
pvf_checking_enabled: false,
pvf_voting_ttl: 2u32.into(),
minimum_validation_upgrade_delay: 2.into(),
Expand Down
2 changes: 1 addition & 1 deletion runtime/parachains/src/configuration/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub mod v3 {
hrmp_max_parathread_outbound_channels: Default::default(),
hrmp_max_message_num_per_candidate: Default::default(),
ump_max_individual_weight: OldWeight(
frame_support::weights::constants::WEIGHT_PER_MILLIS.ref_time() * 20,
frame_support::weights::constants::WEIGHT_REF_TIME_PER_MILLIS * 20,
),
pvf_checking_enabled: false,
pvf_voting_ttl: 2u32.into(),
Expand Down
9 changes: 5 additions & 4 deletions runtime/polkadot/constants/src/weights/block_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

use frame_support::{
parameter_types,
weights::{constants::WEIGHT_PER_NANOS, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight},
};

parameter_types! {
Expand All @@ -54,7 +54,8 @@ parameter_types! {
/// 99th: 6_131_246
/// 95th: 5_988_921
/// 75th: 5_885_724
pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(5_849_907);
pub const BlockExecutionWeight: Weight =
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_849_907));
}

#[cfg(test)]
Expand All @@ -70,12 +71,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."
);
}
Expand Down
9 changes: 5 additions & 4 deletions runtime/polkadot/constants/src/weights/extrinsic_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

use frame_support::{
parameter_types,
weights::{constants::WEIGHT_PER_NANOS, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight},
};

parameter_types! {
Expand All @@ -53,7 +53,8 @@ parameter_types! {
/// 99th: 86_269
/// 95th: 85_510
/// 75th: 85_216
pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(85_212);
pub const ExtrinsicBaseWeight: Weight =
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(85_212));
}

#[cfg(test)]
Expand All @@ -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."
);
}
Expand Down
12 changes: 6 additions & 6 deletions runtime/polkadot/constants/src/weights/paritydb_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub mod constants {
/// 99th: 14_451
/// 95th: 12_588
/// 75th: 11_200
read: 11_826 * constants::WEIGHT_PER_NANOS.ref_time(),
read: 11_826 * constants::WEIGHT_REF_TIME_PER_NANOS,

/// Time to write one storage item.
/// Calculated by multiplying the *Average* of all values with `1.1` and adding `0`.
Expand All @@ -72,7 +72,7 @@ pub mod constants {
/// 99th: 69_379
/// 95th: 47_168
/// 75th: 35_252
write: 38_052 * constants::WEIGHT_PER_NANOS.ref_time(),
write: 38_052 * constants::WEIGHT_REF_TIME_PER_NANOS,
};
}

Expand All @@ -88,20 +88,20 @@ pub mod constants {
fn bound() {
// 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."
);
}
Expand Down
12 changes: 6 additions & 6 deletions runtime/polkadot/constants/src/weights/rocksdb_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub mod constants {
/// 99th: 32_074
/// 95th: 26_658
/// 75th: 19_363
read: 20_499 * constants::WEIGHT_PER_NANOS.ref_time(),
read: 20_499 * constants::WEIGHT_REF_TIME_PER_NANOS,

/// Time to write one storage item.
/// Calculated by multiplying the *Average* of all values with `1.1` and adding `0`.
Expand All @@ -71,7 +71,7 @@ pub mod constants {
/// 99th: 111_151
/// 95th: 92_666
/// 75th: 80_297
write: 83_471 * constants::WEIGHT_PER_NANOS.ref_time(),
write: 83_471 * constants::WEIGHT_REF_TIME_PER_NANOS,
};
}

Expand All @@ -87,20 +87,20 @@ pub mod constants {
fn bound() {
// 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."
);
}
Expand Down
9 changes: 5 additions & 4 deletions runtime/rococo/constants/src/weights/block_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

use frame_support::{
parameter_types,
weights::{constants::WEIGHT_PER_NANOS, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight},
};

parameter_types! {
Expand All @@ -54,7 +54,8 @@ parameter_types! {
/// 99th: 4_189_094
/// 95th: 4_152_261
/// 75th: 4_098_529
pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(4_084_738);
pub const BlockExecutionWeight: Weight =
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(4_084_738));
}

#[cfg(test)]
Expand All @@ -70,12 +71,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."
);
}
Expand Down
Loading