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

Commit

Permalink
Remove dead code in filter_dispute_data
Browse files Browse the repository at this point in the history
  • Loading branch information
tdimitrov committed Dec 15, 2022
1 parent 052cde6 commit 16e1b95
Showing 1 changed file with 8 additions and 37 deletions.
45 changes: 8 additions & 37 deletions runtime/parachains/src/disputes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,24 +885,21 @@ impl<T: Config> Pallet<T> {
let n_validators = session_info.validators.len();

// Check for ancient.
let (first_votes, dispute_state) = {
let dispute_state = {
if let Some(dispute_state) = <Disputes<T>>::get(&set.session, &set.candidate_hash) {
if dispute_state.concluded_at.as_ref().map_or(false, |c| c < &oldest_accepted) {
return StatementSetFilter::RemoveAll
}

(false, dispute_state)
dispute_state
} else {
// No state in storage, this indicates it's the first dispute statement set as well.
(
true,
DisputeState {
validators_for: bitvec![u8, BitOrderLsb0; 0; n_validators],
validators_against: bitvec![u8, BitOrderLsb0; 0; n_validators],
start: now,
concluded_at: None,
},
)
DisputeState {
validators_for: bitvec![u8, BitOrderLsb0; 0; n_validators],
validators_against: bitvec![u8, BitOrderLsb0; 0; n_validators],
start: now,
concluded_at: None,
}
}
};

Expand Down Expand Up @@ -971,32 +968,6 @@ impl<T: Config> Pallet<T> {
return StatementSetFilter::RemoveAll
}

let is_local = <Included<T>>::contains_key(&set.session, &set.candidate_hash);
if !is_local {
// This is only relevant in cases where it's the first vote and the state
// would hence hold a onesided dispute. If a onesided dispute can never be
// started, by induction, we can never enter a state of a one sided dispute.
if first_votes {
let mut vote_for_count = 0_u64;
let mut vote_against_count = 0_u64;
// Since this is the first set of statements for the dispute,
// it's sufficient to count the votes in the statement set after they
set.statements.iter().for_each(|(statement, v_i, _signature)| {
if Some(true) ==
summary.new_participants.get(v_i.0 as usize).map(|b| *b.as_ref())
{
match statement {
// Note that this does not distinguish between pro or con votes,
// since allowing both of them.
// Overflow of the counters is no concern, disputes are limited by weight.
DisputeStatement::Valid(_) => vote_for_count += 1,
DisputeStatement::Invalid(_) => vote_against_count += 1,
}
}
});
}
}

filter
}

Expand Down

0 comments on commit 16e1b95

Please sign in to comment.