Skip to content

Commit

Permalink
Authority benchmark new methods (#1411)
Browse files Browse the repository at this point in the history
* add benchmarks for new methods

* update orml commit

* update orml

* sweep_dust benchmark

* add weight method

* add missing authority weights

* fix weights

* update bench

* cargo run --release --color=never --bin=acala --features=runtime-benchmarks --features=with-mandala-runtime -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_authority --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --template=./templates/runtime-weight-template.hbs --output=./runtime/mandala/src/weights/

* update bench

* cargo run --release --color=never --bin=acala --features=runtime-benchmarks --features=with-mandala-runtime -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_authority --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --template=./templates/runtime-weight-template.hbs --output=./runtime/mandala/src/weights/

* cargo run --release --color=never --bin=acala --features=runtime-benchmarks --features=with-karura-runtime -- benchmark --chain=karura-dev --steps=50 --repeat=20 --pallet=orml_authority --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --template=./templates/runtime-weight-template.hbs --output=./runtime/karura/src/weights/

* fix

Co-authored-by: Acala Benchmarking Bot <[email protected]>
Co-authored-by: Bryan Chen <[email protected]>
  • Loading branch information
3 people authored Sep 15, 2021
1 parent ffcce3d commit ad5f551
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 21 deletions.
16 changes: 8 additions & 8 deletions runtime/karura/src/weights/orml_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! Autogenerated weights for orml_authority
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2021-09-15, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("karura-dev"), DB CACHE: 128

// Executed Command:
Expand All @@ -28,7 +28,7 @@
// --chain=karura-dev
// --steps=50
// --repeat=20
// --pallet=*
// --pallet=orml_authority
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
Expand All @@ -48,30 +48,30 @@ use sp_std::marker::PhantomData;
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> orml_authority::WeightInfo for WeightInfo<T> {
fn dispatch_as() -> Weight {
(21_199_000 as Weight)
(20_621_000 as Weight)
}
fn schedule_dispatch_without_delay() -> Weight {
(55_898_000 as Weight)
(54_460_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn schedule_dispatch_with_delay() -> Weight {
(59_215_000 as Weight)
(57_119_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn fast_track_scheduled_dispatch() -> Weight {
(74_569_000 as Weight)
(73_397_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn delay_scheduled_dispatch() -> Weight {
(74_564_000 as Weight)
(72_988_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn cancel_scheduled_dispatch() -> Weight {
(51_614_000 as Weight)
(50_467_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
Expand Down
45 changes: 41 additions & 4 deletions runtime/mandala/src/benchmarking/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::{Authority, AuthoritysOriginId, BlockNumber, Call, Origin, Runtime, System};
use crate::{AccountId, Authority, AuthoritysOriginId, BlockNumber, Call, Origin, Runtime, System};

use sp_runtime::Perbill;
use sp_runtime::{traits::Hash, Perbill};
use sp_std::prelude::*;

use frame_support::traits::{schedule::DispatchTime, OriginTrait};
use frame_support::{
traits::{schedule::DispatchTime, OriginTrait},
weights::GetDispatchInfo,
};
use frame_system::RawOrigin;
use orml_benchmarking::runtime_benchmarks;
use orml_benchmarking::{runtime_benchmarks, whitelisted_caller};

runtime_benchmarks! {
{ Runtime, orml_authority }
Expand Down Expand Up @@ -135,6 +138,40 @@ runtime_benchmarks! {

let pallets_origin = schedule_origin.caller().clone();
}: _(RawOrigin::Root, Box::new(pallets_origin), 0)

// authorize a call that can be triggered later
authorize_call {
let caller: AccountId = whitelisted_caller();
let call = Call::System(frame_system::Call::fill_block(Perbill::from_percent(1)));
let hash = <Runtime as frame_system::Config>::Hashing::hash_of(&call);
System::set_block_number(1u32);
}: _(RawOrigin::Root, Box::new(call.clone()), Some(caller.clone()))
verify {
assert_eq!(Authority::saved_calls(&hash), Some((call, Some(caller))));
}

remove_authorized_call {
let caller: AccountId = whitelisted_caller();
let call = Call::System(frame_system::Call::fill_block(Perbill::from_percent(1)));
let hash = <Runtime as frame_system::Config>::Hashing::hash_of(&call);
System::set_block_number(1u32);
Authority::authorize_call(Origin::root(), Box::new(call.clone()), Some(caller.clone()))?;
}: _(RawOrigin::Signed(caller), hash)
verify {
assert_eq!(Authority::saved_calls(&hash), None);
}

trigger_call {
let caller: AccountId = whitelisted_caller();
let call = Call::System(frame_system::Call::fill_block(Perbill::from_percent(1)));
let hash = <Runtime as frame_system::Config>::Hashing::hash_of(&call);
let call_weight_bound = call.get_dispatch_info().weight;
System::set_block_number(1u32);
Authority::authorize_call(Origin::root(), Box::new(call.clone()), Some(caller.clone()))?;
}: _(RawOrigin::Signed(caller), hash, call_weight_bound)
verify {
assert_eq!(Authority::saved_calls(&hash), None);
}
}

#[cfg(test)]
Expand Down
18 changes: 9 additions & 9 deletions runtime/mandala/src/weights/orml_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

//! Autogenerated weights for orml_authority
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-09-15, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128

// Executed Command:
Expand All @@ -28,7 +28,7 @@
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=*
// --pallet=orml_authority
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
Expand All @@ -48,30 +48,30 @@ use sp_std::marker::PhantomData;
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> orml_authority::WeightInfo for WeightInfo<T> {
fn dispatch_as() -> Weight {
(29_595_000 as Weight)
(20_989_000 as Weight)
}
fn schedule_dispatch_without_delay() -> Weight {
(71_028_000 as Weight)
(55_153_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn schedule_dispatch_with_delay() -> Weight {
(75_115_000 as Weight)
(57_754_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn fast_track_scheduled_dispatch() -> Weight {
(111_745_000 as Weight)
(74_949_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn delay_scheduled_dispatch() -> Weight {
(111_217_000 as Weight)
(74_280_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn cancel_scheduled_dispatch() -> Weight {
(80_254_000 as Weight)
(51_250_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
Expand Down

0 comments on commit ad5f551

Please sign in to comment.