mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 11:41:02 +00:00
Contracts: Refactor API to use WeightMeter (#2943)
Update the Contracts API to use `WeightMeter`, as it simplifies the code and makes it easier to reason about, rather than taking a mutable weight or returning a tuple with the weight consumed --------- Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -40,7 +40,7 @@ use frame_support::{
|
||||
self,
|
||||
pallet_prelude::StorageVersion,
|
||||
traits::{fungible::InspectHold, Currency},
|
||||
weights::Weight,
|
||||
weights::{Weight, WeightMeter},
|
||||
};
|
||||
use frame_system::RawOrigin;
|
||||
use pallet_balances;
|
||||
@@ -198,7 +198,7 @@ mod benchmarks {
|
||||
fn on_process_deletion_queue_batch() {
|
||||
#[block]
|
||||
{
|
||||
ContractInfo::<T>::process_deletion_queue_batch(Weight::MAX);
|
||||
ContractInfo::<T>::process_deletion_queue_batch(&mut WeightMeter::new())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
ContractInfo::<T>::process_deletion_queue_batch(Weight::MAX);
|
||||
ContractInfo::<T>::process_deletion_queue_batch(&mut WeightMeter::new())
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -226,7 +226,7 @@ mod benchmarks {
|
||||
let mut m = v09::Migration::<T>::default();
|
||||
#[block]
|
||||
{
|
||||
m.step();
|
||||
m.step(&mut WeightMeter::new());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
m.step();
|
||||
m.step(&mut WeightMeter::new());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -259,7 +259,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
m.step();
|
||||
m.step(&mut WeightMeter::new());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
m.step();
|
||||
m.step(&mut WeightMeter::new());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
m.step();
|
||||
m.step(&mut WeightMeter::new());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -307,7 +307,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
m.step();
|
||||
m.step(&mut WeightMeter::new());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
m.step();
|
||||
m.step(&mut WeightMeter::new());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -335,7 +335,7 @@ mod benchmarks {
|
||||
StorageVersion::new(version).put::<Pallet<T>>();
|
||||
#[block]
|
||||
{
|
||||
Migration::<T>::migrate(Weight::MAX);
|
||||
Migration::<T>::migrate(&mut WeightMeter::new());
|
||||
}
|
||||
assert_eq!(StorageVersion::get::<Pallet<T>>(), version);
|
||||
}
|
||||
@@ -2776,7 +2776,8 @@ mod benchmarks {
|
||||
#[benchmark(extra, pov_mode = Ignored)]
|
||||
fn print_schedule() -> Result<(), BenchmarkError> {
|
||||
let max_weight = <T as frame_system::Config>::BlockWeights::get().max_block;
|
||||
let (weight_per_key, key_budget) = ContractInfo::<T>::deletion_budget(max_weight);
|
||||
let (weight_per_key, key_budget) =
|
||||
ContractInfo::<T>::deletion_budget(&mut WeightMeter::with_limit(max_weight));
|
||||
let schedule = T::Schedule::get();
|
||||
log::info!(target: LOG_TARGET, "
|
||||
{schedule:#?}
|
||||
|
||||
Reference in New Issue
Block a user