Skip to content

Commit

Permalink
Issue 6274: keeping all backing votes in provisioner vote set (parity…
Browse files Browse the repository at this point in the history
…tech#6494)

* Fixing filter to keep all backing votes

* Comment and implementers guide edit

* Formatting

* Using fallthrough

* Fmt
  • Loading branch information
BradleyOlson64 authored Jan 4, 2023
1 parent 2feb6c7 commit b4d8c76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions node/core/provisioner/src/disputes/prioritized_selection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use polkadot_node_subsystem::{
};
use polkadot_primitives::v2::{
supermajority_threshold, CandidateHash, DisputeState, DisputeStatement, DisputeStatementSet,
Hash, MultiDisputeStatementSet, SessionIndex, ValidatorIndex,
Hash, MultiDisputeStatementSet, SessionIndex, ValidDisputeStatementKind, ValidatorIndex,
};
use std::{
collections::{BTreeMap, HashMap},
Expand Down Expand Up @@ -364,10 +364,20 @@ fn is_vote_worth_to_keep(
dispute_statement: DisputeStatement,
onchain_state: &DisputeState,
) -> bool {
let offchain_vote = match dispute_statement {
DisputeStatement::Valid(_) => true,
DisputeStatement::Invalid(_) => false,
let (offchain_vote, valid_kind) = match dispute_statement {
DisputeStatement::Valid(kind) => (true, Some(kind)),
DisputeStatement::Invalid(_) => (false, None),
};
// We want to keep all backing votes. This maximizes the number of backers
// punished when misbehaving.
if let Some(kind) = valid_kind {
match kind {
ValidDisputeStatementKind::BackingValid(_) |
ValidDisputeStatementKind::BackingSeconded(_) => return true,
_ => (),
}
}

let in_validators_for = onchain_state
.validators_for
.get(validator_index.0 as usize)
Expand Down
2 changes: 1 addition & 1 deletion roadmap/implementers-guide/src/node/utility/provisioner.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The end result of this process is a vector of `BackedCandidate`s, sorted in orde

This is the point at which the block author provides further votes to active disputes or initiates new disputes in the runtime state.

The block-authoring logic of the runtime has an extra step between handling the inherent-data and producing the actual inherent call, which we assume performs the work of filtering out disputes which are not relevant to the on-chain state.
The block-authoring logic of the runtime has an extra step between handling the inherent-data and producing the actual inherent call, which we assume performs the work of filtering out disputes which are not relevant to the on-chain state. Backing votes are always kept in the dispute statement set. This ensures we punish the maximum number of misbehaving backers.

To select disputes:

Expand Down

0 comments on commit b4d8c76

Please sign in to comment.