From 3dcd7d560ec3f69e88baefe6b767b93e270204fd Mon Sep 17 00:00:00 2001 From: Guillaume Thiolliere Date: Thu, 14 Nov 2024 11:27:00 +0900 Subject: [PATCH 1/2] Fix staking benchmark (#6463) Found by @ggwpez Fix staking benchmark, error was introduced when migrating to v2: https://github.com/paritytech/polkadot-sdk/pull/6025 --------- Co-authored-by: GitHub Action (cherry picked from commit a1af8ed63668fc4a553776e381a12d165e7462f8) --- prdoc/pr_6463.prdoc | 8 ++++++++ substrate/frame/staking/src/benchmarking.rs | 20 +++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 prdoc/pr_6463.prdoc diff --git a/prdoc/pr_6463.prdoc b/prdoc/pr_6463.prdoc new file mode 100644 index 000000000000..9c4787540a49 --- /dev/null +++ b/prdoc/pr_6463.prdoc @@ -0,0 +1,8 @@ +title: Fix staking benchmark +doc: +- audience: Runtime Dev + description: 'Fix staking benchmark, error was introduced when migrating to v2: + https://github.com/paritytech/polkadot-sdk/pull/6025' +crates: +- name: pallet-staking + bump: patch diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 96bd3860542f..905f830f91d7 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -975,20 +975,22 @@ mod benchmarks { ) -> Result<(), BenchmarkError> { // number of nominator intention. let n = MaxNominators::::get(); + create_validators_with_nominators_for_era::( + v, + n, + MaxNominationsOf::::get() as usize, + false, + None, + )?; + + let targets; #[block] { - create_validators_with_nominators_for_era::( - v, - n, - MaxNominationsOf::::get() as usize, - false, - None, - )?; + // default bounds are unbounded. + targets = >::get_npos_targets(DataProviderBounds::default()); } - // default bounds are unbounded. - let targets = >::get_npos_targets(DataProviderBounds::default()); assert_eq!(targets.len() as u32, v); Ok(()) From 090676f32bf9b571357cf4098c0428df9d08d593 Mon Sep 17 00:00:00 2001 From: gui Date: Thu, 14 Nov 2024 12:52:16 +0900 Subject: [PATCH 2/2] prdoc --- prdoc/{pr_6463.prdoc => pr_6475.prdoc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename prdoc/{pr_6463.prdoc => pr_6475.prdoc} (100%) diff --git a/prdoc/pr_6463.prdoc b/prdoc/pr_6475.prdoc similarity index 100% rename from prdoc/pr_6463.prdoc rename to prdoc/pr_6475.prdoc