In this code :

    pub struct NposCompactSolution16::<
        VoterIndex = u32,
        TargetIndex = u16,
        Accuracy = sp_runtime::PerU16,

pub const MAX_NOMINATIONS: u32 =
    <NposCompactSolution16 as sp_npos_elections::NposSolution>::LIMIT as u32;

What does MAX_NOMINATIONS stand for and what is it's value? Is it 16 from the NposCompactSolution16.0? Also, why is this useful? When should we change this value?

2 Answers 2


The docs for generate_solution_type say:

/// Moreover, the maximum number of edges per voter (distribution per assignment) also need to be
/// specified. Attempting to convert from/to an assignment with more distributions will fail.
/// For example, the following generates a public struct with name `TestSolution` with `u16` voter
/// type, `u8` target type and `Perbill` accuracy with maximum of 4 edges per voter.
/// ```
/// # use frame_election_provider_solution_type::generate_solution_type;
/// # use sp_arithmetic::per_things::Perbill;
/// generate_solution_type!(pub struct TestSolution::<
///     VoterIndex = u16,
///     TargetIndex = u8,
///     Accuracy = Perbill,
/// >(4));

Note that this type is generic to a graph based election algorithm where a voter may elect multiple targets. With this in mind in the context of the staking pallet, the phrase “edges per voter” can be understood as the the maximum number of targets (validators), that a nominator can nominate; in other words the max nominations that a nominator can have.

The two primary considerations when configuring this value are:

  1. How does changing this value affect the worst case space / memory complexity of operations on nominators?
  2. How does changing the value affect the election algorithms ability to achieve its goals (i.e. maximize total stake, maximize min staked validator’s exposure, minimize difference between exposure of max and min staked validators).

To address (1), one should consider how many total nominators they want in the system. Essentially, increasing the MAX_NOMINATIONS will increase the worst case space complexity of each nominator; so as the MAX_NOMINATIONS increase, the number of nominators the system can handle will decrease. For example see the discussion here about lower the max number of voters on Kusama.

To address (2), one should consider that hypothetically a phragmen election algorithm can do a better job of creating an optimal set when nominators have selected a wide array of validators (in practice the increase of max nominations is not guaranteed to lead to an increase in solution quality). As an extreme, imagine a max nominations of 1: the algorithm would practically do nothing and we would have the equivalent of a DPoS outcome.

Also keep in mind that nominator accounts make no sybil resistance guarantees; a low max nominations may encourage some users to break up 1 nominator account into several nominator accounts so they can select a wider variety of validators, thus increasing the nominator space complexity per "real" user.

  • Interesting points. I have a few questions. 1. How can a nominator "break" their account into several nominator accounts? 2. If I set MaxNominations = 1, that becomes you say equivalent to a DPoS. What is DPos and how is it different from nPoS?
    – RoboT
    Mar 22, 2022 at 10:57
  • 1
    1) They unbond some funds, transfer them to another account and then nominate. 2) DPoS is a loaded term, but typically it means an account can delegate some staked funds to one validator and validators are rewarded based on their percentage of total stake. I found this, among other resources, when googling: en.bitcoinwiki.org/wiki/DPoS
    – zekemostov
    Mar 22, 2022 at 14:06

Answer the second question: " Is it 16 from the NposCompactSolution16.0 ?". Yes and no, for yes part, it is 16; for no part, 16 does not come from NposCompactSolution16.0, it comes from (16).

For more detail, you can see the following macros' definitions:

  1. syn/src/parse_macro_input.rs macro_rules! parse_macro_input
  2. Parse.parse in npos-elctions/solution-type/src/lib.rs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.