Benchmark pallet sudo (#13880)

* set_key

* v2

* update runtime

* cargo fmt

* remove commenting

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_sudo

* impl weights

* sudo & sudo_as

* where

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_sudo

* update weights

* cargo fmt

* Update Cargo.lock

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 <>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Doordashcon
2023-05-11 14:28:46 +01:00
committed by GitHub
parent f36749b99e
commit 4795c29e9c
10 changed files with 240 additions and 5 deletions
+14 -5
View File
@@ -110,6 +110,11 @@ mod mock;
#[cfg(test)]
mod tests;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
pub mod weights;
pub use weights::WeightInfo;
pub use extension::CheckOnlySudoAccount;
pub use pallet::*;
@@ -130,6 +135,9 @@ pub mod pallet {
type RuntimeCall: Parameter
+ UnfilteredDispatchable<RuntimeOrigin = Self::RuntimeOrigin>
+ GetDispatchInfo;
/// Type representing the weight of this pallet
type WeightInfo: WeightInfo;
}
#[pallet::pallet]
@@ -146,7 +154,10 @@ pub mod pallet {
#[pallet::call_index(0)]
#[pallet::weight({
let dispatch_info = call.get_dispatch_info();
(dispatch_info.weight, dispatch_info.class)
(
T::WeightInfo::sudo().saturating_add(dispatch_info.weight),
dispatch_info.class
)
})]
pub fn sudo(
origin: OriginFor<T>,
@@ -195,7 +206,7 @@ pub mod pallet {
/// ## Complexity
/// - O(1).
#[pallet::call_index(2)]
#[pallet::weight({0})] // FIXME
#[pallet::weight(T::WeightInfo::set_key())]
pub fn set_key(
origin: OriginFor<T>,
new: AccountIdLookupOf<T>,
@@ -222,9 +233,7 @@ pub mod pallet {
#[pallet::weight({
let dispatch_info = call.get_dispatch_info();
(
dispatch_info.weight
// AccountData for inner call origin accountdata.
.saturating_add(T::DbWeight::get().reads_writes(1, 1)),
T::WeightInfo::sudo_as().saturating_add(dispatch_info.weight),
dispatch_info.class,
)
})]