Companion for paritytech/substrate#12183 (#1601)

* Companion for paritytech/substrate#12183

* Fixes

* Update pallets/xcmp-queue/src/lib.rs

* Update pallets/xcmp-queue/src/lib.rs

* update lockfile for {"substrate", "polkadot"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Keith Yeung
2022-09-08 13:29:53 +08:00
committed by GitHub
parent c119f290db
commit 11b18e89c6
31 changed files with 399 additions and 336 deletions
+248 -248
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -287,7 +287,7 @@ pub mod pallet {
Err((message_id, required_weight)) => Err((message_id, required_weight)) =>
// Too much weight required right now. // Too much weight required right now.
{ {
if required_weight > config.max_individual { if required_weight.any_gt(config.max_individual) {
// overweight - add to overweight queue and continue with // overweight - add to overweight queue and continue with
// message execution. // message execution.
let overweight_index = page_index.overweight_count; let overweight_index = page_index.overweight_count;
+3 -3
View File
@@ -808,7 +808,7 @@ impl<T: Config> Pallet<T> {
let mut shuffle_index = 0; let mut shuffle_index = 0;
while shuffle_index < shuffled.len() && while shuffle_index < shuffled.len() &&
max_weight.saturating_sub(weight_used) >= threshold_weight max_weight.saturating_sub(weight_used).all_gte(threshold_weight)
{ {
let index = shuffled[shuffle_index]; let index = shuffled[shuffle_index];
let sender = status[index].sender; let sender = status[index].sender;
@@ -831,7 +831,7 @@ impl<T: Config> Pallet<T> {
if shuffle_index < status.len() { if shuffle_index < status.len() {
weight_available += weight_available +=
(max_weight - weight_available) / (weight_restrict_decay.ref_time() + 1); (max_weight - weight_available) / (weight_restrict_decay.ref_time() + 1);
if weight_available + threshold_weight > max_weight { if (weight_available + threshold_weight).any_gt(max_weight) {
weight_available = max_weight; weight_available = max_weight;
} }
} else { } else {
@@ -871,7 +871,7 @@ impl<T: Config> Pallet<T> {
// other channels a look in. If we've still not unlocked all weight, then we set them // other channels a look in. If we've still not unlocked all weight, then we set them
// up for processing a second time anyway. // up for processing a second time anyway.
if !status[index].message_metadata.is_empty() && if !status[index].message_metadata.is_empty() &&
(weight_processed > Weight::zero() || weight_available != max_weight) (weight_processed.any_gt(Weight::zero()) || weight_available != max_weight)
{ {
if shuffle_index + 1 == shuffled.len() { if shuffle_index + 1 == shuffled.len() {
// Only this queue left. Just run around this loop once more. // Only this queue left. Just run around this loop once more.
@@ -39,11 +39,14 @@ pub mod constants {
// At least 100 µs. // At least 100 µs.
assert!( assert!(
w >= 100u64 * constants::WEIGHT_PER_MICROS, w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 100 µs." "Weight should be at least 100 µs."
); );
// At most 50 ms. // At most 50 ms.
assert!(w <= 50u64 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 50 ms."
);
} }
} }
} }
@@ -38,9 +38,15 @@ pub mod constants {
let w = super::constants::ExtrinsicBaseWeight::get(); let w = super::constants::ExtrinsicBaseWeight::get();
// At least 10 µs. // At least 10 µs.
assert!(w >= 10u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 10 µs."
);
// At most 1 ms. // At most 1 ms.
assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 1 ms."
);
} }
} }
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -39,11 +39,14 @@ pub mod constants {
// At least 100 µs. // At least 100 µs.
assert!( assert!(
w >= 100u64 * constants::WEIGHT_PER_MICROS, w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 100 µs." "Weight should be at least 100 µs."
); );
// At most 50 ms. // At most 50 ms.
assert!(w <= 50u64 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 50 ms."
);
} }
} }
} }
@@ -38,9 +38,15 @@ pub mod constants {
let w = super::constants::ExtrinsicBaseWeight::get(); let w = super::constants::ExtrinsicBaseWeight::get();
// At least 10 µs. // At least 10 µs.
assert!(w >= 10u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 10 µs."
);
// At most 1 ms. // At most 1 ms.
assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 1 ms."
);
} }
} }
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -39,11 +39,14 @@ pub mod constants {
// At least 100 µs. // At least 100 µs.
assert!( assert!(
w >= 100u64 * constants::WEIGHT_PER_MICROS, w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 100 µs." "Weight should be at least 100 µs."
); );
// At most 50 ms. // At most 50 ms.
assert!(w <= 50u64 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 50 ms."
);
} }
} }
} }
@@ -38,9 +38,15 @@ pub mod constants {
let w = super::constants::ExtrinsicBaseWeight::get(); let w = super::constants::ExtrinsicBaseWeight::get();
// At least 10 µs. // At least 10 µs.
assert!(w >= 10u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 10 µs."
);
// At most 1 ms. // At most 1 ms.
assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 1 ms."
);
} }
} }
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -39,11 +39,14 @@ pub mod constants {
// At least 100 µs. // At least 100 µs.
assert!( assert!(
w >= 100u64 * constants::WEIGHT_PER_MICROS, w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 100 µs." "Weight should be at least 100 µs."
); );
// At most 50 ms. // At most 50 ms.
assert!(w <= 50u64 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 50 ms."
);
} }
} }
} }
@@ -38,9 +38,15 @@ pub mod constants {
let w = super::constants::ExtrinsicBaseWeight::get(); let w = super::constants::ExtrinsicBaseWeight::get();
// At least 10 µs. // At least 10 µs.
assert!(w >= 10u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 10 µs."
);
// At most 1 ms. // At most 1 ms.
assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 1 ms."
);
} }
} }
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -39,11 +39,14 @@ pub mod constants {
// At least 100 µs. // At least 100 µs.
assert!( assert!(
w >= 100u64 * constants::WEIGHT_PER_MICROS, w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 100 µs." "Weight should be at least 100 µs."
); );
// At most 50 ms. // At most 50 ms.
assert!(w <= 50u64 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 50 ms."
);
} }
} }
} }
@@ -38,9 +38,15 @@ pub mod constants {
let w = super::constants::ExtrinsicBaseWeight::get(); let w = super::constants::ExtrinsicBaseWeight::get();
// At least 10 µs. // At least 10 µs.
assert!(w >= 10u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 10 µs."
);
// At most 1 ms. // At most 1 ms.
assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 1 ms."
);
} }
} }
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -39,11 +39,14 @@ pub mod constants {
// At least 100 µs. // At least 100 µs.
assert!( assert!(
w >= 100u64 * constants::WEIGHT_PER_MICROS, w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 100 µs." "Weight should be at least 100 µs."
); );
// At most 50 ms. // At most 50 ms.
assert!(w <= 50u64 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 50 ms."
);
} }
} }
} }
@@ -38,9 +38,15 @@ pub mod constants {
let w = super::constants::ExtrinsicBaseWeight::get(); let w = super::constants::ExtrinsicBaseWeight::get();
// At least 10 µs. // At least 10 µs.
assert!(w >= 10u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 10 µs."
);
// At most 1 ms. // At most 1 ms.
assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 1 ms."
);
} }
} }
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -39,11 +39,14 @@ pub mod constants {
// At least 100 µs. // At least 100 µs.
assert!( assert!(
w >= 100u64 * constants::WEIGHT_PER_MICROS, w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 100 µs." "Weight should be at least 100 µs."
); );
// At most 50 ms. // At most 50 ms.
assert!(w <= 50u64 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 50 ms."
);
} }
} }
} }
@@ -38,9 +38,15 @@ pub mod constants {
let w = super::constants::ExtrinsicBaseWeight::get(); let w = super::constants::ExtrinsicBaseWeight::get();
// At least 10 µs. // At least 10 µs.
assert!(w >= 10u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 10 µs."
);
// At most 1 ms. // At most 1 ms.
assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 1 ms."
);
} }
} }
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
@@ -42,20 +42,20 @@ pub mod constants {
fn sane() { fn sane() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1) >= constants::WEIGHT_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1) >= constants::WEIGHT_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }