Skip to content

Commit

Permalink
Fix staking benchmark (paritytech#6463)
Browse files Browse the repository at this point in the history
Found by @ggwpez 

Fix staking benchmark, error was introduced when migrating to v2:
paritytech#6025

---------

Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
2 people authored and dudo50 committed Jan 4, 2025
1 parent 34807f8 commit 3b8f275
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
8 changes: 8 additions & 0 deletions prdoc/pr_6463.prdoc
Original file line number Diff line number Diff line change
@@ -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
20 changes: 11 additions & 9 deletions substrate/frame/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down

0 comments on commit 3b8f275

Please sign in to comment.