The Tip Router Keeper is a critical component of the Jito Tip Router system that manages epoch-based operations for validators, operators, and vaults. It orchestrates the complete lifecycle of an epoch, from updating vaults, weight setting to reward distribution, ensuring proper consensus and state transitions.
The KeeperState
struct maintains all essential addresses and state information:
pub struct KeeperState {
pub epoch: u64,
pub ncn: Pubkey,
pub vaults: Vec<Pubkey>,
pub operators: Vec<Pubkey>,
pub tip_router_config_address: Pubkey,
pub vault_registry_address: Pubkey,
pub epoch_state_address: Pubkey,
// ... additional addresses and state
}
The keeper follows state machine for each epoch:
The keeper uses the progress_epoch
function to determine when to advance:
Determines which epoch the keeper should work on based on:
Collects and emits comprehensive metrics including:
Ensures all vaults are properly registered with the Global Vault Registry before processing begins.
Updates the internal state with current epoch information and account data.
Synchronizes with on-chain epoch state accounts to maintain consistency.
Executes state-specific operations based on current epoch state:
match current_state {
State::SetWeight => crank_set_weight(handler, state.epoch).await,
State::Snapshot => crank_snapshot(handler, state.epoch).await,
State::Vote => crank_vote(handler, state.epoch, test_vote).await,
State::PostVoteCooldown => crank_post_vote_cooldown(handler, state.epoch).await,
State::Distribute => crank_distribute(handler, state.epoch).await,
State::Close => crank_close_epoch_accounts(handler, state.epoch).await,
}
Provides detailed metrics for the current epoch state and progress.
Identifies when the epoch is stuck and needs to progress:
The keeper supports several operating modes:
run_operations = true
): Complete epoch managementmetrics_only = true
): Only emit metrics without state changesrun_migration = true
): Special migration operationsThe keeper implements sophisticated stall detection:
Vote
and PostVoteCooldown
statesWhen stalls are detected: