Skip to content
Snippets Groups Projects
Unverified Commit f8c90b2a authored by ordian's avatar ordian Committed by GitHub
Browse files

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: default avatarTsvetomir Dimitrov <tsvetomir@parity.io>
Co-authored-by: default avatarAnkan <10196091+Ank4n@users.noreply.github.com>
parent f323814d
No related merge requests found
Pipeline #518822 waiting for manual action with stages
in 1 hour, 29 minutes, and 27 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment