diff --git a/prdoc/pr_6463.prdoc b/prdoc/pr_6463.prdoc new file mode 100644 index 0000000000000000000000000000000000000000..9c4787540a4979d4c26d153db11abe304be8794d --- /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 96bd3860542fbd2355e0f8c70ecc384384e1e2ba..905f830f91d73967741f8196abfbd869358a747a 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::<T>::get(); + create_validators_with_nominators_for_era::<T>( + v, + n, + MaxNominationsOf::<T>::get() as usize, + false, + None, + )?; + + let targets; #[block] { - create_validators_with_nominators_for_era::<T>( - v, - n, - MaxNominationsOf::<T>::get() as usize, - false, - None, - )?; + // default bounds are unbounded. + targets = <Staking<T>>::get_npos_targets(DataProviderBounds::default()); } - // default bounds are unbounded. - let targets = <Staking<T>>::get_npos_targets(DataProviderBounds::default()); assert_eq!(targets.len() as u32, v); Ok(())