From 72c07dfcfd42b3e938cd2f161bfd176db4dcec8b Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Wed, 30 Oct 2024 15:15:13 +0100 Subject: [PATCH 1/4] migrate pallet-remarks benchmarks to v2 --- substrate/frame/remark/src/benchmarking.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/substrate/frame/remark/src/benchmarking.rs b/substrate/frame/remark/src/benchmarking.rs index 15b72b4748dd..83c5c68693e2 100644 --- a/substrate/frame/remark/src/benchmarking.rs +++ b/substrate/frame/remark/src/benchmarking.rs @@ -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)] @@ -34,12 +34,17 @@ fn assert_last_event(generic_event: ::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::(Event::Stored { sender: caller, content_hash: sp_io::hashing::blake2_256(&vec![0u8; l as usize]).into() }.into()); } From 921336fa0949507c0d713b52f85b11e44c9d6a78 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 30 Oct 2024 19:12:27 +0000 Subject: [PATCH 2/4] Update from ggwpez running command 'prdoc --bump patch --audience runtime_dev' --- prdoc/pr_6291.prdoc | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 prdoc/pr_6291.prdoc diff --git a/prdoc/pr_6291.prdoc b/prdoc/pr_6291.prdoc new file mode 100644 index 000000000000..73053c9d47bd --- /dev/null +++ b/prdoc/pr_6291.prdoc @@ -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 From b3a598f603fbe58ee15581472c5e4a9e1612a698 Mon Sep 17 00:00:00 2001 From: Giuseppe Re Date: Mon, 4 Nov 2024 18:38:38 +0100 Subject: [PATCH 3/4] Update substrate/frame/remark/src/benchmarking.rs --- substrate/frame/remark/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/remark/src/benchmarking.rs b/substrate/frame/remark/src/benchmarking.rs index 83c5c68693e2..cdc3dcd9fb93 100644 --- a/substrate/frame/remark/src/benchmarking.rs +++ b/substrate/frame/remark/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; use alloc::vec; -use frame_benchmarking::v2::{*}; +use frame_benchmarking::v2::*; use frame_system::{EventRecord, Pallet as System, RawOrigin}; #[cfg(test)] From 5ecbc01ebe58d6a1009d9e83ee1aa87bbae90b3b Mon Sep 17 00:00:00 2001 From: Giuseppe Re Date: Mon, 4 Nov 2024 19:30:00 +0100 Subject: [PATCH 4/4] fmt --- substrate/frame/remark/src/benchmarking.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/substrate/frame/remark/src/benchmarking.rs b/substrate/frame/remark/src/benchmarking.rs index cdc3dcd9fb93..41d49c3b930b 100644 --- a/substrate/frame/remark/src/benchmarking.rs +++ b/substrate/frame/remark/src/benchmarking.rs @@ -39,13 +39,19 @@ mod benchmarks { use super::*; #[benchmark] - fn store(l: Linear<1, { 1024*1024 }>) { + fn store(l: Linear<1, { 1024 * 1024 }>) { let caller: T::AccountId = whitelisted_caller(); #[extrinsic_call] _(RawOrigin::Signed(caller.clone()), vec![0u8; l as usize]); - assert_last_event::(Event::Stored { sender: caller, content_hash: sp_io::hashing::blake2_256(&vec![0u8; l as usize]).into() }.into()); + assert_last_event::( + 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);