Skip to content

Commit

Permalink
migrate pallet-remarks to v2 bench syntax (#6291)
Browse files Browse the repository at this point in the history
Part of:
* #6202

---------

Co-authored-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: Giuseppe Re <[email protected]>
  • Loading branch information
4 people authored Nov 5, 2024
1 parent ec61396 commit 3c6ea86
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
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
25 changes: 18 additions & 7 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::*;
use frame_system::{EventRecord, Pallet as System, RawOrigin};

#[cfg(test)]
Expand All @@ -34,13 +34,24 @@ 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 {
assert_last_event::<T>(Event::Stored { sender: caller, content_hash: sp_io::hashing::blake2_256(&vec![0u8; l as usize]).into() }.into());

#[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(),
);
}

impl_benchmark_test_suite!(Remark, crate::mock::new_test_ext(), crate::mock::Test);
Expand Down

0 comments on commit 3c6ea86

Please sign in to comment.