-
Notifications
You must be signed in to change notification settings - Fork 645
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
Generic slashing side-effects #5623
Open
JuaniRios
wants to merge
16
commits into
paritytech:master
Choose a base branch
from
JuaniRios:slashing-trait
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JuaniRios
changed the title
modify frame_support trait and pallet-balances impl
Generic slashing side-effects
Sep 6, 2024
franciscoaguirre
added
the
T1-FRAME
This PR/Issue is related to core FRAME, the framework.
label
Sep 6, 2024
JuaniRios
added a commit
to Polimec/polimec-node
that referenced
this pull request
Sep 12, 2024
## What? - Reduce vesting schedules of pallet-vesting after a slash is made when an evaluation is settled ## Why? - A user could have negative transferable balance if they had some tokens locked for vesting and then got slashed. ## How? - Semi-generic solution which should be easily adapted to the Polkadot SDK. PR is [here](paritytech/polkadot-sdk#5623). - pallet-funding (in the future pallet-balances) accepts a tuple of items that implement a trait called on_slash. - pallet funding calls this after slashing the evaluator (we don't use the slash interface so we call the trait directly. In the future this trait should also be called when using the slash function) - We implement on pallet vesting the trait where we see how many tokens should be released at the moment of slashing, and then apply the slash on the remaining frozen amount. We recalculate the per_block amount to keep the same end block ## Testing? - 2 tests in the new crate on-slash-vesting - 1 integration test ## Anything Else? - For now the trait for slashing needs to be in the same crate we implement it since we can't impl a foreign trait on a foreign crate. - Soon we should submit a PR to polkadot-sdk where we submit this new slash interface on the tokens::fungible trait, and also add our vesting impl directly inside pallet-vesting.
franciscoaguirre
approved these changes
Sep 13, 2024
kianenigma
reviewed
Sep 13, 2024
kianenigma
reviewed
Sep 13, 2024
kianenigma
reviewed
Sep 13, 2024
kianenigma
reviewed
Sep 13, 2024
kianenigma
reviewed
Sep 13, 2024
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.
LGTM modulo some docs missing
kianenigma
reviewed
Sep 18, 2024
kianenigma
reviewed
Sep 18, 2024
kianenigma
approved these changes
Sep 18, 2024
Someday this can help us/one implement #339. |
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
What?
Make it possible for other pallets to implement their own logic when a slash on a balance occurs.
Why?
In the introduction of holds @gavofyork said:
At Polimec we needed to find a way to reduce the vesting schedules of our users after a slash was made, and after talking to @kianenigma at the Web3Summit, we realized there was no easy way to implement this with the current traits, so we came up with this solution.
How?
done_slash
function of holds::Balanced to it's own trait that any pallet can implement.Integration
The default implementation of done_slash is still an empty function, and the new config type of pallet-balances can be set to an empty tuple, so nothing changes by default.
Review Notes
cargo +nightly fmt --all
then I get changes to a lot of unrelated crates, so not sure if I should run it to avoid the fmt failure of the CIPolkadot address:
15fj1UhQp8Xes7y7LSmDYTy349mXvUwrbNmLaP5tQKBxsQY1
Checklist
T
required)