-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validator Re-Enabling (master PR) #5724
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a quick pass by focusing mainly on the approach. It looks good, nice work @Overkillus!
I've left some thoughts about a corner case with the re-enabling.
// Find the smallest offender to re-enable that is not higher than offender_slash_severity | ||
if let Some((smallest_idx, _)) = currently_disabled | ||
.iter() | ||
.filter(|(_, perbill)| *perbill <= offender_slash_severity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify - even if there is no offender with a smaller offence we will re-enable the first guy with an offence equal to the new offender. Which is a good thing.
However I think we are biased here towards disabling the validator with the smallest index, which is wrong. If there are multiple elements with the same min value min_by_key
returns the first one. If I am not mistaken DisabledValidators
are sorted by key (here) so this way we will always reenable the guy with the smallest index.
It's a corner case but it would be nice to handle it if it is not too complicated.
DisabledValidators::<T>::mutate(|disabled| { | ||
let decision = T::DisablingStrategy::decision(params.stash, params.slash, params.slash_era, &disabled); | ||
|
||
match (decision.disable, decision.reenable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably I am missing something but won't this be simpler if the two values are handled separately?
I mean if decision.disable
is Some
- disable the guy. Then if decision.reenable
is Some
- reenable the guy?
That way you will avoid the code duplication.
let severity = params.slash; | ||
disabled.insert(index, (offender_idx, severity)); | ||
// Propagate disablement to session level | ||
T::SessionInterface::disable_validator(offender_idx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T::SessionInterface::disable_validator(offender_idx); | |
T::SessionInterface::disable_validator(offender_idx); | |
todo!("Add severity updating") |
The CI pipeline was cancelled due to failure one of the required jobs. |
Aims to implement Stage 3 of Validator Disbling as outlined here: #4359