Sigil documentation
ReferenceRust referencesigil-consensus

sigil-consensus · election

Source declarations, signatures and documentation for election.

Source: sigil/node/sigil-consensus/src/election.rs. SHA-256: 8f5217b41cc4646c8307f84f489ec66817ef2c1a2e5bf94c902ed55de3574abe.

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.

election::ElectionWeights

Weights for the composite election score formula.

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ElectionWeights {
/// Weight for normalized stake component.

pub stake: f64,
/// Weight for uptime component.

pub uptime: f64,
/// Weight for OATS trust score component.

pub trust_score: f64,
/// Weight for hardware performance component.

pub hw_performance: f64,
/// Weight for participation component.

pub participation: f64
}

Source line: 20.

election::ElectionConfig

Configuration for the proposer election algorithm.

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ElectionConfig {
/// The weights for each score component.

pub weights: ElectionWeights,
/// Alpha parameter for the concentration penalty.

/// Higher values penalize stake concentration more heavily.

pub concentration_alpha: f64,
/// Maximum allowed stake fraction before the concentration penalty

/// begins to apply significantly. Validators holding more than this

/// fraction of total stake receive a logarithmic penalty.

pub max_stake_fraction: f64
}

Source line: 47.

election::compute_score

Compute the composite election score for a single validator.

The formula is:

Score = w1*(stake/total_stake) + w2*uptime + w3*trust_score
      + w4*hw_performance + w5*participation - alpha * ln(CP)

where CP = (stake / total_stake) / max_stake_fraction.

The concentration penalty uses the natural logarithm of the ratio between the validator's stake fraction and the configured maximum. When the validator's fraction is at or below the maximum, the penalty is zero or negative (i.e., a slight benefit). When it exceeds the maximum, the penalty grows logarithmically.

pub fn compute_score(validator: &Validator, config: &ElectionConfig, total_stake: u64) -> f64;

Source line: 82.

election::elect_proposer

Elect the proposer for a given block height from the validator set.

Only Block Producers are eligible to propose blocks. The selection uses a deterministic VRF-like mechanism: hash(epoch_seed || height) produces a seed that is combined with each candidate's score to deterministically select the proposer.

Returns the DID of the elected proposer, or an empty string if no Block Producers are available.

pub fn elect_proposer(
    validator_set: &ValidatorSet,
    config: &ElectionConfig,
    height: u64,
    epoch_seed: &SigilHash,
) -> String;

Source line: 119.

On this page