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:
- FreezeStakes: At epoch boundary, push pending to frozen (creates epoch snapshot)
- DistributeRewards: Creates EpochRewards account (initially inactive/queued)
- 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
- Distribution: Rewards distributed across partitions
- 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