-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generic slashing side-effects (#5623)
# 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](paritytech/substrate#12951) @gavofyork said: > Since Holds are designed to be infallibly slashed, this means that any logic using a Freeze must handle the possibility of the frozen amount being reduced, potentially to zero. A permissionless function should be provided in order to allow bookkeeping to be updated in this instance. 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? - First we abstract the `done_slash` function of holds::Balanced to it's own trait that any pallet can implement. - Then we add a config type in pallet-balances that accepts a callback tuple of all the pallets that implement this trait. - Finally implement done_slash for pallet-balances such that it calls the config type. ## 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 - I suggest to focus on the first commit which contains the main logic changes. - I also have a working implementation of done_slash for pallet_vesting, should I add it to this PR? - If I run `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 CI - Should I hunt down references to fungible/fungibles documentation and update it accordingly? **Polkadot address:** `15fj1UhQp8Xes7y7LSmDYTy349mXvUwrbNmLaP5tQKBxsQY1` # Checklist * [x] My PR includes a detailed description as outlined in the "Description" and its two subsections above. * [x] My PR follows the [labeling requirements]( https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md#Process ) of this project (at minimum one label for `T` required) * External contributors: ask maintainers to put the right label on your PR. * [ ] I have made corresponding changes to the documentation (if applicable) --------- Co-authored-by: Kian Paimani <[email protected]> Co-authored-by: command-bot <> Co-authored-by: Francisco Aguirre <[email protected]>
- Loading branch information
1 parent
4b356c4
commit c0ddfba
Showing
36 changed files
with
255 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
||
title: Generic slashing side-effects | ||
|
||
doc: | ||
- audience: Runtime Dev | ||
description: | | ||
What? | ||
Make it possible for other pallets to implement their own logic when a slash on a balance occurs. | ||
|
||
How? | ||
First we abstract the done_slash function of holds::Balanced to it's own trait that any pallet can implement. | ||
Then we add a config type in pallet-balances that accepts a callback tuple of all the pallets that implement this trait. | ||
Finally implement done_slash for pallet-balances such that it calls the config type. | ||
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. | ||
|
||
crates: | ||
- name: frame-support | ||
bump: major | ||
|
||
- name: pallet-balances | ||
bump: major | ||
|
||
- name: pallet-broker | ||
bump: minor | ||
|
||
- name: rococo-runtime | ||
bump: minor | ||
|
||
- name: pallet-nis | ||
bump: minor | ||
|
||
- name: westend-runtime | ||
bump: minor | ||
|
||
- name: pallet-assets-freezer | ||
bump: minor | ||
|
||
- name: pallet-contracts-mock-network | ||
bump: minor | ||
|
||
- name: pallet-revive-mock-network | ||
bump: minor | ||
|
||
- name: asset-hub-rococo-runtime | ||
bump: minor | ||
|
||
- name: asset-hub-westend-runtime | ||
bump: minor | ||
|
||
- name: bridge-hub-rococo-runtime | ||
bump: minor | ||
|
||
- name: bridge-hub-westend-runtime | ||
bump: minor | ||
|
||
- name: collectives-westend-runtime | ||
bump: minor | ||
|
||
- name: coretime-rococo-runtime | ||
bump: minor | ||
|
||
- name: coretime-westend-runtime | ||
bump: minor | ||
|
||
- name: people-rococo-runtime | ||
bump: minor | ||
|
||
- name: people-westend-runtime | ||
bump: minor | ||
|
||
- name: penpal-runtime | ||
bump: minor | ||
|
||
- name: contracts-rococo-runtime | ||
bump: minor | ||
|
||
- name: rococo-parachain-runtime | ||
bump: minor | ||
|
||
- name: staging-xcm-builder | ||
bump: minor | ||
|
||
- name: polkadot-sdk | ||
bump: minor | ||
|
||
|
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.