mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
Filter votes from disabled validators in BackedCandidates in process_inherent_data (#2889)
Backport of https://github.com/paritytech/polkadot-sdk/pull/1863 to master Extend candidate sanitation in paras_inherent by removing backing votes from disabled validators. Check https://github.com/paritytech/polkadot-sdk/issues/1592 for more details. This change is related to the disabling strategy implementation (https://github.com/paritytech/polkadot-sdk/pull/2226). --------- Co-authored-by: ordian <noreply@reusable.software> Co-authored-by: ordian <write@reusable.software> Co-authored-by: Maciej <maciej.zyszkiewicz@parity.io>
This commit is contained in:
committed by
GitHub
parent
f574868822
commit
f8954093b4
@@ -194,7 +194,22 @@ impl crate::configuration::Config for Test {
|
||||
type WeightInfo = crate::configuration::TestWeightInfo;
|
||||
}
|
||||
|
||||
impl crate::shared::Config for Test {}
|
||||
pub struct MockDisabledValidators {}
|
||||
impl frame_support::traits::DisabledValidators for MockDisabledValidators {
|
||||
/// Returns true if the given validator is disabled.
|
||||
fn is_disabled(index: u32) -> bool {
|
||||
disabled_validators().iter().any(|v| *v == index)
|
||||
}
|
||||
|
||||
/// Returns a hardcoded list (`DISABLED_VALIDATORS`) of disabled validators
|
||||
fn disabled_validators() -> Vec<u32> {
|
||||
disabled_validators()
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::shared::Config for Test {
|
||||
type DisabledValidators = MockDisabledValidators;
|
||||
}
|
||||
|
||||
impl origin::Config for Test {}
|
||||
|
||||
@@ -564,6 +579,8 @@ thread_local! {
|
||||
|
||||
pub static AVAILABILITY_REWARDS: RefCell<HashMap<ValidatorIndex, usize>>
|
||||
= RefCell::new(HashMap::new());
|
||||
|
||||
pub static DISABLED_VALIDATORS: RefCell<Vec<u32>> = RefCell::new(vec![]);
|
||||
}
|
||||
|
||||
pub fn backing_rewards() -> HashMap<ValidatorIndex, usize> {
|
||||
@@ -574,6 +591,10 @@ pub fn availability_rewards() -> HashMap<ValidatorIndex, usize> {
|
||||
AVAILABILITY_REWARDS.with(|r| r.borrow().clone())
|
||||
}
|
||||
|
||||
pub fn disabled_validators() -> Vec<u32> {
|
||||
DISABLED_VALIDATORS.with(|r| r.borrow().clone())
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub static Processed: Vec<(ParaId, UpwardMessage)> = vec![];
|
||||
}
|
||||
@@ -713,3 +734,7 @@ pub(crate) fn deregister_parachain(id: ParaId) {
|
||||
pub(crate) fn try_deregister_parachain(id: ParaId) -> crate::DispatchResult {
|
||||
frame_support::storage::transactional::with_storage_layer(|| Paras::schedule_para_cleanup(id))
|
||||
}
|
||||
|
||||
pub(crate) fn set_disabled_validators(disabled: Vec<u32>) {
|
||||
DISABLED_VALIDATORS.with(|d| *d.borrow_mut() = disabled)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user