Skip to content

Commit

Permalink
Migrating cumulus-pallet-session-benchmarking to Benchmarking V2 (par…
Browse files Browse the repository at this point in the history
…itytech#6564)

# Description

Migrating cumulus-pallet-session-benchmarking to the new benchmarking
syntax v2.
This is a part of paritytech#6202

---------

Co-authored-by: seemantaggarwal <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2025
1 parent 2d53238 commit 57f0b95
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions cumulus/pallets/session-benchmarking/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,49 @@
// limitations under the License.

//! Benchmarking setup for pallet-session.
#![cfg(feature = "runtime-benchmarks")]

use alloc::{vec, vec::Vec};

use codec::Decode;
use frame_benchmarking::{benchmarks, whitelisted_caller};
use frame_benchmarking::v2::*;
use frame_system::RawOrigin;
use pallet_session::*;
pub struct Pallet<T: Config>(pallet_session::Pallet<T>);
pub trait Config: pallet_session::Config {}

benchmarks! {
set_keys {
#[benchmarks]
mod benchmarks {
use super::*;

#[benchmark]
fn set_keys() -> Result<(), BenchmarkError> {
let caller: T::AccountId = whitelisted_caller();
frame_system::Pallet::<T>::inc_providers(&caller);
let keys = T::Keys::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()).unwrap();
let proof: Vec<u8> = vec![0,1,2,3];
}: _(RawOrigin::Signed(caller), keys, proof)
let proof: Vec<u8> = vec![0, 1, 2, 3];

#[extrinsic_call]
_(RawOrigin::Signed(caller), keys, proof);

Ok(())
}

purge_keys {
#[benchmark]
fn purge_keys() -> Result<(), BenchmarkError> {
let caller: T::AccountId = whitelisted_caller();
frame_system::Pallet::<T>::inc_providers(&caller);
let keys = T::Keys::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()).unwrap();
let proof: Vec<u8> = vec![0,1,2,3];
let _t = pallet_session::Pallet::<T>::set_keys(RawOrigin::Signed(caller.clone()).into(), keys, proof);
}: _(RawOrigin::Signed(caller))
let proof: Vec<u8> = vec![0, 1, 2, 3];
let _t = pallet_session::Pallet::<T>::set_keys(
RawOrigin::Signed(caller.clone()).into(),
keys,
proof,
);

#[extrinsic_call]
_(RawOrigin::Signed(caller));

Ok(())
}
}

0 comments on commit 57f0b95

Please sign in to comment.