Trait sp_staking::offence::Offence
source · [−]pub trait Offence<Offender> {
type TimeSlot: Clone + Codec + Ord;
const ID: Kind;
fn offenders(&self) -> Vec<Offender>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
;
fn session_index(&self) -> SessionIndex;
fn validator_set_count(&self) -> u32;
fn time_slot(&self) -> Self::TimeSlot;
fn slash_fraction(offenders_count: u32, validator_set_count: u32) -> Perbill;
}
Expand description
A trait implemented by an offence report.
This trait assumes that the offence is legitimate and was validated already.
Examples of offences include: a BABE equivocation or a GRANDPA unjustified vote.
Associated Types
Associated Constants
Required methods
The list of all offenders involved in this incident.
The list has no duplicates, so it is rather a set.
fn session_index(&self) -> SessionIndex
fn session_index(&self) -> SessionIndex
The session index that is used for querying the validator set for the slash_fraction
function.
This is used for filtering historical sessions.
fn validator_set_count(&self) -> u32
fn validator_set_count(&self) -> u32
Return a validator set count at the time when the offence took place.
A point in time when this offence happened.
This is used for looking up offences that happened at the “same time”.
The timescale is abstract and doesn’t have to be the same across different implementations
of this trait. The value doesn’t represent absolute timescale though since it is interpreted
along with the session_index
. Two offences are considered to happen at the same time iff
both session_index
and time_slot
are equal.
As an example, for GRANDPA timescale could be a round number and for BABE it could be a slot number. Note that for GRANDPA the round number is reset each epoch.
fn slash_fraction(offenders_count: u32, validator_set_count: u32) -> Perbill
fn slash_fraction(offenders_count: u32, validator_set_count: u32) -> Perbill
A slash fraction of the total exposure that should be slashed for this
particular offence kind for the given parameters that happened at a singular TimeSlot
.
offenders_count
- the count of unique offending authorities. It is >0.
validator_set_count
- the cardinality of the validator set at the time of offence.