Function sp_npos_elections::pjr::t_pjr_check[][src]

pub fn t_pjr_check<AccountId: IdentifierT>(
    supports: &Supports<AccountId>,
    all_candidates: Vec<AccountId>,
    all_voters: Vec<(AccountId, VoteWeight, Vec<AccountId>)>,
    t: ExtendedBalance
) -> Result<(), AccountId>
Expand description

Check a solution to be t-PJR.

Semantics

The t-PJR property is defined in the paper “Validator Election in Nominated Proof-of-Stake”, section 5, definition 1.

In plain language, the t-PJR condition is: if there is a group of N voters who have r common candidates and can afford to support each of them with backing stake t (i.e sum(stake(v) for v in voters) == r * t), then this committee needs to be represented by at least r elected candidates.

Section 5 of the NPoS paper shows that this property can be tested by: for a feasible solution, if Max {score(c)} < t where c is every unelected candidate, then this solution is t-PJR. There may exist edge cases which satisfy the formal definition of t-PJR but do not pass this test, but those should be rare enough that we can discount them.

Interface

In addition to data that can be computed from the Supports struct, a PJR check also needs to inspect un-elected candidates and edges, thus all_candidates and all_voters.