NPoS Challenge Mode (#8236)

* Add PJR challenge functions

- Updates the PJR check to return a counterexample if one exists
- Adds functions to cheaply check counterexamples

This is in support of off-chain PJR challenges: if a miner discovers
that an accepted election solution does not satisfy PJR, it will be
eligible for substantial rewards. This helps ensure that validator
elections have an absolute quality floor, so even if someone manages
to censor well-behaved solutions to give themselves unfair representation,
we can catch them in the act and penalize them.

* counterexample -> counter_example

* reorganize: high -> low abstraction

* reorganize challenges high -> low abstraction

* add note justifying linear search

* Simplify max_pre_score validation

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* add minor test of pjr challenge validation

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Peter Goodspeed-Niklaus
2021-03-16 10:00:03 +01:00
committed by GitHub
parent 844e25522c
commit 49be0579db
2 changed files with 102 additions and 12 deletions
@@ -112,7 +112,7 @@ fn iteration(mut candidate_count: usize, mut voter_count: usize, seed: u64) {
let threshold = standard_threshold(rounds, voters.iter().map(|voter| voter.budget()));
assert!(
pjr_check_core(&candidates, &voters, threshold),
pjr_check_core(&candidates, &voters, threshold).is_ok(),
"unbalanced sequential phragmen must satisfy PJR",
);
}