Sigil documentation
ReferenceRust referencesigil-economics

sigil-economics · slashing

Source declarations, signatures and documentation for slashing.

Source: sigil/node/sigil-economics/src/slashing.rs. SHA-256: 8319d2c50cf009c062c88becbf664540858e94bd99e6a79fd6b000d02f1afd3c.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

slashing::SlashOffense

Types of slashable offenses with associated severity multipliers.

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SlashOffense {
    /// Signing two different blocks at the same height. Severity 3.0x.
    DoubleSign,
    /// Extended validator downtime. Severity 1.0x.
    Downtime,
    /// Proposing an invalid block. Severity 2.0x.
    InvalidBlock,
    /// Presenting equivocation evidence. Severity 2.5x.
    EquivocationEvidence,
    /// Attempting to censor transactions. Severity 2.0x.
    CensorshipAttempt,
    /// Committing an invalid state transition. Severity 3.0x.
    InvalidStateTransition,
}

Source line: 18.

slashing::SlashOffense::severity_multiplier

The severity multiplier applied to the base slash rate for this offense.

pub fn severity_multiplier(&self) -> f64;

Source line: 35.

slashing::SlashOffense::should_jail

Whether this offense results in jailing the validator.

pub fn should_jail(&self) -> bool;

Source line: 47.

slashing::SlashConfig

Parameters governing how slashing penalties are computed.

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SlashConfig {
/// Base fraction of total stake to slash (before severity multiplier).

/// For example, 0.05 means 5% base slash.

pub base_slash_rate: f64,
/// How much of the slash propagates to the human root.

/// 1.0 means the human root bears the FULL penalty.

pub slashing_delta: f64
}

Source line: 58.

slashing::SlashResult

The outcome of a slash computation.

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SlashResult {
/// OAS DID of the slashed validator.

pub validator_did: String,
/// OAS DID of the validator's human root.

pub human_root_did: String,
/// The offense that triggered the slash.

pub offense: SlashOffense,
/// Total micro-MINT slashed from the validator.

pub amount_slashed: u64,
/// The severity multiplier that was applied.

pub severity_multiplier: f64,
/// micro-MINT penalty charged to the human root (delta * amount_slashed).

pub human_root_penalty: u64,
/// Whether the validator should be jailed as a result of this offense.

pub jail: bool
}

Source line: 82.

slashing::compute_slash

Compute the slash amounts for a given offense.

amount_slashed = total_stake * base_slash_rate * severity_multiplier human_root_penalty = amount_slashed * slashing_delta

The amount is capped at the validator's total stake.

pub fn compute_slash(
    config: &SlashConfig,
    stake_record: &StakeRecord,
    offense: SlashOffense,
) -> SlashResult;

Source line: 109.

slashing::apply_slash

Apply a previously computed slash to a validator's stake record.

Deducts amount_slashed from self_stake (capped at self_stake), and optionally jails the validator.

pub fn apply_slash(
    stake_record: &mut StakeRecord,
    slash_result: &SlashResult,
) -> Result<(), EconomicsError>;

Source line: 138.

On this page