-
Notifications
You must be signed in to change notification settings - Fork 767
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
[Fix|NominationPools] Only allow apply slash to be executed if the slash amount is atleast ED #6540
Conversation
@@ -2989,7 +2993,7 @@ pub mod pallet { | |||
|
|||
let who = ensure_signed(origin)?; | |||
let member_account = T::Lookup::lookup(member_account)?; | |||
Self::do_apply_slash(&member_account, Some(who))?; | |||
Self::do_apply_slash(&member_account, Some(who), true)?; |
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 do we want to to avoid slashing below the ED here (pub fn apply_slash
)?
I don't think this is an issue, slash are applied for rare circumstances no? |
@@ -2300,7 +2302,7 @@ pub mod pallet { | |||
|
|||
let slash_weight = | |||
// apply slash if any before withdraw. | |||
match Self::do_apply_slash(&member_account, None) { | |||
match Self::do_apply_slash(&member_account, None, false) { |
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.
My previous comment only made sense when taken with another made to this line, which asked: why don't we want to enforce the ED checks here?
Sorry, I had the GH open for a while, it might have been lost when I refreshed the browser.
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.
At this point, a gas fee is charged for slashing. Additionally, we need to clean up all bookkeeping before a member withdraws.
Single slash can affect unbounded number of pool members. The slashes are applied per member and if that is too small, is it worth to provide free compute for it? |
@@ -3574,15 +3578,21 @@ impl<T: Config> Pallet<T> { | |||
fn do_apply_slash( | |||
member_account: &T::AccountId, | |||
reporter: Option<T::AccountId>, | |||
enforce_min_slash: bool, |
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.
nit but in order to prevent spreading do_apply_slash(..., bool)
across the code which is not very readable, how about creating an enum that helps with readability? something along the lines of
enum SlashConfig {
EnforceMinimum,
DoNotEnforceMinimuim
}
Not sure about the enum and variant names, but in general
// reads better
do_apply_slash(..., SlashConfig::EnforceMinimum);
// than this
do_apply_slash(..., true);
Co-authored-by: Dónal Murray <donal.murray@parity.io>
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-6540-to-stable2407
git worktree add --checkout .worktree/backport-6540-to-stable2407 backport-6540-to-stable2407
cd .worktree/backport-6540-to-stable2407
git reset --hard HEAD^
git cherry-pick -x bf20a9ee18f7215210bbbabf79e955c8c35b3360
git push --force-with-lease |
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-6540-to-stable2409
git worktree add --checkout .worktree/backport-6540-to-stable2409 backport-6540-to-stable2409
cd .worktree/backport-6540-to-stable2409
git reset --hard HEAD^
git cherry-pick -x bf20a9ee18f7215210bbbabf79e955c8c35b3360
git push --force-with-lease |
…ash amount is atleast ED (#6540) This change prevents `pools::apply_slash` from being executed when the pending slash amount of the member is lower than the ED. The issue came to light with the failing [benchmark test](https://github.com/polkadot-fellows/runtimes/actions/runs/11879471717/job/33101445269?pr=490#step:11:765) in Kusama. The problem arises from the inexact conversion between points and balance. Specifically, when points are converted to balance and then back to points, rounding can introduce a small discrepancy between the input and the resulting value. This issue surfaced in Kusama due to its ED being different from Westend and Polkadot (1 UNIT/300), making the rounding issue noticeable. This fix is also significant because applying a slash is feeless and permissionless. Allowing super small slash amounts to be applied without a fee is undesirable. With this change, such small slashes will still be applied but only when member funds are withdrawn. --------- Co-authored-by: Dónal Murray <donal.murray@parity.io> (cherry picked from commit bf20a9e)
Backport #6540 into `stable2407` from Ank4n. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> Co-authored-by: Egor_P <egor@parity.io>
Backport #6540 into `stable2409` from Ank4n. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> --------- Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> Co-authored-by: Ankan <ankan.anurag@gmail.com>
…ash amount is atleast ED (paritytech#6540) This change prevents `pools::apply_slash` from being executed when the pending slash amount of the member is lower than the ED. The issue came to light with the failing [benchmark test](https://github.com/polkadot-fellows/runtimes/actions/runs/11879471717/job/33101445269?pr=490#step:11:765) in Kusama. The problem arises from the inexact conversion between points and balance. Specifically, when points are converted to balance and then back to points, rounding can introduce a small discrepancy between the input and the resulting value. This issue surfaced in Kusama due to its ED being different from Westend and Polkadot (1 UNIT/300), making the rounding issue noticeable. This fix is also significant because applying a slash is feeless and permissionless. Allowing super small slash amounts to be applied without a fee is undesirable. With this change, such small slashes will still be applied but only when member funds are withdrawn. --------- Co-authored-by: Dónal Murray <donal.murray@parity.io>
…ash amount is atleast ED (paritytech#6540) This change prevents `pools::apply_slash` from being executed when the pending slash amount of the member is lower than the ED. The issue came to light with the failing [benchmark test](https://github.com/polkadot-fellows/runtimes/actions/runs/11879471717/job/33101445269?pr=490#step:11:765) in Kusama. The problem arises from the inexact conversion between points and balance. Specifically, when points are converted to balance and then back to points, rounding can introduce a small discrepancy between the input and the resulting value. This issue surfaced in Kusama due to its ED being different from Westend and Polkadot (1 UNIT/300), making the rounding issue noticeable. This fix is also significant because applying a slash is feeless and permissionless. Allowing super small slash amounts to be applied without a fee is undesirable. With this change, such small slashes will still be applied but only when member funds are withdrawn. --------- Co-authored-by: Dónal Murray <donal.murray@parity.io>
This change prevents
pools::apply_slash
from being executed when the pending slash amount of the member is lower than the ED.The issue came to light with the failing benchmark test in Kusama. The problem arises from the inexact conversion between points and balance. Specifically, when points are converted to balance and then back to points, rounding can introduce a small discrepancy between the input and the resulting value. This issue surfaced in Kusama due to its ED being different from Westend and Polkadot (1 UNIT/300), making the rounding issue noticeable.
This fix is also significant because applying a slash is feeless and permissionless. Allowing super small slash amounts to be applied without a fee is undesirable. With this change, such small slashes will still be applied but only when member funds are withdrawn.