Deprecate Weight::from_{ref_time, proof_size} (#13475)

* Deprecate Weight::from_{ref_time, proof_size}

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update templates

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Use from_parts

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Use from_parts

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Dont revert comment 🤦

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_balances

* Update weight files

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* More fixes

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Adapt to Master changes

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: command-bot <>
This commit is contained in:
Oliver Tale-Yazdi
2023-03-02 22:28:17 +01:00
committed by GitHub
parent 7981d4aa59
commit 9e56e1acdd
101 changed files with 2695 additions and 2857 deletions
@@ -701,345 +701,177 @@ mod max_weight {
let w = SolutionOrSnapshotSize { voters: 10, targets: 0 };
MockWeightInfo::set(crate::mock::MockedWeightInfo::Complex);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::zero().set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(0, u64::MAX)),
0
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1, u64::MAX)),
0
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(999).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(999, u64::MAX)),
0
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1000).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1000, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1001).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1001, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1990).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1990, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1999).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1999, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2000).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2000, u64::MAX)),
2
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2001).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2001, u64::MAX)),
2
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2010).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2010, u64::MAX)),
2
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2990).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2990, u64::MAX)),
2
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2999).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2999, u64::MAX)),
2
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(3000).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(3000, u64::MAX)),
3
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(3333).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(3333, u64::MAX)),
3
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(5500).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(5500, u64::MAX)),
5
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(7777).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(7777, u64::MAX)),
7
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(9999).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(9999, u64::MAX)),
9
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(10_000).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(10_000, u64::MAX)),
10
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(10_999).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(10_999, u64::MAX)),
10
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(11_000).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(11_000, u64::MAX)),
10
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(22_000).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(22_000, u64::MAX)),
10
);
let w = SolutionOrSnapshotSize { voters: 1, targets: 0 };
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(0).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(0, u64::MAX)),
0
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1, u64::MAX)),
0
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(999).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(999, u64::MAX)),
0
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1000).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1000, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1001).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1001, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1990).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1990, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1999).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1999, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2000).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2000, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2001).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2001, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2010).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2010, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(3333).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(3333, u64::MAX)),
1
);
let w = SolutionOrSnapshotSize { voters: 2, targets: 0 };
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(0).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(0, u64::MAX)),
0
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1, u64::MAX)),
0
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(999).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(999, u64::MAX)),
0
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1000).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1000, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1001).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1001, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(1999).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(1999, u64::MAX)),
1
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2000).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2000, u64::MAX)),
2
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2001).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2001, u64::MAX)),
2
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(2010).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(2010, u64::MAX)),
2
);
assert_eq!(
Miner::<Runtime>::maximum_voter_for_weight(
0,
w,
Weight::from_ref_time(3333).set_proof_size(u64::MAX)
),
Miner::<Runtime>::maximum_voter_for_weight(0, w, Weight::from_parts(3333, u64::MAX)),
2
);
}
@@ -1340,7 +1172,7 @@ mod tests {
#[test]
fn miner_trims_weight() {
ExtBuilder::default()
.miner_weight(Weight::from_ref_time(100).set_proof_size(u64::MAX))
.miner_weight(Weight::from_parts(100, u64::MAX))
.mock_weight_info(crate::mock::MockedWeightInfo::Basic)
.build_and_execute(|| {
roll_to_unsigned();
@@ -1354,11 +1186,11 @@ mod tests {
raw.solution.unique_targets().len() as u32,
);
// default solution will have 5 edges (5 * 5 + 10)
assert_eq!(solution_weight, Weight::from_ref_time(35));
assert_eq!(solution_weight, Weight::from_parts(35, 0));
assert_eq!(raw.solution.voter_count(), 5);
// now reduce the max weight
<MinerMaxWeight>::set(Weight::from_ref_time(25).set_proof_size(u64::MAX));
<MinerMaxWeight>::set(Weight::from_parts(25, u64::MAX));
let (raw, witness) = MultiPhase::mine_solution().unwrap();
let solution_weight = <Runtime as MinerConfig>::solution_weight(
@@ -1368,7 +1200,7 @@ mod tests {
raw.solution.unique_targets().len() as u32,
);
// default solution will have 5 edges (5 * 5 + 10)
assert_eq!(solution_weight, Weight::from_ref_time(25));
assert_eq!(solution_weight, Weight::from_parts(25, 0));
assert_eq!(raw.solution.voter_count(), 3);
})
}