mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 13:01:01 +00:00
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 <oliver.tale-yazdi@parity.io> * update lockfile for {"substrate"} Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+170
-170
File diff suppressed because it is too large
Load Diff
@@ -69,8 +69,14 @@ mod test_weights {
|
||||
let w = super::BlockExecutionWeight::get();
|
||||
|
||||
// At least 100 µs.
|
||||
assert!(w >= 100u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs.");
|
||||
assert!(
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
"Weight should be at least 100 µs."
|
||||
);
|
||||
// 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."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,14 @@ mod test_weights {
|
||||
let w = super::ExtrinsicBaseWeight::get();
|
||||
|
||||
// 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.
|
||||
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() {
|
||||
// At least 1 µs.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
// At most 1 ms.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,20 +42,20 @@ pub mod constants {
|
||||
fn sane() {
|
||||
// At least 1 µs.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
// At most 1 ms.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ fn remove_keys_weight_is_sensible() {
|
||||
use runtime_common::crowdloan::WeightInfo;
|
||||
let max_weight = <Runtime as crowdloan::Config>::WeightInfo::refund(RemoveKeysLimit::get());
|
||||
// Max remove keys limit should be no more than half the total block weight.
|
||||
assert!(max_weight * 2 < BlockWeights::get().max_block);
|
||||
assert!((max_weight * 2).all_lt(BlockWeights::get().max_block));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -40,11 +40,9 @@ fn sample_size_is_sensible() {
|
||||
let samples: BlockNumber = EndingPeriod::get() / SampleLength::get();
|
||||
let max_weight: Weight = RocksDbWeight::get().reads_writes(samples.into(), samples.into());
|
||||
// Max sample cleanup should be no more than half the total block weight.
|
||||
assert!(max_weight * 2 < BlockWeights::get().max_block);
|
||||
assert!(
|
||||
<Runtime as auctions::Config>::WeightInfo::on_initialize() * 2 <
|
||||
BlockWeights::get().max_block
|
||||
);
|
||||
assert!((max_weight * 2).all_lt(BlockWeights::get().max_block));
|
||||
assert!((<Runtime as auctions::Config>::WeightInfo::on_initialize() * 2)
|
||||
.all_lt(BlockWeights::get().max_block));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -132,7 +130,7 @@ fn nominator_limit() {
|
||||
};
|
||||
|
||||
let mut active = 1;
|
||||
while weight_with(active) <= OffchainSolutionWeightLimit::get() || active == all_voters {
|
||||
while weight_with(active).all_lte(OffchainSolutionWeightLimit::get()) || active == all_voters {
|
||||
active += 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ impl UmpSink for TestUmpSink {
|
||||
Ok(w) => Weight::from_ref_time(w as u64),
|
||||
Err(_) => return Ok(Weight::zero()), // same as the real `UmpSink`
|
||||
};
|
||||
if weight > max_weight {
|
||||
if weight.any_gt(max_weight) {
|
||||
let id = sp_io::hashing::blake2_256(actual_msg);
|
||||
return Err((id, weight))
|
||||
}
|
||||
|
||||
@@ -878,16 +878,11 @@ pub mod pallet {
|
||||
/// Includes a statement for a PVF pre-checking vote. Potentially, finalizes the vote and
|
||||
/// enacts the results if that was the last vote before achieving the supermajority.
|
||||
#[pallet::weight(
|
||||
sp_std::cmp::max(
|
||||
sp_std::cmp::max(
|
||||
<T as Config>::WeightInfo::include_pvf_check_statement_finalize_upgrade_accept(),
|
||||
<T as Config>::WeightInfo::include_pvf_check_statement_finalize_upgrade_reject(),
|
||||
),
|
||||
sp_std::cmp::max(
|
||||
<T as Config>::WeightInfo::include_pvf_check_statement_finalize_onboarding_accept(),
|
||||
<T as Config>::WeightInfo::include_pvf_check_statement_finalize_onboarding_reject(),
|
||||
<T as Config>::WeightInfo::include_pvf_check_statement_finalize_upgrade_accept()
|
||||
.max(<T as Config>::WeightInfo::include_pvf_check_statement_finalize_upgrade_reject())
|
||||
.max(<T as Config>::WeightInfo::include_pvf_check_statement_finalize_onboarding_accept()
|
||||
.max(<T as Config>::WeightInfo::include_pvf_check_statement_finalize_onboarding_reject())
|
||||
)
|
||||
)
|
||||
)]
|
||||
pub fn include_pvf_check_statement(
|
||||
origin: OriginFor<T>,
|
||||
|
||||
@@ -373,8 +373,8 @@ impl<T: Config> Pallet<T> {
|
||||
// the block. It's still reasonable to protect against a massive amount of disputes.
|
||||
if candidates_weight
|
||||
.saturating_add(bitfields_weight)
|
||||
.saturating_add(disputes_weight) >
|
||||
max_block_weight
|
||||
.saturating_add(disputes_weight)
|
||||
.any_gt(max_block_weight)
|
||||
{
|
||||
log::warn!("Overweight para inherent data reached the runtime {:?}", parent_hash);
|
||||
backed_candidates.clear();
|
||||
@@ -753,7 +753,7 @@ impl<T: Config> Pallet<T> {
|
||||
&mut rng,
|
||||
);
|
||||
|
||||
if actual_weight > max_block_weight {
|
||||
if actual_weight.any_gt(max_block_weight) {
|
||||
log::warn!(target: LOG_TARGET, "Post weight limiting weight is still too large.");
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ fn random_sel<X, F: Fn(&X) -> Weight>(
|
||||
// preferred indices originate from outside
|
||||
if let Some(item) = selectables.get(preferred_idx) {
|
||||
let updated = weight_acc.saturating_add(weight_fn(item));
|
||||
if updated > weight_limit {
|
||||
if updated.any_gt(weight_limit) {
|
||||
continue
|
||||
}
|
||||
weight_acc = updated;
|
||||
@@ -833,7 +833,7 @@ fn random_sel<X, F: Fn(&X) -> Weight>(
|
||||
let item = &selectables[idx];
|
||||
let updated = weight_acc.saturating_add(weight_fn(item));
|
||||
|
||||
if updated > weight_limit {
|
||||
if updated.any_gt(weight_limit) {
|
||||
continue
|
||||
}
|
||||
weight_acc = updated;
|
||||
@@ -877,7 +877,7 @@ fn apply_weight_limit<T: Config + inclusion::Config>(
|
||||
let total = total_bitfields_weight.saturating_add(total_candidates_weight);
|
||||
|
||||
// candidates + bitfields fit into the block
|
||||
if max_consumable_weight >= total {
|
||||
if max_consumable_weight.all_gte(total) {
|
||||
return total
|
||||
}
|
||||
|
||||
@@ -1243,7 +1243,7 @@ fn limit_and_sanitize_disputes<
|
||||
// The total weight if all disputes would be included
|
||||
let disputes_weight = multi_dispute_statement_sets_weight::<T, _, _>(&disputes);
|
||||
|
||||
if disputes_weight > max_consumable_weight {
|
||||
if disputes_weight.any_gt(max_consumable_weight) {
|
||||
let mut checked_acc = Vec::<CheckedDisputeStatementSet>::with_capacity(disputes.len());
|
||||
|
||||
// Since the disputes array is sorted, we may use binary search to find the beginning of
|
||||
@@ -1274,7 +1274,7 @@ fn limit_and_sanitize_disputes<
|
||||
dss.statements.len() as u32,
|
||||
);
|
||||
let updated = weight_acc.saturating_add(dispute_weight);
|
||||
if max_consumable_weight >= updated {
|
||||
if max_consumable_weight.all_gte(updated) {
|
||||
// only apply the weight if the validity check passes
|
||||
if let Some(checked) = dispute_statement_set_valid(dss.clone()) {
|
||||
checked_acc.push(checked);
|
||||
|
||||
@@ -607,11 +607,9 @@ mod enter {
|
||||
let limit_inherent_data =
|
||||
Pallet::<Test>::create_inherent_inner(&inherent_data.clone()).unwrap();
|
||||
assert_ne!(limit_inherent_data, expected_para_inherent_data);
|
||||
assert!(
|
||||
inherent_data_weight(&limit_inherent_data) <=
|
||||
inherent_data_weight(&expected_para_inherent_data)
|
||||
);
|
||||
assert!(inherent_data_weight(&limit_inherent_data) <= max_block_weight());
|
||||
assert!(inherent_data_weight(&limit_inherent_data)
|
||||
.all_lte(inherent_data_weight(&expected_para_inherent_data)));
|
||||
assert!(inherent_data_weight(&limit_inherent_data).all_lte(max_block_weight()));
|
||||
|
||||
// Three disputes is over weight (see previous test), so we expect to only see 2 disputes
|
||||
assert_eq!(limit_inherent_data.disputes.len(), 2);
|
||||
@@ -760,7 +758,7 @@ mod enter {
|
||||
});
|
||||
|
||||
let expected_para_inherent_data = scenario.data.clone();
|
||||
assert!(max_block_weight() < inherent_data_weight(&expected_para_inherent_data));
|
||||
assert!(max_block_weight().any_lt(inherent_data_weight(&expected_para_inherent_data)));
|
||||
|
||||
// Check the para inherent data is as expected:
|
||||
// * 1 bitfield per validator (5 validators per core, 2 backed candidates, 3 disputes => 5*5 = 25)
|
||||
@@ -779,7 +777,7 @@ mod enter {
|
||||
// Expect that inherent data is filtered to include only 1 backed candidate and 2 disputes
|
||||
assert!(limit_inherent_data != expected_para_inherent_data);
|
||||
assert!(
|
||||
max_block_weight() >= inherent_data_weight(&limit_inherent_data),
|
||||
max_block_weight().all_gte(inherent_data_weight(&limit_inherent_data)),
|
||||
"Post limiting exceeded block weight: max={} vs. inherent={}",
|
||||
max_block_weight(),
|
||||
inherent_data_weight(&limit_inherent_data)
|
||||
|
||||
@@ -512,7 +512,7 @@ impl<T: Config> Pallet<T> {
|
||||
let mut queue_cache = QueueCache::new();
|
||||
|
||||
while let Some(dispatchee) = cursor.peek() {
|
||||
if weight_used >= config.ump_service_total_weight {
|
||||
if weight_used.any_gte(config.ump_service_total_weight) {
|
||||
// Then check whether we've reached or overshoot the
|
||||
// preferred weight for the dispatching stage.
|
||||
//
|
||||
@@ -537,7 +537,7 @@ impl<T: Config> Pallet<T> {
|
||||
let _ = queue_cache.consume_front::<T>(dispatchee);
|
||||
},
|
||||
Err((id, required)) => {
|
||||
if required > config.ump_max_individual_weight {
|
||||
if required.any_gt(config.ump_max_individual_weight) {
|
||||
// overweight - add to overweight queue and continue with message
|
||||
// execution consuming the message.
|
||||
let upward_message = queue_cache.consume_front::<T>(dispatchee).expect(
|
||||
|
||||
@@ -69,8 +69,14 @@ mod test_weights {
|
||||
let w = super::BlockExecutionWeight::get();
|
||||
|
||||
// At least 100 µs.
|
||||
assert!(w >= 100u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs.");
|
||||
assert!(
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
"Weight should be at least 100 µs."
|
||||
);
|
||||
// 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."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,14 @@ mod test_weights {
|
||||
let w = super::ExtrinsicBaseWeight::get();
|
||||
|
||||
// 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.
|
||||
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."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,20 +88,20 @@ pub mod constants {
|
||||
fn bound() {
|
||||
// At least 1 µs.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
// At most 1 ms.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,20 +87,20 @@ pub mod constants {
|
||||
fn bound() {
|
||||
// At least 1 µs.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
// At most 1 ms.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2203,7 +2203,7 @@ mod test_fees {
|
||||
)
|
||||
};
|
||||
|
||||
while weight_with(voters) <= BlockWeights::get().max_block {
|
||||
while weight_with(voters).all_lte(BlockWeights::get().max_block) {
|
||||
voters += 1;
|
||||
}
|
||||
|
||||
@@ -2237,7 +2237,9 @@ mod test_fees {
|
||||
};
|
||||
|
||||
let mut active = target_voters;
|
||||
while weight_with(active) <= OffchainSolutionWeightLimit::get() || active == target_voters {
|
||||
while weight_with(active).all_lte(OffchainSolutionWeightLimit::get()) ||
|
||||
active == target_voters
|
||||
{
|
||||
active += 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,14 @@ mod test_weights {
|
||||
let w = super::BlockExecutionWeight::get();
|
||||
|
||||
// At least 100 µs.
|
||||
assert!(w >= 100u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs.");
|
||||
assert!(
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
"Weight should be at least 100 µs."
|
||||
);
|
||||
// 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."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,14 @@ mod test_weights {
|
||||
let w = super::ExtrinsicBaseWeight::get();
|
||||
|
||||
// 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.
|
||||
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() {
|
||||
// At least 1 µs.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
// At most 1 ms.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,20 +42,20 @@ pub mod constants {
|
||||
fn sane() {
|
||||
// At least 1 µs.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
// At most 1 ms.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -39,11 +39,14 @@ pub mod constants {
|
||||
|
||||
// At least 100 µs.
|
||||
assert!(
|
||||
w >= 100u64 * constants::WEIGHT_PER_MICROS,
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
"Weight should be at least 100 µs."
|
||||
);
|
||||
// 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();
|
||||
|
||||
// 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.
|
||||
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() {
|
||||
// At least 1 µs.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
// At most 1 ms.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,20 +42,20 @@ pub mod constants {
|
||||
fn sane() {
|
||||
// At least 1 µs.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
// At most 1 ms.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -69,8 +69,14 @@ mod test_weights {
|
||||
let w = super::BlockExecutionWeight::get();
|
||||
|
||||
// At least 100 µs.
|
||||
assert!(w >= 100u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs.");
|
||||
assert!(
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
"Weight should be at least 100 µs."
|
||||
);
|
||||
// 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."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,14 @@ mod test_weights {
|
||||
let w = super::ExtrinsicBaseWeight::get();
|
||||
|
||||
// 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.
|
||||
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() {
|
||||
// At least 1 µs.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
// At most 1 ms.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,20 +42,20 @@ pub mod constants {
|
||||
fn sane() {
|
||||
// At least 1 µs.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
// At most 1 ms.
|
||||
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."
|
||||
);
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ fn remove_keys_weight_is_sensible() {
|
||||
use runtime_common::crowdloan::WeightInfo;
|
||||
let max_weight = <Runtime as crowdloan::Config>::WeightInfo::refund(RemoveKeysLimit::get());
|
||||
// Max remove keys limit should be no more than half the total block weight.
|
||||
assert!(max_weight * 2 < BlockWeights::get().max_block);
|
||||
assert!((max_weight * 2).all_lt(BlockWeights::get().max_block));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -35,11 +35,9 @@ fn sample_size_is_sensible() {
|
||||
let max_weight: frame_support::weights::Weight =
|
||||
RocksDbWeight::get().reads_writes(samples.into(), samples.into());
|
||||
// Max sample cleanup should be no more than half the total block weight.
|
||||
assert!(max_weight * 2 < BlockWeights::get().max_block);
|
||||
assert!(
|
||||
<Runtime as auctions::Config>::WeightInfo::on_initialize() * 2 <
|
||||
BlockWeights::get().max_block
|
||||
);
|
||||
assert!((max_weight * 2).all_lt(BlockWeights::get().max_block));
|
||||
assert!((<Runtime as auctions::Config>::WeightInfo::on_initialize() * 2)
|
||||
.all_lt(BlockWeights::get().max_block));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -67,5 +65,5 @@ fn sanity_check_teleport_assets_weight() {
|
||||
.get_dispatch_info()
|
||||
.weight;
|
||||
|
||||
assert!(weight * 50 < BlockWeights::get().max_block);
|
||||
assert!((weight * 50).all_lt(BlockWeights::get().max_block));
|
||||
}
|
||||
|
||||
@@ -908,7 +908,7 @@ pub mod pallet {
|
||||
SupportedVersion::<T>::insert(XCM_VERSION, new_key, value);
|
||||
}
|
||||
weight_used.saturating_accrue(todo_sv_migrate_weight);
|
||||
if weight_used >= weight_cutoff {
|
||||
if weight_used.any_gte(weight_cutoff) {
|
||||
return (weight_used, Some(stage))
|
||||
}
|
||||
}
|
||||
@@ -922,7 +922,7 @@ pub mod pallet {
|
||||
VersionNotifiers::<T>::insert(XCM_VERSION, new_key, value);
|
||||
}
|
||||
weight_used.saturating_accrue(todo_vn_migrate_weight);
|
||||
if weight_used >= weight_cutoff {
|
||||
if weight_used.any_gte(weight_cutoff) {
|
||||
return (weight_used, Some(stage))
|
||||
}
|
||||
}
|
||||
@@ -963,7 +963,7 @@ pub mod pallet {
|
||||
};
|
||||
Self::deposit_event(event);
|
||||
weight_used.saturating_accrue(todo_vnt_notify_weight);
|
||||
if weight_used >= weight_cutoff {
|
||||
if weight_used.any_gte(weight_cutoff) {
|
||||
let last = Some(iter.last_raw_key().into());
|
||||
return (weight_used, Some(NotifyCurrentTargets(last)))
|
||||
}
|
||||
@@ -981,7 +981,7 @@ pub mod pallet {
|
||||
old_key, value.0,
|
||||
));
|
||||
weight_used.saturating_accrue(todo_vnt_migrate_fail_weight);
|
||||
if weight_used >= weight_cutoff {
|
||||
if weight_used.any_gte(weight_cutoff) {
|
||||
return (weight_used, Some(stage))
|
||||
}
|
||||
continue
|
||||
@@ -1011,7 +1011,7 @@ pub mod pallet {
|
||||
Self::deposit_event(event);
|
||||
weight_used.saturating_accrue(todo_vnt_notify_migrate_weight);
|
||||
}
|
||||
if weight_used >= weight_cutoff {
|
||||
if weight_used.any_gte(weight_cutoff) {
|
||||
return (weight_used, Some(stage))
|
||||
}
|
||||
}
|
||||
@@ -1405,7 +1405,7 @@ pub mod pallet {
|
||||
Queries::<T>::remove(query_id);
|
||||
let weight = call.get_dispatch_info().weight;
|
||||
let max_weight = Weight::from_ref_time(max_weight);
|
||||
if weight > max_weight {
|
||||
if weight.any_gt(max_weight) {
|
||||
let e = Event::NotifyOverweight(
|
||||
query_id,
|
||||
pallet_index,
|
||||
|
||||
Reference in New Issue
Block a user