Skip to content

Commit 91b1a4a

Browse files
ggwpeznathanwhit
authored andcommitted
Deprecate Weight::from_{ref_time, proof_size} (paritytech#13475)
* Deprecate Weight::from_{ref_time, proof_size} Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Update templates Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Use from_parts Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Use from_parts Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Dont revert comment 🤦 Signed-off-by: Oliver Tale-Yazdi <[email protected]> * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_balances * Update weight files Signed-off-by: Oliver Tale-Yazdi <[email protected]> * More fixes Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Adapt to Master changes Signed-off-by: Oliver Tale-Yazdi <[email protected]> --------- Signed-off-by: Oliver Tale-Yazdi <[email protected]> Co-authored-by: command-bot <>
1 parent 558d159 commit 91b1a4a

File tree

101 files changed

+2695
-2857
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2695
-2857
lines changed

.maintain/frame-weight-template.hbs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
5252
// Proof Size summary in bytes:
5353
// Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
5454
// Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
55-
// Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds.
56-
Weight::from_ref_time({{underscore benchmark.base_weight}})
57-
.saturating_add(Weight::from_proof_size({{benchmark.base_calculated_proof_size}}))
55+
// Minimum execution time: {{underscore benchmark.min_execution_time}}_000 picoseconds.
56+
Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}})
5857
{{#each benchmark.component_weight as |cw|}}
5958
// Standard Error: {{underscore cw.error}}
60-
.saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into()))
59+
.saturating_add(Weight::from_parts({{underscore cw.slope}}, 0).saturating_mul({{cw.name}}.into()))
6160
{{/each}}
6261
{{#if (ne benchmark.base_reads "0")}}
6362
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}_u64))
@@ -72,7 +71,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
7271
.saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into())))
7372
{{/each}}
7473
{{#each benchmark.component_calculated_proof_size as |cp|}}
75-
.saturating_add(Weight::from_proof_size({{cp.slope}}).saturating_mul({{cp.name}}.into()))
74+
.saturating_add(Weight::from_parts(0, {{cp.slope}}).saturating_mul({{cp.name}}.into()))
7675
{{/each}}
7776
}
7877
{{/each}}
@@ -95,12 +94,11 @@ impl WeightInfo for () {
9594
// Proof Size summary in bytes:
9695
// Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
9796
// Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
98-
// Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds.
99-
Weight::from_ref_time({{underscore benchmark.base_weight}})
100-
.saturating_add(Weight::from_proof_size({{benchmark.base_calculated_proof_size}}))
97+
// Minimum execution time: {{underscore benchmark.min_execution_time}}_000 picoseconds.
98+
Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}})
10199
{{#each benchmark.component_weight as |cw|}}
102100
// Standard Error: {{underscore cw.error}}
103-
.saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into()))
101+
.saturating_add(Weight::from_parts({{underscore cw.slope}}, 0).saturating_mul({{cw.name}}.into()))
104102
{{/each}}
105103
{{#if (ne benchmark.base_reads "0")}}
106104
.saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}}_u64))
@@ -115,7 +113,7 @@ impl WeightInfo for () {
115113
.saturating_add(RocksDbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into())))
116114
{{/each}}
117115
{{#each benchmark.component_calculated_proof_size as |cp|}}
118-
.saturating_add(Weight::from_proof_size({{cp.slope}}).saturating_mul({{cp.name}}.into()))
116+
.saturating_add(Weight::from_parts(0, {{cp.slope}}).saturating_mul({{cp.name}}.into()))
119117
{{/each}}
120118
}
121119
{{/each}}

bin/node/executor/tests/basic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ fn deploying_wasm_contract_should_work() {
682682
Runtime,
683683
> {
684684
value: 0,
685-
gas_limit: Weight::from_ref_time(500_000_000),
685+
gas_limit: Weight::from_parts(500_000_000, 0),
686686
storage_deposit_limit: None,
687687
code: transfer_code,
688688
data: Vec::new(),
@@ -694,7 +694,7 @@ fn deploying_wasm_contract_should_work() {
694694
function: RuntimeCall::Contracts(pallet_contracts::Call::call::<Runtime> {
695695
dest: sp_runtime::MultiAddress::Id(addr.clone()),
696696
value: 10,
697-
gas_limit: Weight::from_ref_time(500_000_000),
697+
gas_limit: Weight::from_parts(500_000_000, 0),
698698
storage_deposit_limit: None,
699699
data: vec![0x00, 0x01, 0x02, 0x03],
700700
}),

bin/node/runtime/src/impls.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ mod multiplier_tests {
199199
let fm = Multiplier::saturating_from_rational(1, 2);
200200
let test_set = vec![
201201
(Weight::zero(), fm),
202-
(Weight::from_ref_time(100), fm),
203-
(Weight::from_ref_time(1000), fm),
202+
(Weight::from_parts(100, 0), fm),
203+
(Weight::from_parts(1000, 0), fm),
204204
(target(), fm),
205205
(max_normal() / 2, fm),
206206
(max_normal(), fm),
@@ -285,7 +285,7 @@ mod multiplier_tests {
285285

286286
// almost full. The entire quota of normal transactions is taken.
287287
let block_weight = BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap() -
288-
Weight::from_ref_time(100);
288+
Weight::from_parts(100, 0);
289289

290290
// Default substrate weight.
291291
let tx_weight = frame_support::weights::constants::ExtrinsicBaseWeight::get();
@@ -409,23 +409,23 @@ mod multiplier_tests {
409409

410410
#[test]
411411
fn weight_to_fee_should_not_overflow_on_large_weights() {
412-
let kb = Weight::from_ref_time(1024);
412+
let kb = Weight::from_parts(1024, 0);
413413
let mb = 1024u64 * kb;
414414
let max_fm = Multiplier::saturating_from_integer(i128::MAX);
415415

416416
// check that for all values it can compute, correctly.
417417
vec![
418418
Weight::zero(),
419-
Weight::from_ref_time(1),
420-
Weight::from_ref_time(10),
421-
Weight::from_ref_time(1000),
419+
Weight::from_parts(1, 0),
420+
Weight::from_parts(10, 0),
421+
Weight::from_parts(1000, 0),
422422
kb,
423423
10u64 * kb,
424424
100u64 * kb,
425425
mb,
426426
10u64 * mb,
427-
Weight::from_ref_time(2147483647),
428-
Weight::from_ref_time(4294967295),
427+
Weight::from_parts(2147483647, 0),
428+
Weight::from_parts(4294967295, 0),
429429
BlockWeights::get().max_block / 2,
430430
BlockWeights::get().max_block,
431431
Weight::MAX / 2,
@@ -442,7 +442,7 @@ mod multiplier_tests {
442442

443443
// Some values that are all above the target and will cause an increase.
444444
let t = target();
445-
vec![t + Weight::from_ref_time(100), t * 2, t * 4].into_iter().for_each(|i| {
445+
vec![t + Weight::from_parts(100, 0), t * 2, t * 4].into_iter().for_each(|i| {
446446
run_with_system_weight(i, || {
447447
let fm = runtime_multiplier_update(max_fm);
448448
// won't grow. The convert saturates everything.

0 commit comments

Comments
 (0)