Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Allow 24 nominations per validator and publish count #7929

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frame/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,10 @@ benchmarks! {
Some(w),
)?;

// needed for the solution to be generates.
// needed for the solution to be generated.
assert!(<Staking<T>>::create_stakers_snapshot().0);

// set number of winners
// set number of winners.
ValidatorCount::put(w);

// create a assignments in total for the w winners.
Expand Down
7 changes: 5 additions & 2 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ pub type EraIndex = u32;
/// Counter for the number of "reward" points earned by a given validator.
pub type RewardPoint = u32;

// Note: Maximum nomination limit is set here -- 16.
// Note: Maximum nomination limit is set here -- 24.
generate_solution_type!(
#[compact]
pub struct CompactAssignments::<NominatorIndex, ValidatorIndex, OffchainAccuracy>(16)
pub struct CompactAssignments::<NominatorIndex, ValidatorIndex, OffchainAccuracy>(24)
);

/// Accuracy used for on-chain election.
Expand Down Expand Up @@ -1266,6 +1266,9 @@ decl_module! {
/// their reward. This used to limit the i/o cost for the nominator payout.
const MaxNominatorRewardedPerValidator: u32 = T::MaxNominatorRewardedPerValidator::get();

/// The maximum of validator candidates each nominator may nominate.
const MaxNominations: u32 = MAX_NOMINATIONS as u32;

type Error = Error<T>;

fn deposit_event() = default;
Expand Down
14 changes: 7 additions & 7 deletions frame/staking/src/testing_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ pub fn create_validators<T: Config>(
/// we are working with a clean state.
///
/// Parameters:
/// - `validators`: number of bonded validators
/// - `validators`: number of bonded validators.
/// - `nominators`: number of bonded nominators.
/// - `edge_per_nominator`: number of edge (vote) per nominator.
/// - `edges_per_nominator`: number of edges (votes) per nominator.
/// - `randomize_stake`: whether to randomize the stakes.
/// - `to_nominate`: if `Some(n)`, only the first `n` bonded validator are voted upon.
/// Else, all of them are considered and `edge_per_nominator` random validators are voted for.
/// Else, all of them are considered and `edges_per_nominator` random validators are voted for.
///
/// Return the validators choosen to be nominated.
/// Return the validators chosen to be nominated.
pub fn create_validators_with_nominators_for_era<T: Config>(
validators: u32,
nominators: u32,
edge_per_nominator: usize,
edges_per_nominator: usize,
randomize_stake: bool,
to_nominate: Option<u32>,
) -> Result<Vec<<T::Lookup as StaticLookup>::Source>, &'static str> {
Expand Down Expand Up @@ -155,9 +155,9 @@ pub fn create_validators_with_nominators_for_era<T: Config>(
// Have them randomly validate
let mut available_validators = validator_choosen.clone();
let mut selected_validators: Vec<<T::Lookup as StaticLookup>::Source> =
Vec::with_capacity(edge_per_nominator);
Vec::with_capacity(edges_per_nominator);

for _ in 0 .. validators.min(edge_per_nominator as u32) {
for _ in 0 .. validators.min(edges_per_nominator as u32) {
let selected = rng.next_u32() as usize % available_validators.len();
let validator = available_validators.remove(selected);
selected_validators.push(validator);
Expand Down