mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +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:
@@ -619,12 +619,9 @@ pub struct UnappliedSlash<AccountId, Balance: HasCompact> {
|
||||
///
|
||||
/// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Config`
|
||||
pub trait SessionInterface<AccountId>: frame_system::Config {
|
||||
/// Disable a given validator by stash ID.
|
||||
///
|
||||
/// Returns `true` if new era should be forced at the end of this session.
|
||||
/// This allows preventing a situation where there is too many validators
|
||||
/// disabled and block production stalls.
|
||||
fn disable_validator(validator: &AccountId) -> Result<bool, ()>;
|
||||
/// Disable the validator at the given index, returns `false` if the validator was already
|
||||
/// disabled or the index is out of bounds.
|
||||
fn disable_validator(validator_index: u32) -> bool;
|
||||
/// Get the validators from session.
|
||||
fn validators() -> Vec<AccountId>;
|
||||
/// Prune historical session tries up to but not including the given index.
|
||||
@@ -645,8 +642,8 @@ where
|
||||
Option<<T as frame_system::Config>::AccountId>,
|
||||
>,
|
||||
{
|
||||
fn disable_validator(validator: &<T as frame_system::Config>::AccountId) -> Result<bool, ()> {
|
||||
<pallet_session::Pallet<T>>::disable(validator)
|
||||
fn disable_validator(validator_index: u32) -> bool {
|
||||
<pallet_session::Pallet<T>>::disable_index(validator_index)
|
||||
}
|
||||
|
||||
fn validators() -> Vec<<T as frame_system::Config>::AccountId> {
|
||||
|
||||
Reference in New Issue
Block a user