-
Notifications
You must be signed in to change notification settings - Fork 823
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
[AHM] Moves disabling logic into pallet-session #7581
Conversation
…into gpestana/epm-mb
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 look. Changes look sane. I'm approving to get this included in the release but we have to do a proper review before deploying it on a prod network.
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.
High level interface looks very clear and good. Approving with the assumption that the impl is equivalent to the old behavior.
All GitHub workflows were cancelled due to failure one of the required jobs. |
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.
Thanks Kian, Tsveto and Donnal for a quick review and Ankan for awesome work!
Since we got this quickly merged I wanted to do a deeper dive into comparing it with pre-refactor behaviour. I highlighted a few bits and once we clarify those it's looking perfect
/// Note: This sets the OffenceSeverity to the lowest value. | ||
pub fn disable_index(i: u32) -> bool { | ||
if i >= Validators::<T>::decode_len().unwrap_or(0) as u32 { | ||
if i >= Validators::<T>::decode_len().defensive_unwrap_or(0) as u32 { | ||
return false | ||
} | ||
|
||
DisabledValidators::<T>::mutate(|disabled| { | ||
if let Err(index) = disabled.binary_search(&i) { | ||
disabled.insert(index, i); | ||
if let Err(index) = disabled.binary_search_by_key(&i, |(index, _)| *index) { | ||
disabled.insert(index, (i, OffenceSeverity(Perbill::zero()))); |
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.
Why are we defaulting to lowest severity? And what is the purpose of this logic? It is not being used for report_offence as you directly modify the DisabledValidators. Just for testing then?
What worries me is that we expose a way of disabling validators that is dangerous (default to lowest priority). At least requiring a severity would make it less prone to mistakes.
And if the argument is to expose it to other pallets then shouldn't we also have the enable_index that you removed a few lines below?
Another option is to make report_offence depend on disable_index / enable_index instead of making direct changes to disabledValidators
@@ -631,7 +653,7 @@ impl<T: Config> Pallet<T> { | |||
|
|||
/// Public function to access the disabled validators. | |||
pub fn disabled_validators() -> Vec<u32> { | |||
DisabledValidators::<T>::get() | |||
DisabledValidators::<T>::get().iter().map(|(i, _)| *i).collect() |
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.
dont we want to expose the severities as well?
@@ -740,23 +764,6 @@ impl<T: Config> Pallet<T> { | |||
}) | |||
} | |||
|
|||
/// Re-enable the validator of index `i`, returns `false` if the validator was already enabled. |
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.
see comment on disable_index
@@ -2745,6 +2741,7 @@ impl<T: Config> Pallet<T> { | |||
Ok(()) | |||
} | |||
|
|||
/* todo(ank4n): move to session try runtime |
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.
todo
|
||
// Clear disabled validators. | ||
<DisabledValidators<T>>::kill(); |
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.
original impl only killed DisabledValidators on era change, so they persisted between sessions. It is quite important so I'm bringing it to light explicitly. Is this behaviour replicated in the refactor?
assert!(disabling_decision.disable.is_none() && disabling_decision.reenable.is_none()); | ||
}); | ||
} | ||
// todo(ank4n): Ensure there is a test that for older eras, the disabling strategy does not |
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.
todo
closes #6508.
TODO
DisabledValidators
both in pallet-session and pallet-staking.DisabledValidators
.