-
Notifications
You must be signed in to change notification settings - Fork 690
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
Conversation
## 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.
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
@franciscoaguirre https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7467206 was started for your command Comment |
@franciscoaguirre Command |
# Conflicts: # substrate/utils/wasm-builder/src/wasm_project.rs
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.
for owner check, on contracts-pallet
I believe so, but I will let @ggwpez chime in. Let's use this as an opportunity to make sure our |
\tip medium |
/tip medium |
@JuaniRios Contributor did not properly post their account address. Make sure the pull request description (or user bio) has: "{network} address: {address}". |
/tip medium |
2 similar comments
/tip medium |
/tip medium |
@kianenigma A referendum for a medium (80 DOT) tip was successfully submitted for @JuaniRios (15fj1UhQp8Xes7y7LSmDYTy349mXvUwrbNmLaP5tQKBxsQY1 on polkadot). |
The referendum has appeared on Polkassembly. |
Polkadot address: 15fj1UhQp8Xes7y7LSmDYTy349mXvUwrbNmLaP5tQKBxsQY1
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 CIChecklist
T
required)