git.delta.rocks / unique-network / refs/commits / 12cebb765284

difftreelog

feat(maintenance) new weight + benchmark

Fahrrader2023-02-21parent: #e7f049d.patch.diff
in: master

2 files changed

modifiedpallets/maintenance/src/benchmarking.rsdiffbeforeafterboth
18use crate::{Pallet as Maintenance, Config};18use crate::{Pallet as Maintenance, Config};
1919
20use frame_benchmarking::benchmarks;20use frame_benchmarking::benchmarks;
21use frame_system::RawOrigin;21use frame_system::{Call as RuntimeCall, RawOrigin};
22use frame_support::ensure;22use frame_support::{ensure, traits::StorePreimage};
23use codec::Encode;
24use sp_std::vec;
2325
24benchmarks! {26benchmarks! {
25 enable {27 enable {
35 ensure!(!<Enabled<T>>::get(), "didn't disable the MM");37 ensure!(!<Enabled<T>>::get(), "didn't disable the MM");
36 }38 }
39
40 execute_preimage {
41 let call_hash = RuntimeCall::<T>::set_storage { items: vec![] }.encode();
42 let hash = T::Preimages::note(call_hash.into())?;
43 }: _(RawOrigin::Root, hash)
44 verify {
45 }
37}46}
3847
modifiedpallets/maintenance/src/weights.rsdiffbeforeafterboth
35pub trait WeightInfo {35pub trait WeightInfo {
36 fn enable() -> Weight;36 fn enable() -> Weight;
37 fn disable() -> Weight;37 fn disable() -> Weight;
38 fn execute_preimage() -> Weight;
38}39}
3940
40/// Weights for pallet_maintenance using the Substrate node and recommended hardware.41/// Weights for pallet_maintenance using the Substrate node and recommended hardware.
50 Weight::from_ref_time(7_273_000)51 Weight::from_ref_time(7_273_000)
51 .saturating_add(T::DbWeight::get().writes(1))52 .saturating_add(T::DbWeight::get().writes(1))
52 }53 }
54 // Storage:
55 fn execute_preimage() -> Weight {
56 Weight::from_ref_time(7_273_000)
57 .saturating_add(T::DbWeight::get().reads(2))
58 .saturating_add(T::DbWeight::get().writes(1))
59 }
53}60}
5461
55// For backwards compatibility and tests62// For backwards compatibility and tests
64 Weight::from_ref_time(7_273_000)71 Weight::from_ref_time(7_273_000)
65 .saturating_add(RocksDbWeight::get().writes(1))72 .saturating_add(RocksDbWeight::get().writes(1))
66 }73 }
74 // Storage:
75 fn execute_preimage() -> Weight {
76 Weight::from_ref_time(7_273_000)
77 .saturating_add(RocksDbWeight::get().reads(2))
78 .saturating_add(RocksDbWeight::get().writes(1))
79 }
67}80}
6881