staking: add `manual_slash` extrinsic (#7805)
This PR adds a convenience extrinsic `manual_slash` for the governance to slash a validator manually. ## Changes * The `on_offence` implementation for the Staking pallet accepts a slice of `OffenceDetails` including the full validator exposure, however, it simply [ignores](https://github.com/paritytech/polkadot-sdk/blob/c8d33396 /substrate/frame/staking/src/pallet/impls.rs#L1864) that part. I've extracted the functionality into an inherent `on_offence` method that takes `OffenceDetails` without the full exposure and this is called directly in `manual_slash` * `manual_slash` creates an offence for a validator with a given slash percentange ## Questions - [x] should `manual_slash` accept session instead of an era when the validator was in the active set? staking thinks in terms of eras and we can check out of bounds this way, which is why it was chosen for this implementation, but if there are arguments against, happy to change to session index - [X] should the accepted origin be something more than just root? Changed to `T::AdminOrigin` to align with `cancel_deferred_slash` - [X] should I adapt this PR also against https://github.com/paritytech/polkadot-sdk/pull/6996? looking at the changes, it should apply mostly without conflicts --------- Co-authored-by:Tsvetomir Dimitrov <tsvetomir@parity.io> Co-authored-by:
Ankan <10196091+Ank4n@users.noreply.github.com>
parent
f323814d
Showing
- polkadot/runtime/westend/src/weights/pallet_staking.rs 29 additions, 0 deletionspolkadot/runtime/westend/src/weights/pallet_staking.rs
- prdoc/pr_7805.prdoc 11 additions, 0 deletionsprdoc/pr_7805.prdoc
- substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs 1 addition, 1 deletion...lection-provider-multi-phase/test-staking-e2e/src/mock.rs
- substrate/frame/staking/src/benchmarking.rs 27 additions, 0 deletionssubstrate/frame/staking/src/benchmarking.rs
- substrate/frame/staking/src/mock.rs 6 additions, 2 deletionssubstrate/frame/staking/src/mock.rs
- substrate/frame/staking/src/pallet/impls.rs 20 additions, 2 deletionssubstrate/frame/staking/src/pallet/impls.rs
- substrate/frame/staking/src/pallet/mod.rs 58 additions, 0 deletionssubstrate/frame/staking/src/pallet/mod.rs
- substrate/frame/staking/src/tests.rs 183 additions, 3 deletionssubstrate/frame/staking/src/tests.rs
- substrate/frame/staking/src/weights.rs 59 additions, 0 deletionssubstrate/frame/staking/src/weights.rs
Please register or sign in to comment