Skip to content

Commit

Permalink
Filter votes from disabled validators in BackedCandidates in proces…
Browse files Browse the repository at this point in the history
…s_inherent_data (paritytech#2889)

Backport of paritytech#1863 to
master

Extend candidate sanitation in paras_inherent by removing backing votes
from disabled validators. Check
paritytech#1592 for more details.

This change is related to the disabling strategy implementation
(paritytech#2226).

---------

Co-authored-by: ordian <[email protected]>
Co-authored-by: ordian <[email protected]>
Co-authored-by: Maciej <[email protected]>
  • Loading branch information
4 people authored Jan 18, 2024
1 parent d065fc6 commit 2e077e5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions substrate/frame/aura/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ impl DisabledValidators for MockDisabledValidators {
fn is_disabled(index: AuthorityIndex) -> bool {
DisabledValidatorTestValue::get().binary_search(&index).is_ok()
}

fn disabled_validators() -> Vec<u32> {
DisabledValidatorTestValue::get()
}
}

impl pallet_aura::Config for Test {
Expand Down
4 changes: 3 additions & 1 deletion substrate/frame/contracts/mock-network/src/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
}

impl shared::Config for Runtime {}
impl shared::Config for Runtime {
type DisabledValidators = ();
}

impl configuration::Config for Runtime {
type WeightInfo = configuration::TestWeightInfo;
Expand Down
4 changes: 4 additions & 0 deletions substrate/frame/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,10 @@ impl<T: Config> frame_support::traits::DisabledValidators for Pallet<T> {
fn is_disabled(index: u32) -> bool {
<Pallet<T>>::disabled_validators().binary_search(&index).is_ok()
}

fn disabled_validators() -> Vec<u32> {
<Pallet<T>>::disabled_validators()
}
}

/// Wraps the author-scraping logic for consensus engines that can recover
Expand Down
7 changes: 7 additions & 0 deletions substrate/frame/support/src/traits/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,17 @@ pub trait ValidatorRegistration<ValidatorId> {
pub trait DisabledValidators {
/// Returns true if the given validator is disabled.
fn is_disabled(index: u32) -> bool;

/// Returns all disabled validators
fn disabled_validators() -> Vec<u32>;
}

impl DisabledValidators for () {
fn is_disabled(_index: u32) -> bool {
false
}

fn disabled_validators() -> Vec<u32> {
vec![]
}
}

0 comments on commit 2e077e5

Please sign in to comment.