rialo-stake-cache-interface 0.3.0-alpha.0

Shared types for the Stake Cache used by svm-execution and program-runtime
Documentation

Shared types for the Stake Cache.

This crate provides types that are shared between svm-execution and rialo-s-program-runtime, allowing builtin programs to access and manipulate stake cache data during transaction execution.

Reward Distribution Flow

The reward distribution follows a specific flow:

  1. FreezeStakes: At epoch boundary, push pending to frozen (creates epoch snapshot)
  2. DistributeRewards: Creates EpochRewards account (initially inactive/queued)
  3. Activation: When EpochRewards becomes active:
    • pop_front_and_merge_to_baseline() is called
    • frozen.front() is merged into baseline
    • Rewards are calculated from baseline only
  4. Distribution: Rewards distributed across partitions
  5. Completion: EpochRewards marked inactive

Reward Eligibility

Stakes are eligible for rewards based on the following checks:

  • activation_requested.is_some() → stake was activated
  • deactivation not yet effective (timestamp-based check against epoch boundary)
  • validator.is_some() → stake is delegated to a validator

Lookup Methods

Different lookup methods for different use cases:

  • From Pending (get_*_from_pending): Includes next epoch changes
  • From Last Frozen (get_*_from_last_frozen): Current epoch's effective state
  • From First Frozen (get_*_from_first_frozen): Oldest pending rewards epoch
  • From Baseline (get_*_from_baseline): Post-merge state for reward calculation