Skip to content

Commit 8f68ad1

Browse files
paritytech-release-backport-bot[bot]karolk91github-actions[bot]
authored
[stable2506] Backport #9354 (#9375)
Backport #9354 into `stable2506` from karolk91. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: Karol Kokoszka <[email protected]> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1e4e953 commit 8f68ad1

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

prdoc/pr_9354.prdoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: Remove whitespaces added by macros due to token re-parsing
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
Normalize result of `stringify` in scenarios when used inside nested macros to stringify token streams for benchmarking framework
6+
crates:
7+
- name: frame-benchmarking
8+
bump: patch

substrate/frame/benchmarking/src/v1.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,8 +1818,8 @@ pub fn show_benchmark_debug_info(
18181818
#[macro_export]
18191819
macro_rules! add_benchmark {
18201820
( $params:ident, $batches:ident, $name:path, $location:ty ) => {
1821-
let name_string = stringify!($name).as_bytes();
1822-
let instance_string = stringify!($location).as_bytes();
1821+
let pallet_string = stringify!($name).replace(" ", "").into_bytes();
1822+
let instance_string = stringify!($location).replace(" ", "").into_bytes();
18231823
let (config, whitelist) = $params;
18241824
let $crate::BenchmarkConfig {
18251825
pallet,
@@ -1829,7 +1829,7 @@ macro_rules! add_benchmark {
18291829
verify,
18301830
internal_repeats,
18311831
} = config;
1832-
if &pallet[..] == &name_string[..] && &instance[..] == &instance_string[..] {
1832+
if &pallet[..] == &pallet_string[..] && &instance[..] == &instance_string[..] {
18331833
let benchmark_result = <$location as $crate::Benchmarking>::run_benchmark(
18341834
&benchmark[..],
18351835
&selected_components[..],
@@ -1852,7 +1852,7 @@ macro_rules! add_benchmark {
18521852
},
18531853
Err($crate::BenchmarkError::Stop(e)) => {
18541854
$crate::show_benchmark_debug_info(
1855-
instance_string,
1855+
&instance_string,
18561856
benchmark,
18571857
selected_components,
18581858
verify,
@@ -1883,8 +1883,8 @@ macro_rules! add_benchmark {
18831883

18841884
if let Some(final_results) = final_results {
18851885
$batches.push($crate::BenchmarkBatch {
1886-
pallet: name_string.to_vec(),
1887-
instance: instance_string.to_vec(),
1886+
pallet: pallet_string,
1887+
instance: instance_string,
18881888
benchmark: benchmark.clone(),
18891889
results: final_results,
18901890
});
@@ -1915,12 +1915,12 @@ macro_rules! add_benchmark {
19151915
#[macro_export]
19161916
macro_rules! list_benchmark {
19171917
( $list:ident, $extra:ident, $name:path, $location:ty ) => {
1918-
let pallet_string = stringify!($name).as_bytes();
1919-
let instance_string = stringify!($location).as_bytes();
1918+
let pallet_string = stringify!($name).replace(" ", "").into_bytes();
1919+
let instance_string = stringify!($location).replace(" ", "").into_bytes();
19201920
let benchmarks = <$location as $crate::Benchmarking>::benchmarks($extra);
19211921
let pallet_benchmarks = $crate::BenchmarkList {
1922-
pallet: pallet_string.to_vec(),
1923-
instance: instance_string.to_vec(),
1922+
pallet: pallet_string,
1923+
instance: instance_string,
19241924
benchmarks: benchmarks.to_vec(),
19251925
};
19261926
$list.push(pallet_benchmarks)

0 commit comments

Comments
 (0)