Skip to content

Commit 0d6f499

Browse files
authored
Companion for paritytech/substrate#12868 (#1970)
* Replace WEIGHT_PER_* with WEIGHT_REF_TIME_PER_* * Fixes * Fixes * update lockfile for {"substrate", "polkadot"} Co-authored-by: parity-processbot <>
1 parent 551ed58 commit 0d6f499

File tree

24 files changed

+381
-380
lines changed

24 files changed

+381
-380
lines changed

Cargo.lock

Lines changed: 266 additions & 277 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cumulus/parachain-template/runtime/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use frame_support::{
3131
parameter_types,
3232
traits::{ConstU32, ConstU64, ConstU8, Everything},
3333
weights::{
34-
constants::WEIGHT_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
34+
constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
3535
WeightToFeeCoefficients, WeightToFeePolynomial,
3636
},
3737
PalletId,
@@ -217,9 +217,10 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
217217
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
218218

219219
/// We allow for 0.5 of a second of compute with a 12 second average block time.
220-
const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND
221-
.saturating_div(2)
222-
.set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64);
220+
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
221+
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
222+
cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64,
223+
);
223224

224225
/// The version information used to identify this runtime when compiled natively.
225226
#[cfg(feature = "std")]

cumulus/parachain-template/runtime/src/weights/block_weights.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ pub mod constants {
2323

2424
parameter_types! {
2525
/// Importing a block with 0 Extrinsics.
26-
pub const BlockExecutionWeight: Weight = constants::WEIGHT_PER_NANOS.saturating_mul(5_000_000);
26+
pub const BlockExecutionWeight: Weight =
27+
Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000));
2728
}
2829

2930
#[cfg(test)]
@@ -39,12 +40,12 @@ pub mod constants {
3940

4041
// At least 100 µs.
4142
assert!(
42-
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
43+
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
4344
"Weight should be at least 100 µs."
4445
);
4546
// At most 50 ms.
4647
assert!(
47-
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
48+
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
4849
"Weight should be at most 50 ms."
4950
);
5051
}

cumulus/parachain-template/runtime/src/weights/extrinsic_weights.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ pub mod constants {
2323

2424
parameter_types! {
2525
/// Executing a NO-OP `System::remarks` Extrinsic.
26-
pub const ExtrinsicBaseWeight: Weight = constants::WEIGHT_PER_NANOS.saturating_mul(125_000);
26+
pub const ExtrinsicBaseWeight: Weight =
27+
Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000));
2728
}
2829

2930
#[cfg(test)]
@@ -39,12 +40,12 @@ pub mod constants {
3940

4041
// At least 10 µs.
4142
assert!(
42-
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
43+
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
4344
"Weight should be at least 10 µs."
4445
);
4546
// At most 1 ms.
4647
assert!(
47-
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
48+
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
4849
"Weight should be at most 1 ms."
4950
);
5051
}

cumulus/parachain-template/runtime/src/weights/paritydb_weights.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub mod constants {
2525
/// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights
2626
/// are available for brave runtime engineers who may want to try this out as default.
2727
pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight {
28-
read: 8_000 * constants::WEIGHT_PER_NANOS.ref_time(),
29-
write: 50_000 * constants::WEIGHT_PER_NANOS.ref_time(),
28+
read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
29+
write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
3030
};
3131
}
3232

@@ -42,20 +42,20 @@ pub mod constants {
4242
fn sane() {
4343
// At least 1 µs.
4444
assert!(
45-
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
45+
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
4646
"Read weight should be at least 1 µs."
4747
);
4848
assert!(
49-
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
49+
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
5050
"Write weight should be at least 1 µs."
5151
);
5252
// At most 1 ms.
5353
assert!(
54-
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
54+
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
5555
"Read weight should be at most 1 ms."
5656
);
5757
assert!(
58-
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
58+
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
5959
"Write weight should be at most 1 ms."
6060
);
6161
}

cumulus/parachain-template/runtime/src/weights/rocksdb_weights.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub mod constants {
2525
/// By default, Substrate uses `RocksDB`, so this will be the weight used throughout
2626
/// the runtime.
2727
pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
28-
read: 25_000 * constants::WEIGHT_PER_NANOS.ref_time(),
29-
write: 100_000 * constants::WEIGHT_PER_NANOS.ref_time(),
28+
read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
29+
write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
3030
};
3131
}
3232

@@ -42,20 +42,20 @@ pub mod constants {
4242
fn sane() {
4343
// At least 1 µs.
4444
assert!(
45-
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
45+
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
4646
"Read weight should be at least 1 µs."
4747
);
4848
assert!(
49-
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
49+
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
5050
"Write weight should be at least 1 µs."
5151
);
5252
// At most 1 ms.
5353
assert!(
54-
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
54+
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
5555
"Read weight should be at most 1 ms."
5656
);
5757
assert!(
58-
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
58+
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
5959
"Write weight should be at most 1 ms."
6060
);
6161
}

cumulus/parachains/runtimes/assets/statemine/src/weights/block_weights.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ pub mod constants {
2323

2424
parameter_types! {
2525
/// Importing a block with 0 Extrinsics.
26-
pub const BlockExecutionWeight: Weight = constants::WEIGHT_PER_NANOS.saturating_mul(5_000_000);
26+
pub const BlockExecutionWeight: Weight =
27+
Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000));
2728
}
2829

2930
#[cfg(test)]
@@ -39,12 +40,12 @@ pub mod constants {
3940

4041
// At least 100 µs.
4142
assert!(
42-
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
43+
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
4344
"Weight should be at least 100 µs."
4445
);
4546
// At most 50 ms.
4647
assert!(
47-
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
48+
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
4849
"Weight should be at most 50 ms."
4950
);
5051
}

cumulus/parachains/runtimes/assets/statemine/src/weights/extrinsic_weights.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ pub mod constants {
2323

2424
parameter_types! {
2525
/// Executing a NO-OP `System::remarks` Extrinsic.
26-
pub const ExtrinsicBaseWeight: Weight = constants::WEIGHT_PER_NANOS.saturating_mul(125_000);
26+
pub const ExtrinsicBaseWeight: Weight =
27+
Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000));
2728
}
2829

2930
#[cfg(test)]
@@ -39,12 +40,12 @@ pub mod constants {
3940

4041
// At least 10 µs.
4142
assert!(
42-
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
43+
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
4344
"Weight should be at least 10 µs."
4445
);
4546
// At most 1 ms.
4647
assert!(
47-
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
48+
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
4849
"Weight should be at most 1 ms."
4950
);
5051
}

cumulus/parachains/runtimes/assets/statemine/src/weights/paritydb_weights.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub mod constants {
2525
/// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights
2626
/// are available for brave runtime engineers who may want to try this out as default.
2727
pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight {
28-
read: 8_000 * constants::WEIGHT_PER_NANOS.ref_time(),
29-
write: 50_000 * constants::WEIGHT_PER_NANOS.ref_time(),
28+
read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
29+
write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
3030
};
3131
}
3232

@@ -42,20 +42,20 @@ pub mod constants {
4242
fn sane() {
4343
// At least 1 µs.
4444
assert!(
45-
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
45+
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
4646
"Read weight should be at least 1 µs."
4747
);
4848
assert!(
49-
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
49+
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
5050
"Write weight should be at least 1 µs."
5151
);
5252
// At most 1 ms.
5353
assert!(
54-
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
54+
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
5555
"Read weight should be at most 1 ms."
5656
);
5757
assert!(
58-
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
58+
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
5959
"Write weight should be at most 1 ms."
6060
);
6161
}

cumulus/parachains/runtimes/assets/statemine/src/weights/rocksdb_weights.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub mod constants {
2525
/// By default, Substrate uses `RocksDB`, so this will be the weight used throughout
2626
/// the runtime.
2727
pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
28-
read: 25_000 * constants::WEIGHT_PER_NANOS.ref_time(),
29-
write: 100_000 * constants::WEIGHT_PER_NANOS.ref_time(),
28+
read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
29+
write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
3030
};
3131
}
3232

@@ -42,20 +42,20 @@ pub mod constants {
4242
fn sane() {
4343
// At least 1 µs.
4444
assert!(
45-
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
45+
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
4646
"Read weight should be at least 1 µs."
4747
);
4848
assert!(
49-
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
49+
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
5050
"Write weight should be at least 1 µs."
5151
);
5252
// At most 1 ms.
5353
assert!(
54-
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
54+
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
5555
"Read weight should be at most 1 ms."
5656
);
5757
assert!(
58-
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
58+
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
5959
"Write weight should be at most 1 ms."
6060
);
6161
}

0 commit comments

Comments
 (0)