Remove Ord impl for Weights V2 and add comparison fns (#12183)

* Remove Ord impl for Weights V2 and add comparison fns

* Remove TODO

* Update frame/multisig/src/lib.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update frame/election-provider-multi-phase/src/unsigned.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Remove unused import

* cargo fmt

* Fix tests

* Fix more tests

* cargo fmt

* Fix more tests

* Update frame/contracts/src/wasm/mod.rs

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* Update weight benchmarking templates

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
Keith Yeung
2022-09-08 12:22:41 +08:00
committed by GitHub
parent 09ec484139
commit 6ce4d45175
23 changed files with 156 additions and 82 deletions
+10 -8
View File
@@ -229,7 +229,7 @@ impl BlockWeights {
// Make sure that if total is set it's greater than base_block &&
// base_for_class
error_assert!(
(max_for_class > self.base_block && max_for_class > base_for_class)
(max_for_class.all_gt(self.base_block) && max_for_class.all_gt(base_for_class))
|| max_for_class == Weight::zero(),
&mut error,
"[{:?}] {:?} (total) has to be greater than {:?} (base block) & {:?} (base extrinsic)",
@@ -237,8 +237,10 @@ impl BlockWeights {
);
// Max extrinsic can't be greater than max_for_class.
error_assert!(
weights.max_extrinsic.unwrap_or(Weight::zero()) <=
max_for_class.saturating_sub(base_for_class),
weights
.max_extrinsic
.unwrap_or(Weight::zero())
.all_lte(max_for_class.saturating_sub(base_for_class)),
&mut error,
"[{:?}] {:?} (max_extrinsic) can't be greater than {:?} (max for class)",
class,
@@ -247,14 +249,14 @@ impl BlockWeights {
);
// Max extrinsic should not be 0
error_assert!(
weights.max_extrinsic.unwrap_or_else(Weight::max_value) > Weight::zero(),
weights.max_extrinsic.unwrap_or_else(Weight::max_value).all_gt(Weight::zero()),
&mut error,
"[{:?}] {:?} (max_extrinsic) must not be 0. Check base cost and average initialization cost.",
class, weights.max_extrinsic,
);
// Make sure that if reserved is set it's greater than base_for_class.
error_assert!(
reserved > base_for_class || reserved == Weight::zero(),
reserved.all_gt(base_for_class) || reserved == Weight::zero(),
&mut error,
"[{:?}] {:?} (reserved) has to be greater than {:?} (base extrinsic) if set",
class,
@@ -263,7 +265,7 @@ impl BlockWeights {
);
// Make sure max block is greater than max_total if it's set.
error_assert!(
self.max_block >= weights.max_total.unwrap_or(Weight::zero()),
self.max_block.all_gte(weights.max_total.unwrap_or(Weight::zero())),
&mut error,
"[{:?}] {:?} (max block) has to be greater than {:?} (max for class)",
class,
@@ -272,7 +274,7 @@ impl BlockWeights {
);
// Make sure we can fit at least one extrinsic.
error_assert!(
self.max_block > base_for_class + self.base_block,
self.max_block.all_gt(base_for_class + self.base_block),
&mut error,
"[{:?}] {:?} (max block) must fit at least one extrinsic {:?} (base weight)",
class,
@@ -400,7 +402,7 @@ impl BlockWeightsBuilder {
// compute max block size.
for class in DispatchClass::all() {
weights.max_block = match weights.per_class.get(*class).max_total {
Some(max) if max > weights.max_block => max,
Some(max) => max.max(weights.max_block),
_ => weights.max_block,
};
}