Skip to content

Commit 5746577

Browse files
KiChjangggwpez
andauthored
Companion for paritytech/substrate#12183 (#5971)
* Companion for paritytech/substrate#12183 * Fixes * Fixes * Fixes * cargo fmt * Fixes * Fixes * Fixes * cargo fmt * Update runtime/parachains/src/paras_inherent/mod.rs Co-authored-by: Oliver Tale-Yazdi <[email protected]> * update lockfile for {"substrate"} Co-authored-by: Oliver Tale-Yazdi <[email protected]> Co-authored-by: parity-processbot <>
1 parent 4be2f91 commit 5746577

10 files changed

Lines changed: 57 additions & 33 deletions

File tree

relay/kusama/constants/src/weights/block_weights.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ mod test_weights {
6969
let w = super::BlockExecutionWeight::get();
7070

7171
// At least 100 µs.
72-
assert!(w >= 100u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs.");
72+
assert!(
73+
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
74+
"Weight should be at least 100 µs."
75+
);
7376
// At most 50 ms.
74-
assert!(w <= 50u64 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms.");
77+
assert!(
78+
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
79+
"Weight should be at most 50 ms."
80+
);
7581
}
7682
}

relay/kusama/constants/src/weights/extrinsic_weights.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ mod test_weights {
6868
let w = super::ExtrinsicBaseWeight::get();
6969

7070
// At least 10 µs.
71-
assert!(w >= 10u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs.");
71+
assert!(
72+
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
73+
"Weight should be at least 10 µs."
74+
);
7275
// At most 1 ms.
73-
assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms.");
76+
assert!(
77+
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
78+
"Weight should be at most 1 ms."
79+
);
7480
}
7581
}

relay/kusama/constants/src/weights/paritydb_weights.rs

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

relay/kusama/constants/src/weights/rocksdb_weights.rs

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

relay/kusama/src/tests.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn remove_keys_weight_is_sensible() {
3030
use runtime_common::crowdloan::WeightInfo;
3131
let max_weight = <Runtime as crowdloan::Config>::WeightInfo::refund(RemoveKeysLimit::get());
3232
// Max remove keys limit should be no more than half the total block weight.
33-
assert!(max_weight * 2 < BlockWeights::get().max_block);
33+
assert!((max_weight * 2).all_lt(BlockWeights::get().max_block));
3434
}
3535

3636
#[test]
@@ -40,11 +40,9 @@ fn sample_size_is_sensible() {
4040
let samples: BlockNumber = EndingPeriod::get() / SampleLength::get();
4141
let max_weight: Weight = RocksDbWeight::get().reads_writes(samples.into(), samples.into());
4242
// Max sample cleanup should be no more than half the total block weight.
43-
assert!(max_weight * 2 < BlockWeights::get().max_block);
44-
assert!(
45-
<Runtime as auctions::Config>::WeightInfo::on_initialize() * 2 <
46-
BlockWeights::get().max_block
47-
);
43+
assert!((max_weight * 2).all_lt(BlockWeights::get().max_block));
44+
assert!((<Runtime as auctions::Config>::WeightInfo::on_initialize() * 2)
45+
.all_lt(BlockWeights::get().max_block));
4846
}
4947

5048
#[test]
@@ -132,7 +130,7 @@ fn nominator_limit() {
132130
};
133131

134132
let mut active = 1;
135-
while weight_with(active) <= OffchainSolutionWeightLimit::get() || active == all_voters {
133+
while weight_with(active).all_lte(OffchainSolutionWeightLimit::get()) || active == all_voters {
136134
active += 1;
137135
}
138136

relay/polkadot/constants/src/weights/block_weights.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ mod test_weights {
6969
let w = super::BlockExecutionWeight::get();
7070

7171
// At least 100 µs.
72-
assert!(w >= 100u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs.");
72+
assert!(
73+
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
74+
"Weight should be at least 100 µs."
75+
);
7376
// At most 50 ms.
74-
assert!(w <= 50u64 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms.");
77+
assert!(
78+
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
79+
"Weight should be at most 50 ms."
80+
);
7581
}
7682
}

relay/polkadot/constants/src/weights/extrinsic_weights.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ mod test_weights {
6868
let w = super::ExtrinsicBaseWeight::get();
6969

7070
// At least 10 µs.
71-
assert!(w >= 10u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs.");
71+
assert!(
72+
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
73+
"Weight should be at least 10 µs."
74+
);
7275
// At most 1 ms.
73-
assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms.");
76+
assert!(
77+
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
78+
"Weight should be at most 1 ms."
79+
);
7480
}
7581
}

relay/polkadot/constants/src/weights/paritydb_weights.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,20 @@ pub mod constants {
8888
fn bound() {
8989
// At least 1 µs.
9090
assert!(
91-
W::get().reads(1) >= constants::WEIGHT_PER_MICROS,
91+
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
9292
"Read weight should be at least 1 µs."
9393
);
9494
assert!(
95-
W::get().writes(1) >= constants::WEIGHT_PER_MICROS,
95+
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
9696
"Write weight should be at least 1 µs."
9797
);
9898
// At most 1 ms.
9999
assert!(
100-
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS,
100+
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
101101
"Read weight should be at most 1 ms."
102102
);
103103
assert!(
104-
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS,
104+
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
105105
"Write weight should be at most 1 ms."
106106
);
107107
}

relay/polkadot/constants/src/weights/rocksdb_weights.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,20 @@ pub mod constants {
8787
fn bound() {
8888
// At least 1 µs.
8989
assert!(
90-
W::get().reads(1) >= constants::WEIGHT_PER_MICROS,
90+
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
9191
"Read weight should be at least 1 µs."
9292
);
9393
assert!(
94-
W::get().writes(1) >= constants::WEIGHT_PER_MICROS,
94+
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
9595
"Write weight should be at least 1 µs."
9696
);
9797
// At most 1 ms.
9898
assert!(
99-
W::get().reads(1) <= constants::WEIGHT_PER_MILLIS,
99+
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
100100
"Read weight should be at most 1 ms."
101101
);
102102
assert!(
103-
W::get().writes(1) <= constants::WEIGHT_PER_MILLIS,
103+
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
104104
"Write weight should be at most 1 ms."
105105
);
106106
}

relay/polkadot/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,7 +2203,7 @@ mod test_fees {
22032203
)
22042204
};
22052205

2206-
while weight_with(voters) <= BlockWeights::get().max_block {
2206+
while weight_with(voters).all_lte(BlockWeights::get().max_block) {
22072207
voters += 1;
22082208
}
22092209

@@ -2237,7 +2237,9 @@ mod test_fees {
22372237
};
22382238

22392239
let mut active = target_voters;
2240-
while weight_with(active) <= OffchainSolutionWeightLimit::get() || active == target_voters {
2240+
while weight_with(active).all_lte(OffchainSolutionWeightLimit::get()) ||
2241+
active == target_voters
2242+
{
22412243
active += 1;
22422244
}
22432245

0 commit comments

Comments
 (0)