Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
disputes pallet: Filter disputes with votes less than supermajority t…
Browse files Browse the repository at this point in the history
…hreshold
  • Loading branch information
tdimitrov committed Nov 21, 2022
1 parent 9546890 commit 81b54a3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions runtime/parachains/src/disputes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ pub mod pallet {
PotentialSpam,
/// A dispute where there are only votes on one side.
SingleSidedDispute,
/// Unconfirmed dispute statement sets provided
UnconfirmedDispute,
}

#[pallet::call]
Expand Down Expand Up @@ -1038,6 +1040,13 @@ impl<T: Config> Pallet<T> {
return StatementSetFilter::RemoveAll
}

// Reject disputes containing less votes than needed for confirmation.
if summary.state.validators_for.count_ones() + summary.state.validators_against.count_ones() <
supermajority_threshold(summary.state.validators_for.len())
{
return StatementSetFilter::RemoveAll
}

// Apply spam slot changes. Bail early if too many occupied.
let is_local = <Included<T>>::contains_key(&set.session, &set.candidate_hash);
if !is_local {
Expand Down Expand Up @@ -1200,6 +1209,14 @@ impl<T: Config> Pallet<T> {
Error::<T>::SingleSidedDispute,
);

// Reject disputes containing less votes than needed for confirmation.
ensure!(
summary.state.validators_for.count_ones() +
summary.state.validators_against.count_ones() >=
supermajority_threshold(summary.state.validators_for.len()),
Error::<T>::UnconfirmedDispute,
);

let DisputeStatementSet { ref session, ref candidate_hash, .. } = set;
let session = *session;
let candidate_hash = *candidate_hash;
Expand Down

0 comments on commit 81b54a3

Please sign in to comment.