Skip to content
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

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft

Validator Re-Enabling (master PR) #5724

wants to merge 19 commits into from

Conversation

Overkillus
Copy link
Contributor

Aims to implement Stage 3 of Validator Disbling as outlined here: #4359

@Overkillus Overkillus added I1-security The node fails to follow expected, security-sensitive, behaviour. T8-polkadot This PR/Issue is related to/affects the Polkadot network. labels Sep 16, 2024
@Overkillus Overkillus self-assigned this Sep 16, 2024
Copy link
Contributor

@tdimitrov tdimitrov left a 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)
Copy link
Contributor

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) {
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
T::SessionInterface::disable_validator(offender_idx);
T::SessionInterface::disable_validator(offender_idx);
todo!("Add severity updating")

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable-int
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7414353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I1-security The node fails to follow expected, security-sensitive, behaviour. T8-polkadot This PR/Issue is related to/affects the Polkadot network.
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

3 participants