--- a/pallets/maintenance/src/benchmarking.rs +++ b/pallets/maintenance/src/benchmarking.rs @@ -18,8 +18,10 @@ use crate::{Pallet as Maintenance, Config}; use frame_benchmarking::benchmarks; -use frame_system::RawOrigin; -use frame_support::ensure; +use frame_system::{Call as RuntimeCall, RawOrigin}; +use frame_support::{ensure, traits::StorePreimage}; +use codec::Encode; +use sp_std::vec; benchmarks! { enable { @@ -34,4 +36,11 @@ verify { ensure!(!>::get(), "didn't disable the MM"); } + + execute_preimage { + let call_hash = RuntimeCall::::set_storage { items: vec![] }.encode(); + let hash = T::Preimages::note(call_hash.into())?; + }: _(RawOrigin::Root, hash) + verify { + } } --- a/pallets/maintenance/src/weights.rs +++ b/pallets/maintenance/src/weights.rs @@ -35,6 +35,7 @@ pub trait WeightInfo { fn enable() -> Weight; fn disable() -> Weight; + fn execute_preimage() -> Weight; } /// Weights for pallet_maintenance using the Substrate node and recommended hardware. @@ -50,6 +51,12 @@ Weight::from_ref_time(7_273_000) .saturating_add(T::DbWeight::get().writes(1)) } + // Storage: + fn execute_preimage() -> Weight { + Weight::from_ref_time(7_273_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } } // For backwards compatibility and tests @@ -64,4 +71,10 @@ Weight::from_ref_time(7_273_000) .saturating_add(RocksDbWeight::get().writes(1)) } + // Storage: + fn execute_preimage() -> Weight { + Weight::from_ref_time(7_273_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) + } }