-
Notifications
You must be signed in to change notification settings - Fork 2.7k
NPoS Challenge Mode #8236
NPoS Challenge Mode #8236
Conversation
|
I'll follow whatever the convention is; my intent was to rebase once #8160 is merged. |
kianenigma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API is confused. The challenge, ideally has just one input:
counter_examplecandidate. Next to this, we will need to pass in all the voters as well, and nothing more to validate the challenge.
From this, we just compute prescore(counter_example, voters, t).
So no need to pass support and all_candidates` in.
|
The code doesn't iterate over all candidates, except to the degree that it searches the candidate list for the one of interest. However, it does require the full list of supports, all candidate, all voters. The chain of requirements goes like this:
A reasonable argument could be, "but why not extract a subset of |
We will surely need to run the All in all, we could also meet in the middle and merge this as-is and update the API once the challenge phase is in. But note that that is not imminent and we first need to finish the unsigned + signed phase, so I see it happening in the next ~3 months or so, based on how fast we move. |
Could we apply an economic incentive instead? We're already planning on incentivizing users to submit counterexamples by providing some reward to them. Couldn't we also apply some penalty in the event that the user submits an invalid counterexample? |
- 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.
822b9b1 to
b7b5866
Compare
b7b5866 to
63acb11
Compare
|
Reduced to unique commits; should be easier to review now. |
| supports: &Supports<AccountId>, | ||
| all_candidates: Vec<AccountId>, | ||
| all_voters: Vec<(AccountId, VoteWeight, Vec<AccountId>)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One random note unrelated to this PR per se: this pallet had quite a bad rap for not having a well defined behaviour with duplicate votes and candidates and targets etc. Now, finally, everything that goes through setup_input (called prior to seq_phragmen and phragmms) gets sanitized. Would be good to ensure these functions have the same standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prepare_pjr_input mentions setup_inputs in its documentation, but doesn't actually delegate. Shall I create an issue to add explicit delegation there to ensure that the behaviors are identical?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An issue would be good, bit I am not sure if delegation is the best way, we have to see. We can maybe mix this into #4593
kianenigma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing I see missing is a test. Otherwise looks clean.
Co-authored-by: Kian Paimani <[email protected]>
| /// Validate a challenge to an election result. | ||
| /// | ||
| /// A challenge to an election result is valid if there exists some counter_example for which | ||
| /// `pre_score(counter_example) >= threshold`. Validating an existing counter_example is computationally | ||
| /// cheaper than re-running the PJR check. | ||
| /// | ||
| /// Returns `true` if the challenge is valid: the proposed solution does not satisfy PJR. | ||
| /// Returns `false` if the challenge is invalid: the proposed solution does in fact satisfy PJR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this exact text is copied on all these functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also any advantage to breaking up the steps into such minimal functions? I feel if anything, this may actually loose context of what other operations are happening between the steps, where optimizations may be added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference in the text is
- /// This function uses the standard threshold.
+ /// This function uses a supplied threshold.The documentation goal is to ensure that each function's documentation completely describes what that function does, even though a similar function exists.
As for why the functions are factored in this way, it comes down to two things. On the one hand, it mirrors the factorization of the pjr_check functions. On the other hand, it means that users can supply a threshold, or not, as desired. We have use cases for both.
shawntabrizi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks clean
|
bot merge |
|
Trying merge. |
* 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 <[email protected]> * add minor test of pjr challenge validation Co-authored-by: Kian Paimani <[email protected]>

Builds on #8160.
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.