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
+12 -12
View File
@@ -718,12 +718,12 @@ mod tests {
// one with block number arg and one without
fn on_initialize(n: T::BlockNumber) -> Weight {
println!("on_initialize({})", n);
Weight::from_ref_time(175)
Weight::from_parts(175, 0)
}
fn on_idle(n: T::BlockNumber, remaining_weight: Weight) -> Weight {
println!("on_idle{}, {})", n, remaining_weight);
Weight::from_ref_time(175)
Weight::from_parts(175, 0)
}
fn on_finalize(n: T::BlockNumber) {
@@ -732,7 +732,7 @@ mod tests {
fn on_runtime_upgrade() -> Weight {
sp_io::storage::set(super::TEST_KEY, "module".as_bytes());
Weight::from_ref_time(200)
Weight::from_parts(200, 0)
}
fn offchain_worker(n: T::BlockNumber) {
@@ -853,9 +853,9 @@ mod tests {
parameter_types! {
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::builder()
.base_block(Weight::from_ref_time(10))
.for_class(DispatchClass::all(), |weights| weights.base_extrinsic = Weight::from_ref_time(5))
.for_class(DispatchClass::non_mandatory(), |weights| weights.max_total = Weight::from_ref_time(1024).set_proof_size(u64::MAX).into())
.base_block(Weight::from_parts(10, 0))
.for_class(DispatchClass::all(), |weights| weights.base_extrinsic = Weight::from_parts(5, 0))
.for_class(DispatchClass::non_mandatory(), |weights| weights.max_total = Weight::from_parts(1024, u64::MAX).into())
.build_or_panic();
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 10,
@@ -946,7 +946,7 @@ mod tests {
sp_io::storage::set(TEST_KEY, "custom_upgrade".as_bytes());
sp_io::storage::set(CUSTOM_ON_RUNTIME_KEY, &true.encode());
System::deposit_event(frame_system::Event::CodeUpdated);
Weight::from_ref_time(100)
Weight::from_parts(100, 0)
}
}
@@ -1124,7 +1124,7 @@ mod tests {
let encoded_len = encoded.len() as u64;
// on_initialize weight + base block execution weight
let block_weights = <Runtime as frame_system::Config>::BlockWeights::get();
let base_block_weight = Weight::from_ref_time(175) + block_weights.base_block;
let base_block_weight = Weight::from_parts(175, 0) + block_weights.base_block;
let limit = block_weights.get(DispatchClass::Normal).max_total.unwrap() - base_block_weight;
let num_to_exhaust_block = limit.ref_time() / (encoded_len + 5);
t.execute_with(|| {
@@ -1149,7 +1149,7 @@ mod tests {
assert_eq!(
<frame_system::Pallet<Runtime>>::block_weight().total(),
//--------------------- on_initialize + block_execution + extrinsic_base weight
Weight::from_ref_time((encoded_len + 5) * (nonce + 1)) + base_block_weight,
Weight::from_parts((encoded_len + 5) * (nonce + 1), 0) + base_block_weight,
);
assert_eq!(
<frame_system::Pallet<Runtime>>::extrinsic_index(),
@@ -1180,7 +1180,7 @@ mod tests {
let mut t = new_test_ext(1);
t.execute_with(|| {
// Block execution weight + on_initialize weight from custom module
let base_block_weight = Weight::from_ref_time(175) +
let base_block_weight = Weight::from_parts(175, 0) +
<Runtime as frame_system::Config>::BlockWeights::get().base_block;
Executive::initialize_block(&Header::new(
@@ -1199,7 +1199,7 @@ mod tests {
assert!(Executive::apply_extrinsic(x2.clone()).unwrap().is_ok());
// default weight for `TestXt` == encoded length.
let extrinsic_weight = Weight::from_ref_time(len as u64) +
let extrinsic_weight = Weight::from_parts(len as u64, 0) +
<Runtime as frame_system::Config>::BlockWeights::get()
.get(DispatchClass::Normal)
.base_extrinsic;
@@ -1315,7 +1315,7 @@ mod tests {
// the `on_initialize` weight defined in the custom test module.
assert_eq!(
<frame_system::Pallet<Runtime>>::block_weight().total(),
Weight::from_ref_time(175 + 175 + 10)
Weight::from_parts(175 + 175 + 10, 0)
);
})
}