Skip to content

Commit

Permalink
Switch from deprecated Weight::from_ref_time to Weight::from_parts
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Apr 2, 2023
1 parent 1baac0f commit 5663a09
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion crates/pallet-grandpa-finality-verifier/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion crates/pallet-rewards/src/default_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
6 changes: 3 additions & 3 deletions crates/pallet-subspace/src/default_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion crates/pallet-subspace/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/pallet-subspace/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ fn report_equivocation_has_valid_weight() {
// the weight is always the same.
assert!((1..=1000)
.map(|_| { <Test as Config>::WeightInfo::report_equivocation() })
.all(|w| w == Weight::from_ref_time(10_000)));
.all(|w| w == Weight::from_parts(10_000, 0)));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/pallet-transaction-fees/src/default_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
4 changes: 2 additions & 2 deletions crates/subspace-runtime/src/weights/subspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions domains/pallets/domain-registry/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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!(
Expand All @@ -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,
};

Expand Down Expand Up @@ -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,
}
));
Expand Down
2 changes: 1 addition & 1 deletion domains/pallets/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ mod pallet {
// Reset the intermediate storage roots from last block.
IntermediateRoots::<T>::kill();
// TODO: Probably needs a different value
Weight::from_ref_time(1)
Weight::from_parts(1, 0)
}
}

Expand Down
2 changes: 1 addition & 1 deletion domains/runtime/core-eth-relay/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion domains/runtime/core-payments/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
10 changes: 5 additions & 5 deletions orml/vesting/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion substrate/substrate-test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<frame_system::Call<Runtime>> for Extrinsic {
Expand Down

0 comments on commit 5663a09

Please sign in to comment.