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:
André Silva
2021-10-06 17:22:34 +01:00
committed by GitHub
parent 12e9e7ceb3
commit 7e5c022aea
25 changed files with 282 additions and 134 deletions
+1 -1
View File
@@ -674,7 +674,7 @@ where
SetIdSession::<T>::insert(current_set_id, &session_index);
}
fn on_disabled(i: usize) {
fn on_disabled(i: u32) {
Self::deposit_log(ConsensusLog::OnDisabled(i as u64))
}
}
+2 -2
View File
@@ -111,7 +111,6 @@ where
parameter_types! {
pub const Period: u64 = 1;
pub const Offset: u64 = 0;
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
}
/// Custom `SessionHandler` since we use `TestSessionKeys` as `Keys`.
@@ -124,7 +123,6 @@ impl pallet_session::Config for Test {
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
type SessionHandler = <TestSessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = TestSessionKeys;
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
type WeightInfo = ();
}
@@ -191,6 +189,7 @@ parameter_types! {
pub const MaxNominatorRewardedPerValidator: u32 = 64;
pub const ElectionLookahead: u64 = 0;
pub const StakingUnsignedPriority: u64 = u64::MAX / 2;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
}
impl onchain::Config for Test {
@@ -214,6 +213,7 @@ impl pallet_staking::Config for Test {
type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
type GenesisElectionProvider = Self::ElectionProvider;