referrerpolicy=no-referrer-when-downgrade

Trait sp_staking::offence::OffenceReportSystem

source ·
pub trait OffenceReportSystem<Reporter, Evidence> {
    type Longevity: Get<u64>;

    // Required methods
    fn publish_evidence(evidence: Evidence) -> Result<(), ()>;
    fn check_evidence(
        evidence: Evidence,
    ) -> Result<(), TransactionValidityError>;
    fn process_evidence(
        reporter: Reporter,
        evidence: Evidence,
    ) -> Result<(), DispatchError>;
}
Expand description

An abstract system to publish, check and process offence evidences.

Implementation details are left opaque and we don’t assume any specific usage scenario for this trait at this level. The main goal is to group together some common actions required during a typical offence report flow.

Even though this trait doesn’t assume too much, this is a general guideline for a typical usage scenario:

  1. An offence is detected and an evidence is submitted on-chain via the OffenceReportSystem::publish_evidence method. This will construct and submit an extrinsic transaction containing the offence evidence.

  2. If the extrinsic is unsigned then the transaction receiver may want to perform some preliminary checks before further processing. This is a good place to call the OffenceReportSystem::check_evidence method.

  3. Finally the report extrinsic is executed on-chain. This is where the user calls the OffenceReportSystem::process_evidence to consume the offence report and enact any required action.

Required Associated Types§

source

type Longevity: Get<u64>

Longevity, in blocks, for the evidence report validity.

For example, when using the staking pallet this should be set equal to the bonding duration in blocks, not eras.

Required Methods§

source

fn publish_evidence(evidence: Evidence) -> Result<(), ()>

Publish an offence evidence.

Common usage: submit the evidence on-chain via some kind of extrinsic.

source

fn check_evidence(evidence: Evidence) -> Result<(), TransactionValidityError>

Check an offence evidence.

Common usage: preliminary validity check before execution (e.g. for unsigned extrinsic quick checks).

source

fn process_evidence( reporter: Reporter, evidence: Evidence, ) -> Result<(), DispatchError>

Process an offence evidence.

Common usage: enact some form of slashing directly or by forwarding the evidence to a lower level specialized subsystem (e.g. a handler implementing ReportOffence trait).

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<Reporter, Evidence> OffenceReportSystem<Reporter, Evidence> for ()

Dummy offence report system.

Doesn’t do anything special and returns Ok(()) for all the actions.

§

type Longevity = ()

source§

fn publish_evidence(_evidence: Evidence) -> Result<(), ()>

source§

fn check_evidence(_evidence: Evidence) -> Result<(), TransactionValidityError>

source§

fn process_evidence( _reporter: Reporter, _evidence: Evidence, ) -> Result<(), DispatchError>

Implementors§