mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 16:11:05 +00:00
staking: only disable slashed validators and keep them disabled for whole era (#9448)
* session: remove disabled validators threshold logic * staking: add logic to track offending validators * staking: disable validators for the whole era * frame: fix tests * staking: add tests for disabling validators handling * staking: fix adding offending validator when already slashed in era * address review comments * session, staking: add comments about sorted vecs Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
@@ -141,6 +141,10 @@ pub mod pallet {
|
||||
#[pallet::constant]
|
||||
type MaxNominatorRewardedPerValidator: Get<u32>;
|
||||
|
||||
/// The fraction of the validator set that is safe to be offending.
|
||||
/// After the threshold is reached a new era will be forced.
|
||||
type OffendingValidatorsThreshold: Get<Perbill>;
|
||||
|
||||
/// Something that can provide a sorted list of voters in a somewhat sorted way. The
|
||||
/// original use case for this was designed with [`pallet_bags_list::Pallet`] in mind. If
|
||||
/// the bags-list is not desired, [`impls::UseNominatorsMap`] is likely the desired option.
|
||||
@@ -437,6 +441,19 @@ pub mod pallet {
|
||||
#[pallet::getter(fn current_planned_session)]
|
||||
pub type CurrentPlannedSession<T> = StorageValue<_, SessionIndex, ValueQuery>;
|
||||
|
||||
/// Indices of validators that have offended in the active era and whether they are currently
|
||||
/// disabled.
|
||||
///
|
||||
/// This value should be a superset of disabled validators since not all offences lead to the
|
||||
/// validator being disabled (if there was no slash). This is needed to track the percentage of
|
||||
/// validators that have offended in the current era, ensuring a new era is forced if
|
||||
/// `OffendingValidatorsThreshold` is reached. The vec is always kept sorted so that we can find
|
||||
/// whether a given validator has previously offended using binary search. It gets cleared when
|
||||
/// the era ends.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn offending_validators)]
|
||||
pub type OffendingValidators<T: Config> = StorageValue<_, Vec<(u32, bool)>, ValueQuery>;
|
||||
|
||||
/// True if network has been upgraded to this version.
|
||||
/// Storage version of the pallet.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user