Skip to content
Snippets Groups Projects
ordian's avatar
ordian authored
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: default avatarTsvetomir Dimitrov <tsvetomir@parity.io>
Co-authored-by: default avatarAnkan <10196091+Ank4n@users.noreply.github.com>
f8c90b2a