diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index aa7acee6d27d..b63305efb27a 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -129,9 +129,8 @@ pub trait DisputesHandler { included_in: BlockNumber, ); - /// Whether the given candidate could be invalid, i.e. there is an ongoing - /// or concluded dispute with supermajority-against. - fn could_be_invalid(session: SessionIndex, candidate_hash: CandidateHash) -> bool; + /// Whether the given candidate concluded invalid in a dispute with supermajority. + fn concluded_invalid(session: SessionIndex, candidate_hash: CandidateHash) -> bool; /// Called by the initializer to initialize the configuration module. fn initializer_initialize(now: BlockNumber) -> Weight; @@ -165,7 +164,7 @@ impl DisputesHandler for () { ) { } - fn could_be_invalid(_session: SessionIndex, _candidate_hash: CandidateHash) -> bool { + fn concluded_invalid(_session: SessionIndex, _candidate_hash: CandidateHash) -> bool { false } @@ -201,8 +200,8 @@ impl DisputesHandler for pallet::Pallet { pallet::Pallet::::note_included(session, candidate_hash, included_in) } - fn could_be_invalid(session: SessionIndex, candidate_hash: CandidateHash) -> bool { - pallet::Pallet::::could_be_invalid(session, candidate_hash) + fn concluded_invalid(session: SessionIndex, candidate_hash: CandidateHash) -> bool { + pallet::Pallet::::concluded_invalid(session, candidate_hash) } fn initializer_initialize(now: T::BlockNumber) -> Weight { @@ -1114,10 +1113,10 @@ impl Pallet { } } - pub(crate) fn could_be_invalid(session: SessionIndex, candidate_hash: CandidateHash) -> bool { + pub(crate) fn concluded_invalid(session: SessionIndex, candidate_hash: CandidateHash) -> bool { >::get(&session, &candidate_hash).map_or(false, |dispute| { - // A dispute that is ongoing or has concluded with supermajority-against. - dispute.concluded_at.is_none() || has_supermajority_against(&dispute) + // A dispute that has concluded with supermajority-against. + has_supermajority_against(&dispute) }) } @@ -2207,9 +2206,9 @@ mod tests { ] ); - assert_eq!(Pallet::::could_be_invalid(3, candidate_hash.clone()), false); // It has 5 votes for - assert_eq!(Pallet::::could_be_invalid(4, candidate_hash.clone()), true); - assert_eq!(Pallet::::could_be_invalid(5, candidate_hash.clone()), true); + assert!(!Pallet::::concluded_invalid(3, candidate_hash.clone())); + assert!(!Pallet::::concluded_invalid(4, candidate_hash.clone())); + assert!(Pallet::::concluded_invalid(5, candidate_hash.clone())); // Ensure inclusion removes spam slots assert_eq!(SpamSlots::::get(4), Some(vec![0, 0, 1, 1, 0, 0, 0])); diff --git a/runtime/parachains/src/paras_inherent.rs b/runtime/parachains/src/paras_inherent.rs index a972dbfaa3d8..9ac8e0141542 100644 --- a/runtime/parachains/src/paras_inherent.rs +++ b/runtime/parachains/src/paras_inherent.rs @@ -66,8 +66,8 @@ pub mod pallet { /// The hash of the submitted parent header doesn't correspond to the saved block hash of /// the parent. InvalidParentHeader, - /// Potentially invalid candidate. - CandidateCouldBeInvalid, + /// Disputed candidate that was concluded invalid. + CandidateConcludedInvalid, } /// Whether the paras inherent was included within this block. @@ -238,14 +238,14 @@ pub mod pallet { let backed_candidates = limit_backed_candidates::(backed_candidates); let backed_candidates_len = backed_candidates.len() as Weight; - // Refuse to back any candidates that are disputed or invalid. + // Refuse to back any candidates that were disputed and are concluded invalid. for candidate in &backed_candidates { ensure!( - !T::DisputesHandler::could_be_invalid( + !T::DisputesHandler::concluded_invalid( current_session, candidate.candidate.hash(), ), - Error::::CandidateCouldBeInvalid, + Error::::CandidateConcludedInvalid, ); }