Companion for Weight v1.5 (#5943)

* fix to latest substrate pr

* update weights

* cargo build -p polkadot-runtime-parachains

* fix xcm-builder

* fix import

* fix a bunch

* fix a bunch of weight stuff

* kusama compile

* unused

* builds

* maybe fix

* cargo test -p polkadot-runtime-parachains

* xcm simulator example

* fix tests

* xcm sim fuzz

* fix runtime tests

* remove unused

* fix integration tests

* scalar div

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Shawn Tabrizi
2022-08-31 12:59:39 +01:00
committed by GitHub
parent 138aae0a22
commit 28e94d97dd
231 changed files with 4577 additions and 4514 deletions
@@ -339,7 +339,8 @@ impl<T: Config> Pallet<T> {
let max_block_weight = <T as frame_system::Config>::BlockWeights::get().max_block;
METRICS.on_before_filter(candidates_weight + bitfields_weight + disputes_weight);
METRICS
.on_before_filter((candidates_weight + bitfields_weight + disputes_weight).ref_time());
T::DisputesHandler::assure_deduplicated_and_sorted(&mut disputes)
.map_err(|_e| Error::<T>::DisputeStatementsUnsortedOrDuplicates)?;
@@ -377,9 +378,9 @@ impl<T: Config> Pallet<T> {
{
log::warn!("Overweight para inherent data reached the runtime {:?}", parent_hash);
backed_candidates.clear();
candidates_weight = 0;
candidates_weight = Weight::zero();
signed_bitfields.clear();
bitfields_weight = 0;
bitfields_weight = Weight::zero();
}
let entropy = compute_entropy::<T>(parent_hash);
@@ -537,7 +538,7 @@ impl<T: Config> Pallet<T> {
// this is max config.ump_service_total_weight
let _ump_weight = <ump::Pallet<T>>::process_pending_upward_messages();
METRICS.on_after_filter(total_consumed_weight);
METRICS.on_after_filter(total_consumed_weight.ref_time());
Ok(Some(total_consumed_weight).into())
}
@@ -803,7 +804,7 @@ fn random_sel<X, F: Fn(&X) -> Weight>(
weight_limit: Weight,
) -> (Weight, Vec<usize>) {
if selectables.is_empty() {
return (0 as Weight, Vec::new())
return (Weight::zero(), Vec::new())
}
// all indices that are not part of the preferred set
let mut indices = (0..selectables.len())
@@ -812,7 +813,7 @@ fn random_sel<X, F: Fn(&X) -> Weight>(
.collect::<Vec<_>>();
let mut picked_indices = Vec::with_capacity(selectables.len().saturating_sub(1));
let mut weight_acc = 0 as Weight;
let mut weight_acc = Weight::zero();
preferred_indices.shuffle(rng);
for preferred_idx in preferred_indices {
@@ -893,7 +894,7 @@ fn apply_weight_limit<T: Config + inclusion::Config>(
// There is weight remaining to be consumed by a subset of candidates
// which are going to be picked now.
if let Some(max_consumable_by_candidates) =
max_consumable_weight.checked_sub(total_bitfields_weight)
max_consumable_weight.checked_sub(&total_bitfields_weight)
{
let (acc_candidate_weight, indices) =
random_sel::<BackedCandidate<<T as frame_system::Config>::Hash>, _>(
@@ -1265,7 +1266,7 @@ fn limit_and_sanitize_disputes<
let remote_disputes = disputes.split_off(idx);
// Accumualated weight of all disputes picked, that passed the checks.
let mut weight_acc = 0 as Weight;
let mut weight_acc = Weight::zero();
// Select disputes in-order until the remaining weight is attained
disputes.iter().for_each(|dss| {
@@ -37,18 +37,18 @@ pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn enter_variable_disputes(v: u32) -> Weight {
// MAX Block Weight should fit 4 disputes
80_000 * v as Weight + 80_000
Weight::from_ref_time(80_000 * v as u64 + 80_000)
}
fn enter_bitfields() -> Weight {
// MAX Block Weight should fit 4 backed candidates
40_000 as Weight
Weight::from_ref_time(40_000u64)
}
fn enter_backed_candidates_variable(v: u32) -> Weight {
// MAX Block Weight should fit 4 backed candidates
40_000 * v as Weight + 40_000
Weight::from_ref_time(40_000 * v as u64 + 40_000)
}
fn enter_backed_candidate_code_upgrade() -> Weight {
0
Weight::zero()
}
}
// To simplify benchmarks running as tests, we set all the weights to 0. `enter` will exit early
@@ -57,16 +57,16 @@ impl WeightInfo for TestWeightInfo {
#[cfg(feature = "runtime-benchmarks")]
impl WeightInfo for TestWeightInfo {
fn enter_variable_disputes(_v: u32) -> Weight {
0
Weight::zero()
}
fn enter_bitfields() -> Weight {
0
Weight::zero()
}
fn enter_backed_candidates_variable(_v: u32) -> Weight {
0
Weight::zero()
}
fn enter_backed_candidate_code_upgrade() -> Weight {
0
Weight::zero()
}
}
@@ -99,12 +99,12 @@ pub fn multi_dispute_statement_sets_weight<
.as_ref()
.iter()
.map(|d| dispute_statement_set_weight::<T, &S>(d))
.fold(0, |acc_weight, weight| acc_weight.saturating_add(weight))
.fold(Weight::new(), |acc_weight, weight| acc_weight.saturating_add(weight))
}
pub fn signed_bitfields_weight<T: Config>(bitfields_len: usize) -> Weight {
<<T as Config>::WeightInfo as WeightInfo>::enter_bitfields()
.saturating_mul(bitfields_len as Weight)
.saturating_mul(Weight::from_ref_time(bitfields_len as u64))
}
pub fn backed_candidate_weight<T: frame_system::Config + Config>(
@@ -125,5 +125,5 @@ pub fn backed_candidates_weight<T: frame_system::Config + Config>(
candidates
.iter()
.map(|c| backed_candidate_weight::<T>(c))
.fold(0, |acc, x| acc.saturating_add(x))
.fold(Weight::new(), |acc, x| acc.saturating_add(x))
}