Sigil documentation
ReferenceRust referencesigil-economics

sigil-economics · staking

Source declarations, signatures and documentation for staking.

Source: sigil/node/sigil-economics/src/staking.rs. SHA-256: 4f07a1633f16d77f266547e9be06b2ff2da63149a988bd46e806c0fc2bcdc605.

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.

staking::MIN_BP_STAKE

Minimum self-stake for a Block Producer: 10,000 MINT = 10_000_000_000 micro-MINT.

pub const MIN_BP_STAKE: u64;

Source line: 11.

staking::MIN_BV_STAKE

Minimum self-stake for a Block Validator: 1,000 MINT = 1_000_000_000 micro-MINT.

pub const MIN_BV_STAKE: u64;

Source line: 14.

staking::UNBONDING_EPOCHS

Number of epochs a validator must wait after initiating unstake.

pub const UNBONDING_EPOCHS: u64;

Source line: 17.

staking::StakeRecord

A validator's stake record.

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

pub validator_did: String,
/// OAS DID of the human root that spawned this validator.

pub human_root_did: String,
/// Lineage generation (0 = human root itself, 1 = direct child, ...).

pub generation: u32,
/// micro-MINT staked by the validator itself.

pub self_stake: u64,
/// micro-MINT delegated to this validator by others.

pub delegated_stake: u64,
/// Whether this validator produces blocks or only validates them.

pub mode: ValidatorMode,
/// Current lifecycle status.

pub status: StakeStatus,
/// Epoch at which unbonding completes (set when unbonding begins).

pub unbonding_epoch: Option<u64>
}

Source line: 25.

staking::StakeRecord::total_stake

Total stake = self-stake + delegated stake.

pub fn total_stake(&self) -> u64;

Source line: 46.

staking::StakeRecord::meets_minimum

Whether the validator's self-stake meets the mode-specific minimum.

pub fn meets_minimum(&self) -> bool;

Source line: 51.

staking::StakeRecord::can_unstake

Whether the validator is in a state that allows unstaking.

pub fn can_unstake(&self) -> bool;

Source line: 57.

staking::StakeStatus

Current lifecycle status of a validator.

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum StakeStatus {
    /// Validator is active and participating in consensus.
    Active,
    /// Validator has initiated unstake; waiting for unbonding period.
    Unbonding,
    /// Unbonding complete; funds are free.
    Unbonded,
    /// Validator is jailed (e.g., for double-signing).
    Jailed,
}

Source line: 64.

staking::Delegation

A delegation from a delegator to a validator.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Delegation {
/// OAS DID of the delegator.

pub delegator_did: String,
/// OAS DID of the validator receiving delegation.

pub validator_did: String,
/// micro-MINT delegated.

pub amount: u64,
/// Epoch at which this delegation started.

pub start_epoch: u64,
/// If set, the delegator is withdrawing some portion.

pub pending_undelegation: Option<PendingUndelegation>
}

Source line: 81.

staking::PendingUndelegation

An in-progress undelegation.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PendingUndelegation {
/// micro-MINT being undelegated.

pub amount: u64,
/// Epoch when undelegation completes.

pub completion_epoch: u64
}

Source line: 96.

staking::min_stake_for_mode

Returns the minimum self-stake for the given validator mode.

pub fn min_stake_for_mode(mode: &ValidatorMode) -> u64;

Source line: 108.

staking::apply_stake_deposit

Deposit additional stake into a validator record.

Returns an error if the validator is jailed or unbonding.

pub fn apply_stake_deposit(record: &mut StakeRecord, amount: u64) -> Result<(), EconomicsError>;

Source line: 118.

staking::apply_unstake

Begin the unstaking process for a validator.

Reduces self-stake by amount and sets status to Unbonding if the remaining self-stake no longer meets the mode minimum. Otherwise the validator stays Active but the amount is still deducted.

pub fn apply_unstake(
    record: &mut StakeRecord,
    amount: u64,
    current_epoch: u64,
) -> Result<(), EconomicsError>;

Source line: 146.

staking::apply_delegation

Add delegation to an existing delegation record.

pub fn apply_delegation(delegation: &mut Delegation, amount: u64) -> Result<(), EconomicsError>;

Source line: 180.

staking::apply_undelegation

Begin undelegation of amount from a delegation.

Subtracts amount from the delegation's active balance and sets a pending undelegation record.

pub fn apply_undelegation(
    delegation: &mut Delegation,
    amount: u64,
    current_epoch: u64,
) -> Result<(), EconomicsError>;

Source line: 197.

staking::complete_unbonding

Complete unbonding for a validator if the unbonding epoch has passed.

Returns Some(freed_amount) if the unbonding is complete and the record transitions to Unbonded. Returns None if the record is not unbonding or the epoch has not yet arrived.

pub fn complete_unbonding(record: &mut StakeRecord, current_epoch: u64) -> Option<u64>;

Source line: 233.

On this page