From 5663a0946115a1251f26222edd75f6a621c41485 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 2 Apr 2023 23:38:17 +0300 Subject: [PATCH] Switch from deprecated `Weight::from_ref_time` to `Weight::from_parts` --- .../pallet-grandpa-finality-verifier/src/tests/mock.rs | 2 +- crates/pallet-rewards/src/default_weights.rs | 2 +- crates/pallet-subspace/src/default_weights.rs | 6 +++--- crates/pallet-subspace/src/mock.rs | 2 +- crates/pallet-subspace/src/tests.rs | 2 +- crates/pallet-transaction-fees/src/default_weights.rs | 2 +- crates/subspace-runtime/src/weights/subspace.rs | 4 ++-- domains/pallets/domain-registry/src/tests.rs | 8 ++++---- domains/pallets/executive/src/lib.rs | 2 +- domains/runtime/core-eth-relay/src/runtime.rs | 2 +- domains/runtime/core-payments/src/runtime.rs | 2 +- orml/vesting/src/weights.rs | 10 +++++----- substrate/substrate-test-runtime/src/lib.rs | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/crates/pallet-grandpa-finality-verifier/src/tests/mock.rs b/crates/pallet-grandpa-finality-verifier/src/tests/mock.rs index 078dc6540c..2dc32f0f92 100644 --- a/crates/pallet-grandpa-finality-verifier/src/tests/mock.rs +++ b/crates/pallet-grandpa-finality-verifier/src/tests/mock.rs @@ -24,7 +24,7 @@ construct_runtime! { parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024); + pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/crates/pallet-rewards/src/default_weights.rs b/crates/pallet-rewards/src/default_weights.rs index af96863360..69d1d01f5b 100644 --- a/crates/pallet-rewards/src/default_weights.rs +++ b/crates/pallet-rewards/src/default_weights.rs @@ -21,6 +21,6 @@ use frame_support::weights::Weight; impl crate::WeightInfo for () { fn on_initialize() -> Weight { // TODO: Correct value - Weight::from_ref_time(1) + Weight::from_parts(1, 0) } } diff --git a/crates/pallet-subspace/src/default_weights.rs b/crates/pallet-subspace/src/default_weights.rs index 5aa8a956ca..21bd6eda98 100644 --- a/crates/pallet-subspace/src/default_weights.rs +++ b/crates/pallet-subspace/src/default_weights.rs @@ -21,16 +21,16 @@ use frame_support::weights::Weight; impl crate::WeightInfo for () { fn report_equivocation() -> Weight { // TODO: Proper value - Weight::from_ref_time(10_000) + Weight::from_parts(10_000, 0) } fn store_segment_headers(segment_headers_count: usize) -> Weight { // TODO: Proper value - Weight::from_ref_time(10_000 * (segment_headers_count as u64 + 1)) + Weight::from_parts(10_000 * (segment_headers_count as u64 + 1), 0) } fn vote() -> Weight { // TODO: Proper value - Weight::from_ref_time(10_000) + Weight::from_parts(10_000, 0) } } diff --git a/crates/pallet-subspace/src/mock.rs b/crates/pallet-subspace/src/mock.rs index 57cb7d796c..d8b5bc8b1e 100644 --- a/crates/pallet-subspace/src/mock.rs +++ b/crates/pallet-subspace/src/mock.rs @@ -68,7 +68,7 @@ frame_support::construct_runtime!( parameter_types! { pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(16); pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(1024)); + frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0)); } impl frame_system::Config for Test { diff --git a/crates/pallet-subspace/src/tests.rs b/crates/pallet-subspace/src/tests.rs index 727b304036..ebbdcff8cd 100644 --- a/crates/pallet-subspace/src/tests.rs +++ b/crates/pallet-subspace/src/tests.rs @@ -472,7 +472,7 @@ fn report_equivocation_has_valid_weight() { // the weight is always the same. assert!((1..=1000) .map(|_| { ::WeightInfo::report_equivocation() }) - .all(|w| w == Weight::from_ref_time(10_000))); + .all(|w| w == Weight::from_parts(10_000, 0))); } #[test] diff --git a/crates/pallet-transaction-fees/src/default_weights.rs b/crates/pallet-transaction-fees/src/default_weights.rs index af96863360..69d1d01f5b 100644 --- a/crates/pallet-transaction-fees/src/default_weights.rs +++ b/crates/pallet-transaction-fees/src/default_weights.rs @@ -21,6 +21,6 @@ use frame_support::weights::Weight; impl crate::WeightInfo for () { fn on_initialize() -> Weight { // TODO: Correct value - Weight::from_ref_time(1) + Weight::from_parts(1, 0) } } diff --git a/crates/subspace-runtime/src/weights/subspace.rs b/crates/subspace-runtime/src/weights/subspace.rs index 453dda474d..1cc0c02a17 100644 --- a/crates/subspace-runtime/src/weights/subspace.rs +++ b/crates/subspace-runtime/src/weights/subspace.rs @@ -6,12 +6,12 @@ pub struct WeightInfo; impl pallet_subspace::WeightInfo for WeightInfo { fn report_equivocation() -> Weight { // TODO: Proper value - Weight::from_ref_time(10_000) + Weight::from_parts(10_000, 0) } fn store_segment_headers(segment_headers_count: usize) -> Weight { // TODO: Proper value - Weight::from_ref_time(10_000 * (segment_headers_count as u64 + 1)) + Weight::from_parts(10_000 * (segment_headers_count as u64 + 1), 0) } fn vote() -> Weight { diff --git a/domains/pallets/domain-registry/src/tests.rs b/domains/pallets/domain-registry/src/tests.rs index 8872e01a9c..1d723ce509 100644 --- a/domains/pallets/domain-registry/src/tests.rs +++ b/domains/pallets/domain-registry/src/tests.rs @@ -184,7 +184,7 @@ fn new_test_ext() -> sp_io::TestExternalities { wasm_runtime_hash: Hash::repeat_byte(1), bundle_slot_probability: (1, 1), max_bundle_size: 1024 * 1024, - max_bundle_weight: Weight::from_ref_time(100_000_000_000), + max_bundle_weight: Weight::from_parts(100_000_000_000, 0), min_operator_stake: 20, }, 1, @@ -205,7 +205,7 @@ fn create_domain_should_work() { wasm_runtime_hash: Hash::repeat_byte(1), bundle_slot_probability: (1, 1), max_bundle_size: 1024 * 1024, - max_bundle_weight: Weight::from_ref_time(100_000_000_000), + max_bundle_weight: Weight::from_parts(100_000_000_000, 0), min_operator_stake: 20, }; assert_eq!( @@ -222,7 +222,7 @@ fn create_domain_should_work() { wasm_runtime_hash: Hash::random(), bundle_slot_probability: (1, 1), max_bundle_size: 1024 * 1024, - max_bundle_weight: Weight::from_ref_time(100_000_000_000), + max_bundle_weight: Weight::from_parts(100_000_000_000, 0), min_operator_stake: 20, }; @@ -312,7 +312,7 @@ fn register_domain_operator_and_update_domain_stake_should_work() { wasm_runtime_hash: Hash::random(), bundle_slot_probability: (1, 1), max_bundle_size: 1024 * 1024, - max_bundle_weight: Weight::from_ref_time(100_000_000_000), + max_bundle_weight: Weight::from_parts(100_000_000_000, 0), min_operator_stake: 20, } )); diff --git a/domains/pallets/executive/src/lib.rs b/domains/pallets/executive/src/lib.rs index 0112dad8ba..1a7d931785 100644 --- a/domains/pallets/executive/src/lib.rs +++ b/domains/pallets/executive/src/lib.rs @@ -101,7 +101,7 @@ mod pallet { // Reset the intermediate storage roots from last block. IntermediateRoots::::kill(); // TODO: Probably needs a different value - Weight::from_ref_time(1) + Weight::from_parts(1, 0) } } diff --git a/domains/runtime/core-eth-relay/src/runtime.rs b/domains/runtime/core-eth-relay/src/runtime.rs index 589b0fc301..d73a38d3e7 100644 --- a/domains/runtime/core-eth-relay/src/runtime.rs +++ b/domains/runtime/core-eth-relay/src/runtime.rs @@ -514,7 +514,7 @@ impl_runtime_apis! { UncheckedExtrinsic::new_unsigned( domain_pallet_executive::Call::sudo_unchecked_weight_unsigned { call: Box::new(set_code_call.into()), - weight: Weight::from_ref_time(0), + weight: Weight::from_parts(0, 0), }.into() ).encode() } diff --git a/domains/runtime/core-payments/src/runtime.rs b/domains/runtime/core-payments/src/runtime.rs index 994fea4c6d..67ebd3aa81 100644 --- a/domains/runtime/core-payments/src/runtime.rs +++ b/domains/runtime/core-payments/src/runtime.rs @@ -455,7 +455,7 @@ impl_runtime_apis! { UncheckedExtrinsic::new_unsigned( domain_pallet_executive::Call::sudo_unchecked_weight_unsigned { call: Box::new(set_code_call.into()), - weight: Weight::from_ref_time(0), + weight: Weight::from_parts(0, 0), }.into() ).encode() } diff --git a/orml/vesting/src/weights.rs b/orml/vesting/src/weights.rs index de4832378e..dee57ab4d2 100644 --- a/orml/vesting/src/weights.rs +++ b/orml/vesting/src/weights.rs @@ -38,21 +38,21 @@ pub trait WeightInfo { /// Default weights. impl WeightInfo for () { fn vested_transfer() -> Weight { - Weight::from_ref_time(69_000_000) + Weight::from_parts(69_000_000, 0) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } fn claim(i: u32, ) -> Weight { - Weight::from_ref_time(31_747_000) + Weight::from_parts(31_747_000, 0) // Standard Error: 4_000 - .saturating_add(Weight::from_ref_time(63_000).saturating_mul(i as u64)) + .saturating_add(Weight::from_parts(63_000, 0).saturating_mul(i as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } fn update_vesting_schedules(i: u32, ) -> Weight { - Weight::from_ref_time(29_457_000) + Weight::from_parts(29_457_000, 0) // Standard Error: 4_000 - .saturating_add(Weight::from_ref_time(117_000).saturating_mul(i as u64)) + .saturating_add(Weight::from_parts(117_000, 0).saturating_mul(i as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } diff --git a/substrate/substrate-test-runtime/src/lib.rs b/substrate/substrate-test-runtime/src/lib.rs index 767a86af21..4cdfb5665d 100644 --- a/substrate/substrate-test-runtime/src/lib.rs +++ b/substrate/substrate-test-runtime/src/lib.rs @@ -579,7 +579,7 @@ parameter_types! { pub RuntimeBlockLength: BlockLength = BlockLength::max(4 * 1024 * 1024); pub RuntimeBlockWeights: BlockWeights = - BlockWeights::with_sensible_defaults(Weight::from_ref_time(4 * 1024 * 1024), Perbill::from_percent(75)); + BlockWeights::with_sensible_defaults(Weight::from_parts(4 * 1024 * 1024, 0), Perbill::from_percent(75)); } impl From> for Extrinsic {