Skip to content

Commit

Permalink
Fix staking benchmark (#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:
#6025

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
gui1117 and actions-user authored Nov 14, 2024
1 parent bff395f commit a1af8ed
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 a1af8ed

Please sign in to comment.