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

disputes pallet: Filter unconfirmed disputes #6330

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -937,6 +939,7 @@ impl<T: Config> Pallet<T> {
//
// Votes which are duplicate or already known by the chain are filtered out.
// The entire set is removed if the dispute is both, ancient and concluded.
// Disputes without enough votes to get confirmed are also filtered out.
fn filter_dispute_data(
set: &DisputeStatementSet,
post_conclusion_acceptance_period: <T as frame_system::Config>::BlockNumber,
Expand Down Expand Up @@ -1038,6 +1041,13 @@ impl<T: Config> Pallet<T> {
return StatementSetFilter::RemoveAll
}

// Reject disputes containing less votes than needed for confirmation.
if (summary.state.validators_for.clone() | &summary.state.validators_against).count_ones() <=
byzantine_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 +1210,13 @@ impl<T: Config> Pallet<T> {
Error::<T>::SingleSidedDispute,
);

// Reject disputes containing less votes than needed for confirmation.
ensure!(
(summary.state.validators_for.clone() | &summary.state.validators_against).count_ones() >
byzantine_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