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]>
(cherry picked from commit a1af8ed)
  • Loading branch information
gui1117 committed Nov 14, 2024
1 parent 65ee808 commit 4500201
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 4500201

Please sign in to comment.