Module elector

Module elector 

Source
Expand description

Leader election strategies for simplex consensus.

This module provides the Config and Elector traits for customizing how leaders are selected for each consensus round, along with built-in implementations.

§Built-in Electors

  • RoundRobin/RoundRobinElector: Deterministic rotation through participants based on view number. Optionally shuffled using a seed. Works with any signing scheme.

  • Random/RandomElector: Uses randomness derived from BLS threshold signatures for unpredictable leader selection. Falls back to round-robin for the first view (no certificate available). Only works with bls12381_threshold.

§Custom Electors

Applications can implement Config and Elector for custom leader selection logic such as stake-weighted selection or other application-specific strategies.

§Usage

This module uses a type-state pattern to ensure correct usage:

  1. Users create an elector Config (e.g., RoundRobin)
  2. The config is passed to the consensus configuration
  3. Consensus calls Config::build internally with the correct participants
  4. The resulting Elector can only be created by consensus, preventing misuse

Structs§

Random
Configuration for leader election using threshold signature randomness.
RandomElector
Initialized random leader elector using threshold signature randomness.
RoundRobin
Configuration for round-robin leader election.
RoundRobinElector
Initialized round-robin leader elector.

Traits§

Config
Configuration for creating an Elector.
Elector
An initialized elector that can select leaders for consensus rounds.