mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 06:41:02 +00:00
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:
committed by
GitHub
parent
7981d4aa59
commit
9e56e1acdd
@@ -314,7 +314,7 @@ pub trait WithPostDispatchInfo {
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// let who = ensure_signed(origin).map_err(|e| e.with_weight(Weight::from_ref_time(100)))?;
|
||||
/// let who = ensure_signed(origin).map_err(|e| e.with_weight(Weight::from_parts(100, 0)))?;
|
||||
/// ensure!(who == me, Error::<T>::NotMe.with_weight(200_000));
|
||||
/// ```
|
||||
fn with_weight(self, actual_weight: Weight) -> DispatchErrorWithPostInfo;
|
||||
@@ -365,7 +365,7 @@ impl<Call: Encode + GetDispatchInfo, Extra: Encode> GetDispatchInfo
|
||||
fn get_dispatch_info(&self) -> DispatchInfo {
|
||||
// for testing: weight == size.
|
||||
DispatchInfo {
|
||||
weight: Weight::from_ref_time(self.encode().len() as _),
|
||||
weight: Weight::from_parts(self.encode().len() as _, 0),
|
||||
pays_fee: Pays::Yes,
|
||||
class: self.call.get_dispatch_info().class,
|
||||
}
|
||||
@@ -552,7 +552,7 @@ impl<T> ClassifyDispatch<T> for (Weight, DispatchClass, Pays) {
|
||||
impl From<Option<u64>> for PostDispatchInfo {
|
||||
fn from(maybe_actual_computation: Option<u64>) -> Self {
|
||||
let actual_weight = match maybe_actual_computation {
|
||||
Some(actual_computation) => Some(Weight::zero().set_ref_time(actual_computation)),
|
||||
Some(actual_computation) => Some(Weight::from_parts(actual_computation, 0)),
|
||||
None => None,
|
||||
};
|
||||
Self { actual_weight, pays_fee: Default::default() }
|
||||
@@ -563,7 +563,7 @@ impl From<(Option<u64>, Pays)> for PostDispatchInfo {
|
||||
fn from(post_weight_info: (Option<u64>, Pays)) -> Self {
|
||||
let (maybe_actual_time, pays_fee) = post_weight_info;
|
||||
let actual_weight = match maybe_actual_time {
|
||||
Some(actual_time) => Some(Weight::zero().set_ref_time(actual_time)),
|
||||
Some(actual_time) => Some(Weight::from_parts(actual_time, 0)),
|
||||
None => None,
|
||||
};
|
||||
Self { actual_weight, pays_fee }
|
||||
@@ -584,7 +584,7 @@ impl<T> PaysFee<T> for u64 {
|
||||
|
||||
impl<T> WeighData<T> for u64 {
|
||||
fn weigh_data(&self, _: T) -> Weight {
|
||||
return Weight::zero().set_ref_time(*self)
|
||||
return Weight::from_parts(*self, 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ impl<T> PaysFee<T> for (u64, Pays) {
|
||||
/// pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin {
|
||||
/// #[weight = 1_000_000]
|
||||
/// fn my_long_function(origin, do_expensive_calc: bool) -> DispatchResultWithPostInfo {
|
||||
/// ensure_signed(origin).map_err(|e| e.with_weight(Weight::from_ref_time(100_000)))?;
|
||||
/// ensure_signed(origin).map_err(|e| e.with_weight(Weight::from_parts(100_000, 0)))?;
|
||||
/// if do_expensive_calc {
|
||||
/// // do the expensive calculation
|
||||
/// // ...
|
||||
@@ -3239,13 +3239,13 @@ mod tests {
|
||||
#[weight = (5, DispatchClass::Operational)]
|
||||
fn operational(_origin) { unreachable!() }
|
||||
|
||||
fn on_initialize(n: T::BlockNumber,) -> Weight { if n.into() == 42 { panic!("on_initialize") } Weight::from_ref_time(7) }
|
||||
fn on_initialize(n: T::BlockNumber,) -> Weight { if n.into() == 42 { panic!("on_initialize") } Weight::from_parts(7, 0) }
|
||||
fn on_idle(n: T::BlockNumber, remaining_weight: Weight,) -> Weight {
|
||||
if n.into() == 42 || remaining_weight == Weight::from_ref_time(42) { panic!("on_idle") }
|
||||
Weight::from_ref_time(7)
|
||||
if n.into() == 42 || remaining_weight == Weight::from_parts(42, 0) { panic!("on_idle") }
|
||||
Weight::from_parts(7, 0)
|
||||
}
|
||||
fn on_finalize(n: T::BlockNumber,) { if n.into() == 42 { panic!("on_finalize") } }
|
||||
fn on_runtime_upgrade() -> Weight { Weight::from_ref_time(10) }
|
||||
fn on_runtime_upgrade() -> Weight { Weight::from_parts(10, 0) }
|
||||
fn offchain_worker() {}
|
||||
/// Some doc
|
||||
fn integrity_test() { panic!("integrity_test") }
|
||||
@@ -3423,27 +3423,27 @@ mod tests {
|
||||
fn on_initialize_should_work_2() {
|
||||
assert_eq!(
|
||||
<Module<TraitImpl> as OnInitialize<u32>>::on_initialize(10),
|
||||
Weight::from_ref_time(7)
|
||||
Weight::from_parts(7, 0)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "on_idle")]
|
||||
fn on_idle_should_work_1() {
|
||||
<Module<TraitImpl> as OnIdle<u32>>::on_idle(42, Weight::from_ref_time(9));
|
||||
<Module<TraitImpl> as OnIdle<u32>>::on_idle(42, Weight::from_parts(9, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "on_idle")]
|
||||
fn on_idle_should_work_2() {
|
||||
<Module<TraitImpl> as OnIdle<u32>>::on_idle(9, Weight::from_ref_time(42));
|
||||
<Module<TraitImpl> as OnIdle<u32>>::on_idle(9, Weight::from_parts(42, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn on_idle_should_work_3() {
|
||||
assert_eq!(
|
||||
<Module<TraitImpl> as OnIdle<u32>>::on_idle(10, Weight::from_ref_time(11)),
|
||||
Weight::from_ref_time(7)
|
||||
<Module<TraitImpl> as OnIdle<u32>>::on_idle(10, Weight::from_parts(11, 0)),
|
||||
Weight::from_parts(7, 0)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3458,7 +3458,7 @@ mod tests {
|
||||
sp_io::TestExternalities::default().execute_with(|| {
|
||||
assert_eq!(
|
||||
<Module<TraitImpl> as OnRuntimeUpgrade>::on_runtime_upgrade(),
|
||||
Weight::from_ref_time(10)
|
||||
Weight::from_parts(10, 0)
|
||||
)
|
||||
});
|
||||
}
|
||||
@@ -3469,7 +3469,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
Call::<TraitImpl>::operational {}.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
weight: Weight::from_ref_time(5),
|
||||
weight: Weight::from_parts(5, 0),
|
||||
class: DispatchClass::Operational,
|
||||
pays_fee: Pays::Yes
|
||||
},
|
||||
@@ -3478,7 +3478,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
Call::<TraitImpl>::aux_3 {}.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
weight: Weight::from_ref_time(3),
|
||||
weight: Weight::from_parts(3, 0),
|
||||
class: DispatchClass::Normal,
|
||||
pays_fee: Pays::Yes
|
||||
},
|
||||
@@ -3567,10 +3567,10 @@ mod weight_tests {
|
||||
#[weight = (0, DispatchClass::Operational, Pays::Yes)]
|
||||
fn f12(_origin, _a: u32, _eb: u32) { unimplemented!(); }
|
||||
|
||||
#[weight = T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) + Weight::from_ref_time(10_000)]
|
||||
#[weight = T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) + Weight::from_parts(10_000, 0)]
|
||||
fn f20(_origin) { unimplemented!(); }
|
||||
|
||||
#[weight = T::DbWeight::get().reads_writes(6, 5) + Weight::from_ref_time(40_000)]
|
||||
#[weight = T::DbWeight::get().reads_writes(6, 5) + Weight::from_parts(40_000, 0)]
|
||||
fn f21(_origin) { unimplemented!(); }
|
||||
|
||||
}
|
||||
@@ -3580,96 +3580,96 @@ mod weight_tests {
|
||||
fn weights_are_correct() {
|
||||
// #[weight = 1000]
|
||||
let info = Call::<TraitImpl>::f00 {}.get_dispatch_info();
|
||||
assert_eq!(info.weight, Weight::from_ref_time(1000));
|
||||
assert_eq!(info.weight, Weight::from_parts(1000, 0));
|
||||
assert_eq!(info.class, DispatchClass::Normal);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
|
||||
// #[weight = (1000, DispatchClass::Mandatory)]
|
||||
let info = Call::<TraitImpl>::f01 {}.get_dispatch_info();
|
||||
assert_eq!(info.weight, Weight::from_ref_time(1000));
|
||||
assert_eq!(info.weight, Weight::from_parts(1000, 0));
|
||||
assert_eq!(info.class, DispatchClass::Mandatory);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
|
||||
// #[weight = (1000, Pays::No)]
|
||||
let info = Call::<TraitImpl>::f02 {}.get_dispatch_info();
|
||||
assert_eq!(info.weight, Weight::from_ref_time(1000));
|
||||
assert_eq!(info.weight, Weight::from_parts(1000, 0));
|
||||
assert_eq!(info.class, DispatchClass::Normal);
|
||||
assert_eq!(info.pays_fee, Pays::No);
|
||||
|
||||
// #[weight = (1000, DispatchClass::Operational, Pays::No)]
|
||||
let info = Call::<TraitImpl>::f03 {}.get_dispatch_info();
|
||||
assert_eq!(info.weight, Weight::from_ref_time(1000));
|
||||
assert_eq!(info.weight, Weight::from_parts(1000, 0));
|
||||
assert_eq!(info.class, DispatchClass::Operational);
|
||||
assert_eq!(info.pays_fee, Pays::No);
|
||||
|
||||
// #[weight = ((_a * 10 + _eb * 1) as Weight, DispatchClass::Normal, Pays::Yes)]
|
||||
let info = Call::<TraitImpl>::f11 { _a: 13, _eb: 20 }.get_dispatch_info();
|
||||
assert_eq!(info.weight, Weight::from_ref_time(150)); // 13*10 + 20
|
||||
assert_eq!(info.weight, Weight::from_parts(150, 0)); // 13*10 + 20
|
||||
assert_eq!(info.class, DispatchClass::Normal);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
|
||||
// #[weight = (0, DispatchClass::Operational, Pays::Yes)]
|
||||
let info = Call::<TraitImpl>::f12 { _a: 10, _eb: 20 }.get_dispatch_info();
|
||||
assert_eq!(info.weight, Weight::from_ref_time(0));
|
||||
assert_eq!(info.weight, Weight::from_parts(0, 0));
|
||||
assert_eq!(info.class, DispatchClass::Operational);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
|
||||
// #[weight = T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) + 10_000]
|
||||
let info = Call::<TraitImpl>::f20 {}.get_dispatch_info();
|
||||
assert_eq!(info.weight, Weight::from_ref_time(12300)); // 100*3 + 1000*2 + 10_1000
|
||||
assert_eq!(info.weight, Weight::from_parts(12300, 0)); // 100*3 + 1000*2 + 10_1000
|
||||
assert_eq!(info.class, DispatchClass::Normal);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
|
||||
// #[weight = T::DbWeight::get().reads_writes(6, 5) + 40_000]
|
||||
let info = Call::<TraitImpl>::f21 {}.get_dispatch_info();
|
||||
assert_eq!(info.weight, Weight::from_ref_time(45600)); // 100*6 + 1000*5 + 40_1000
|
||||
assert_eq!(info.weight, Weight::from_parts(45600, 0)); // 100*6 + 1000*5 + 40_1000
|
||||
assert_eq!(info.class, DispatchClass::Normal);
|
||||
assert_eq!(info.pays_fee, Pays::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extract_actual_weight_works() {
|
||||
let pre = DispatchInfo { weight: Weight::from_ref_time(1000), ..Default::default() };
|
||||
assert_eq!(extract_actual_weight(&Ok(Some(7).into()), &pre), Weight::from_ref_time(7));
|
||||
let pre = DispatchInfo { weight: Weight::from_parts(1000, 0), ..Default::default() };
|
||||
assert_eq!(extract_actual_weight(&Ok(Some(7).into()), &pre), Weight::from_parts(7, 0));
|
||||
assert_eq!(
|
||||
extract_actual_weight(&Ok(Some(1000).into()), &pre),
|
||||
Weight::from_ref_time(1000)
|
||||
Weight::from_parts(1000, 0)
|
||||
);
|
||||
assert_eq!(
|
||||
extract_actual_weight(
|
||||
&Err(DispatchError::BadOrigin.with_weight(Weight::from_ref_time(9))),
|
||||
&Err(DispatchError::BadOrigin.with_weight(Weight::from_parts(9, 0))),
|
||||
&pre
|
||||
),
|
||||
Weight::from_ref_time(9)
|
||||
Weight::from_parts(9, 0)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extract_actual_weight_caps_at_pre_weight() {
|
||||
let pre = DispatchInfo { weight: Weight::from_ref_time(1000), ..Default::default() };
|
||||
let pre = DispatchInfo { weight: Weight::from_parts(1000, 0), ..Default::default() };
|
||||
assert_eq!(
|
||||
extract_actual_weight(&Ok(Some(1250).into()), &pre),
|
||||
Weight::from_ref_time(1000)
|
||||
Weight::from_parts(1000, 0)
|
||||
);
|
||||
assert_eq!(
|
||||
extract_actual_weight(
|
||||
&Err(DispatchError::BadOrigin.with_weight(Weight::from_ref_time(1300))),
|
||||
&Err(DispatchError::BadOrigin.with_weight(Weight::from_parts(1300, 0))),
|
||||
&pre
|
||||
),
|
||||
Weight::from_ref_time(1000),
|
||||
Weight::from_parts(1000, 0),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extract_actual_pays_fee_works() {
|
||||
let pre = DispatchInfo { weight: Weight::from_ref_time(1000), ..Default::default() };
|
||||
let pre = DispatchInfo { weight: Weight::from_parts(1000, 0), ..Default::default() };
|
||||
assert_eq!(extract_actual_pays_fee(&Ok(Some(7).into()), &pre), Pays::Yes);
|
||||
assert_eq!(extract_actual_pays_fee(&Ok(Some(1000).into()), &pre), Pays::Yes);
|
||||
assert_eq!(extract_actual_pays_fee(&Ok((Some(1000), Pays::Yes).into()), &pre), Pays::Yes);
|
||||
assert_eq!(extract_actual_pays_fee(&Ok((Some(1000), Pays::No).into()), &pre), Pays::No);
|
||||
assert_eq!(
|
||||
extract_actual_pays_fee(
|
||||
&Err(DispatchError::BadOrigin.with_weight(Weight::from_ref_time(9))),
|
||||
&Err(DispatchError::BadOrigin.with_weight(Weight::from_parts(9, 0))),
|
||||
&pre
|
||||
),
|
||||
Pays::Yes
|
||||
@@ -3686,7 +3686,7 @@ mod weight_tests {
|
||||
);
|
||||
|
||||
let pre = DispatchInfo {
|
||||
weight: Weight::from_ref_time(1000),
|
||||
weight: Weight::from_parts(1000, 0),
|
||||
pays_fee: Pays::No,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -367,18 +367,18 @@ mod tests {
|
||||
|
||||
impl OnInitialize<u8> for Test {
|
||||
fn on_initialize(_n: u8) -> Weight {
|
||||
Weight::from_ref_time(10)
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
}
|
||||
impl OnRuntimeUpgrade for Test {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
Weight::from_ref_time(20)
|
||||
Weight::from_parts(20, 0)
|
||||
}
|
||||
}
|
||||
|
||||
TestExternalities::default().execute_with(|| {
|
||||
assert_eq!(<(Test, Test)>::on_initialize(0), Weight::from_ref_time(20));
|
||||
assert_eq!(<(Test, Test)>::on_runtime_upgrade(), Weight::from_ref_time(40));
|
||||
assert_eq!(<(Test, Test)>::on_initialize(0), Weight::from_parts(20, 0));
|
||||
assert_eq!(<(Test, Test)>::on_runtime_upgrade(), Weight::from_parts(40, 0));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ parameter_types! {
|
||||
/// 95th: 384_876
|
||||
/// 75th: 380_642
|
||||
pub const BlockExecutionWeight: Weight =
|
||||
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(381_015));
|
||||
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(381_015), 0);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -54,7 +54,7 @@ parameter_types! {
|
||||
/// 95th: 100_051
|
||||
/// 75th: 99_916
|
||||
pub const ExtrinsicBaseWeight: Weight =
|
||||
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(99_840));
|
||||
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(99_840), 0);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -508,7 +508,7 @@ fn call_weight_should_attach_to_call_enum() {
|
||||
assert_eq!(
|
||||
module3::Call::<Runtime>::operational {}.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
weight: Weight::from_ref_time(5),
|
||||
weight: Weight::from_parts(5, 0),
|
||||
class: DispatchClass::Operational,
|
||||
pays_fee: Pays::Yes
|
||||
},
|
||||
@@ -517,7 +517,7 @@ fn call_weight_should_attach_to_call_enum() {
|
||||
assert_eq!(
|
||||
module3::Call::<Runtime>::aux_4 {}.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
weight: Weight::from_ref_time(3),
|
||||
weight: Weight::from_parts(3, 0),
|
||||
class: DispatchClass::Normal,
|
||||
pays_fee: Pays::Yes
|
||||
},
|
||||
|
||||
@@ -171,7 +171,7 @@ pub mod pallet {
|
||||
let _ = T::AccountId::from(SomeType1); // Test for where clause
|
||||
let _ = T::AccountId::from(SomeType2); // Test for where clause
|
||||
Self::deposit_event(Event::Something(10));
|
||||
Weight::from_ref_time(10)
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
fn on_finalize(_: BlockNumberFor<T>) {
|
||||
let _ = T::AccountId::from(SomeType1); // Test for where clause
|
||||
@@ -182,7 +182,7 @@ pub mod pallet {
|
||||
let _ = T::AccountId::from(SomeType1); // Test for where clause
|
||||
let _ = T::AccountId::from(SomeType2); // Test for where clause
|
||||
Self::deposit_event(Event::Something(30));
|
||||
Weight::from_ref_time(30)
|
||||
Weight::from_parts(30, 0)
|
||||
}
|
||||
fn integrity_test() {
|
||||
let _ = T::AccountId::from(SomeType1); // Test for where clause
|
||||
@@ -197,7 +197,7 @@ pub mod pallet {
|
||||
{
|
||||
/// Doc comment put in metadata
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(Weight::from_ref_time(*_foo as u64))]
|
||||
#[pallet::weight(Weight::from_parts(*_foo as u64, 0))]
|
||||
pub fn foo(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] _foo: u32,
|
||||
@@ -715,7 +715,7 @@ fn call_expand() {
|
||||
assert_eq!(
|
||||
call_foo.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
weight: frame_support::weights::Weight::from_ref_time(3),
|
||||
weight: frame_support::weights::Weight::from_parts(3, 0),
|
||||
class: DispatchClass::Normal,
|
||||
pays_fee: Pays::Yes
|
||||
}
|
||||
@@ -1096,10 +1096,10 @@ fn pallet_hooks_expand() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
frame_system::Pallet::<Runtime>::set_block_number(1);
|
||||
|
||||
assert_eq!(AllPalletsWithoutSystem::on_initialize(1), Weight::from_ref_time(10));
|
||||
assert_eq!(AllPalletsWithoutSystem::on_initialize(1), Weight::from_parts(10, 0));
|
||||
AllPalletsWithoutSystem::on_finalize(1);
|
||||
|
||||
assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), Weight::from_ref_time(30));
|
||||
assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), Weight::from_parts(30, 0));
|
||||
|
||||
assert_eq!(
|
||||
frame_system::Pallet::<Runtime>::events()[0].event,
|
||||
@@ -1137,13 +1137,13 @@ fn all_pallets_type_reversed_order_is_correct() {
|
||||
{
|
||||
assert_eq!(
|
||||
AllPalletsWithoutSystemReversed::on_initialize(1),
|
||||
Weight::from_ref_time(10)
|
||||
Weight::from_parts(10, 0)
|
||||
);
|
||||
AllPalletsWithoutSystemReversed::on_finalize(1);
|
||||
|
||||
assert_eq!(
|
||||
AllPalletsWithoutSystemReversed::on_runtime_upgrade(),
|
||||
Weight::from_ref_time(30)
|
||||
Weight::from_parts(30, 0)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1219,7 +1219,7 @@ fn migrate_from_pallet_version_to_storage_version() {
|
||||
};
|
||||
|
||||
// `pallet_num` pallets, 2 writes and every write costs 5 weight.
|
||||
assert_eq!(Weight::from_ref_time(pallet_num * 2 * 5), weight);
|
||||
assert_eq!(Weight::from_parts(pallet_num * 2 * 5, 0), weight);
|
||||
|
||||
// All pallet versions should be removed
|
||||
assert!(sp_io::storage::get(&pallet_version_key(Example::name())).is_none());
|
||||
|
||||
@@ -85,7 +85,7 @@ mod pallet_old {
|
||||
|
||||
fn on_initialize(_n: T::BlockNumber) -> Weight {
|
||||
<Dummy<T>>::put(T::Balance::from(10));
|
||||
Weight::from_ref_time(10)
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn on_finalize(_n: T::BlockNumber) {
|
||||
@@ -131,7 +131,7 @@ pub mod pallet {
|
||||
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {
|
||||
fn on_initialize(_n: T::BlockNumber) -> Weight {
|
||||
<Dummy<T>>::put(T::Balance::from(10));
|
||||
Weight::from_ref_time(10)
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn on_finalize(_n: T::BlockNumber) {
|
||||
|
||||
@@ -72,7 +72,7 @@ mod pallet_old {
|
||||
|
||||
fn on_initialize(_n: T::BlockNumber) -> Weight {
|
||||
<Dummy<T, I>>::put(T::Balance::from(10));
|
||||
Weight::from_ref_time(10)
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn on_finalize(_n: T::BlockNumber) {
|
||||
@@ -117,7 +117,7 @@ pub mod pallet {
|
||||
impl<T: Config<I>, I: 'static> Hooks<T::BlockNumber> for Pallet<T, I> {
|
||||
fn on_initialize(_n: T::BlockNumber) -> Weight {
|
||||
<Dummy<T, I>>::put(T::Balance::from(10));
|
||||
Weight::from_ref_time(10)
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn on_finalize(_n: T::BlockNumber) {
|
||||
|
||||
@@ -54,10 +54,10 @@ pub mod pallet {
|
||||
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
|
||||
if TypeId::of::<I>() == TypeId::of::<()>() {
|
||||
Self::deposit_event(Event::Something(10));
|
||||
Weight::from_ref_time(10)
|
||||
Weight::from_parts(10, 0)
|
||||
} else {
|
||||
Self::deposit_event(Event::Something(11));
|
||||
Weight::from_ref_time(11)
|
||||
Weight::from_parts(11, 0)
|
||||
}
|
||||
}
|
||||
fn on_finalize(_: BlockNumberFor<T>) {
|
||||
@@ -70,10 +70,10 @@ pub mod pallet {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
if TypeId::of::<I>() == TypeId::of::<()>() {
|
||||
Self::deposit_event(Event::Something(30));
|
||||
Weight::from_ref_time(30)
|
||||
Weight::from_parts(30, 0)
|
||||
} else {
|
||||
Self::deposit_event(Event::Something(31));
|
||||
Weight::from_ref_time(31)
|
||||
Weight::from_parts(31, 0)
|
||||
}
|
||||
}
|
||||
fn integrity_test() {}
|
||||
@@ -83,7 +83,7 @@ pub mod pallet {
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
/// Doc comment put in metadata
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(Weight::from_ref_time(*_foo as u64))]
|
||||
#[pallet::weight(Weight::from_parts(*_foo as u64, 0))]
|
||||
pub fn foo(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] _foo: u32,
|
||||
@@ -356,7 +356,7 @@ fn call_expand() {
|
||||
assert_eq!(
|
||||
call_foo.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
weight: Weight::from_ref_time(3),
|
||||
weight: Weight::from_parts(3, 0),
|
||||
class: DispatchClass::Normal,
|
||||
pays_fee: Pays::Yes
|
||||
}
|
||||
@@ -368,7 +368,7 @@ fn call_expand() {
|
||||
assert_eq!(
|
||||
call_foo.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
weight: Weight::from_ref_time(3),
|
||||
weight: Weight::from_parts(3, 0),
|
||||
class: DispatchClass::Normal,
|
||||
pays_fee: Pays::Yes
|
||||
}
|
||||
@@ -649,10 +649,10 @@ fn pallet_hooks_expand() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
frame_system::Pallet::<Runtime>::set_block_number(1);
|
||||
|
||||
assert_eq!(AllPalletsWithoutSystem::on_initialize(1), Weight::from_ref_time(21));
|
||||
assert_eq!(AllPalletsWithoutSystem::on_initialize(1), Weight::from_parts(21, 0));
|
||||
AllPalletsWithoutSystem::on_finalize(1);
|
||||
|
||||
assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), Weight::from_ref_time(61));
|
||||
assert_eq!(AllPalletsWithoutSystem::on_runtime_upgrade(), Weight::from_parts(61, 0));
|
||||
|
||||
assert_eq!(
|
||||
frame_system::Pallet::<Runtime>::events()[0].event,
|
||||
|
||||
Reference in New Issue
Block a user