Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate pallet-remarks to v2 bench syntax #6291

Merged
merged 9 commits into from
Nov 5, 2024
9 changes: 9 additions & 0 deletions prdoc/pr_6291.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: migrate pallet-remarks to v2 bench syntax
doc:
- audience: Runtime Dev
description: |-
Part of:
* #6202
crates:
- name: pallet-remark
bump: patch
17 changes: 11 additions & 6 deletions substrate/frame/remark/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use super::*;
use alloc::vec;
use frame_benchmarking::v1::{benchmarks, whitelisted_caller};
use frame_benchmarking::v2::{*};
re-gius marked this conversation as resolved.
Show resolved Hide resolved
use frame_system::{EventRecord, Pallet as System, RawOrigin};

#[cfg(test)]
Expand All @@ -34,12 +34,17 @@ fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
assert_eq!(event, &system_event);
}

benchmarks! {
store {
let l in 1 .. 1024*1024;
#[benchmarks]
mod benchmarks {
use super::*;

#[benchmark]
fn store(l: Linear<1, { 1024*1024 }>) {
let caller: T::AccountId = whitelisted_caller();
}: _(RawOrigin::Signed(caller.clone()), vec![0u8; l as usize])
verify {

#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), vec![0u8; l as usize]);

assert_last_event::<T>(Event::Stored { sender: caller, content_hash: sp_io::hashing::blake2_256(&vec![0u8; l as usize]).into() }.into());
}

Expand Down