paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.8k stars 652 forks source link

Generic slashing side-effects #5623

Open JuaniRios opened 3 weeks ago

JuaniRios commented 3 weeks ago

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:

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?

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

Polkadot address: 15fj1UhQp8Xes7y7LSmDYTy349mXvUwrbNmLaP5tQKBxsQY1

Checklist

kianenigma commented 1 week ago

Someday this can help us/one implement https://github.com/paritytech/polkadot-sdk/issues/339.

franciscoaguirre commented 1 week ago

bot fmt

command-bot[bot] commented 1 week ago

@franciscoaguirre https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7395715 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 4-483b8645-287c-4c87-8f54-ef9967c4660c to cancel this command or bot cancel to cancel all commands in this pull request.

command-bot[bot] commented 1 week ago

@franciscoaguirre Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7395715 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7395715/artifacts/download.

JuaniRios commented 5 days ago

bot fmt

command-bot[bot] commented 5 days ago

@JuaniRios Requester could not be detected as a member of an allowed organization.

franciscoaguirre commented 4 days ago

bot fmt

command-bot[bot] commented 4 days ago

@franciscoaguirre https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7421120 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 2-df158727-91f6-49d9-84b9-cb7164a6a85e to cancel this command or bot cancel to cancel all commands in this pull request.

command-bot[bot] commented 4 days ago

@franciscoaguirre Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7421120 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7421120/artifacts/download.

JuaniRios commented 3 days ago

@franciscoaguirre @kianenigma PR is passing the main checks. We only need a call to the fmt bot, and I think that will also fix the umbrella check.

I ran python3 ./scripts/generate-umbrella.py --sdk . --version 0.1.0 for the umbrella fix, is that the right command?