Proof of History (PoH)
Proof of History provides a cryptographic clock that proves the passage of time between events.PoH Overview
PoH is a sequential hash chain where each hash proves time has passed:PoH Service
The PoH service (~/workspace/source/poh/src/poh_service.rs) runs continuously:- Generates hashes in tight loop
- Records transactions as PoH “mixins”
- Produces ticks at regular intervals
- Provides entries for block production
PoH Recorder
The PohRecorder (~/workspace/source/poh/src/poh_recorder.rs:1) coordinates between PoH and banking:Working Bank
- Current bank being filled with transactions
- Min/max tick heights for this slot
- Start time for performance tracking
Recording Transactions
Transactions recorded into PoH:- Banking stage processes transaction batch
- Transaction hashes mixed into PoH
- PoH hash recorded with transactions
- Entry created with PoH hash + transactions
- Entry sent to blockstore
PoH Controller
The PohController (~/workspace/source/poh/src/poh_controller.rs) manages:- Leader schedule integration
- Tick and slot timing
- Grace period handling
- Slot completion signaling
Tower BFT Consensus
Tower BFT is the fork selection and voting consensus mechanism.Tower Structure
The consensus module (~/workspace/source/core/src/consensus.rs:1) implements Tower BFT:Vote State
Each validator maintains vote state:- Vote History - Recently voted slots
- Lockouts - Commitment to voted forks
- Root - Last finalized slot
- Last Vote - Most recent vote slot
Fork Choice
The HeaviestSubtreeForkChoice (~/workspace/source/core/src/consensus/heaviest_subtree_fork_choice.rs) selects the best fork:Selection Criteria
- Stake Weight - Total stake voting for fork
- Lockout Intervals - Validator commitments
- Optimistic Confirmation - 2/3+ stake threshold
- Switch Threshold - Required stake to change forks
Switch Fork Decision
- SameFork - Continue on current fork
- SwitchProof - Switch to different fork with proof
- FailedSwitchThreshold - Insufficient stake to switch
- FailedSwitchDuplicateRollback - Duplicate detected
Threshold Decision
- Shallow Threshold - 4 confirmations
- Deep Threshold - 8 confirmations
- Switch Threshold - 38% of stake
Vote Processing
Votes processed in cluster_info_vote_listener (~/workspace/source/core/src/cluster_info_vote_listener.rs):- Receive Votes - From gossip network
- Validate Votes - Check signature and format
- Update Vote State - Add to vote tracker
- Update Fork Weight - Recalculate stake weight
- Trigger Optimistic Confirmation - Check thresholds
Progress Map
The ProgressMap (~/workspace/source/core/src/consensus/progress_map.rs) tracks fork progress:Lockout Intervals
- Created when validator votes
- Duration doubles with each vote
- Prevents switching to conflicting forks
- Expires after sufficient confirmations
Voting Process
Vote Generation
The voting_service (~/workspace/source/core/src/voting_service.rs) generates votes:- Evaluate Fork - Check if should vote
- Create Vote - Build vote transaction
- Switch Decision - Determine if switching forks
- Submit Vote - Send to TPU
Vote Instruction
- Vote - Standard vote on slot
- VoteStateUpdate - Compact vote update
- TowerSync - Full tower state sync
Vote Stake Tracker
The vote_stake_tracker (~/workspace/source/core/src/consensus/vote_stake_tracker.rs) maintains:- Stake weight per slot
- Validator votes received
- Optimistic confirmation status
- Rooting thresholds
Replay Stage
The replay_stage (~/workspace/source/core/src/replay_stage.rs) coordinates consensus:Replay Process
- Select Fork - Use fork choice algorithm
- Replay Transactions - Execute block contents
- Verify Results - Compare against block hash
- Update Progress - Mark slot as replayed
- Generate Vote - Vote on confirmed slot
- Update Root - Move root forward if finalized
Frozen Bank Evaluation
Once bank frozen:- Compute Hash - Calculate accounts hash
- Compare Hash - Verify matches expected
- Record Vote - Add vote to progress map
- Check Thresholds - Evaluate confirmation
- Update Tower - Add slot to vote history
Optimistic Confirmation
Slots optimistically confirmed when:- 2/3+ of stake has voted
- Vote observed on fork
- No conflicting votes
- Within lockout period
- Fast transaction confirmation
- Low latency finality signaling
- Improved user experience
Finalization
Slots finalized (rooted) when:- 31 confirmations deep
- Sufficient lockouts created
- Supermajority commitment
- No conflicting forks viable
- Cleanup of old fork state
- Snapshot creation
- Ledger compaction
- Account pruning
Duplicate Detection
Consensus monitors for duplicates:- Duplicate Blocks - Multiple blocks for same slot
- Duplicate Votes - Conflicting votes from validator
- Duplicate Shreds - Conflicting shreds for slot
- Slashing (if enabled)
- Fork selection impact
- Optimistic confirmation block
Vote State Updates
Compact vote updates reduce bandwidth:- Send only vote range instead of full history
- Tower sync for full state
- Incremental updates for normal votes
Commitment Service
The commitment_service (~/workspace/source/core/src/commitment_service.rs) tracks:- Processed - Executed but not confirmed
- Confirmed - Optimistically confirmed
- Finalized - Rooted and permanent
Performance Characteristics
- Fast Confirmation - 400-600ms for optimistic
- Finality - 12-13 seconds for root
- Fork Recovery - Automatic rollback on invalid fork
- Network Partition - Recovers with majority stake
Key Files
- Consensus: ~/workspace/source/core/src/consensus.rs
- PoH Recorder: ~/workspace/source/poh/src/poh_recorder.rs
- PoH Service: ~/workspace/source/poh/src/poh_service.rs
- Replay Stage: ~/workspace/source/core/src/replay_stage.rs
- Voting Service: ~/workspace/source/core/src/voting_service.rs