Overview
The gossip implementation uses a Conflict-free Replicated Data Store (CRDS) to propagate information across the cluster.Key Concepts
From ~/workspace/source/gossip/src/cluster_info.rs:1:Network Topology
The network is arranged in layers (~/workspace/source/gossip/src/cluster_info.rs:8):- Layer 0 - Leader node
- Layer 1 - As many nodes as can fit (up to 2^10)
- Layer 2 - Everyone else (up to 2^20 nodes)
- Limits broadcast fan-out
- Reduces network congestion
- Scales to large clusters
- Prioritizes stake-weighted nodes
CRDS (Cluster Replicated Data Store)
The CRDS (~/workspace/source/gossip/src/crds.rs:1) stores all gossip data:Data Organization
CRDS Value Types
- ContactInfo - Node network addresses
- Vote - Validator votes
- LowestSlot - Oldest available slot
- SnapshotHashes - Available snapshots
- EpochSlots - Slots seen in epoch
- DuplicateShred - Duplicate detection
Merge Strategy
Values updated using last-write-wins:- Compare wallclock timestamps
- If equal, compare value hashes
- Keep newer/greater value
- Discard older value
Contact Info
Contact info (~/workspace/source/gossip/src/contact_info.rs) contains node network details:Socket Types
- Gossip - Cluster information exchange
- TPU (Transaction Processing Unit) - Transaction forwarding
- TPU Forward - Transaction forwarding to next leader
- TVU (Transaction Validation Unit) - Shred reception
- TVU Forward - Shred forwarding
- Repair - Missing shred requests
- Serve Repair - Serve repair requests
- RPC - Client RPC requests
Gossip Messages
Push Messages
Nodes push new data to random peers:- Select Data - Choose recent updates
- Select Peers - Pick random stake-weighted peers
- Send Push - Broadcast data to peers
- Track Duplicates - Avoid resending same data
Pull Messages
Nodes pull missing data from peers:- Create Filter - Bloom filter of known data
- Send Request - Request data matching filter
- Receive Response - Get filtered data
- Merge Data - Update local CRDS
Prune Messages
Nodes prune redundant connections:- Track Origins - Note push message sources
- Identify Duplicates - Find redundant paths
- Send Prune - Request to stop forwarding
- Update Topology - Adjust gossip graph
Peer Discovery
Entrypoint Discovery
- Connect to Entrypoint - Bootstrap with known node
- Pull Cluster Info - Get full cluster state
- Update ContactInfo - Merge into local CRDS
- Start Gossip - Begin push/pull protocol
Spy Nodes
Spy nodes observe without participating:- Don’t publish contact info
- Only pull, never push
- Used for monitoring
- Don’t forward transactions
Cluster Communication
Vote Propagation
Votes gossiped for consensus:- Receive Vote - From voting service
- Create CrdsValue - Wrap in gossip message
- Push to Cluster - Broadcast via gossip
- Update Progress - Track vote propagation
Epoch Slots
Validators share observed slots:- Track which slots validator saw
- Detect network partitions
- Identify missing blocks
- Coordinate replay
Snapshot Hashes
Nodes advertise available snapshots:- Full snapshot hashes
- Incremental snapshot hashes
- Download availability
- Snapshot gossip for fast sync
Shred Version
Shred version isolates incompatible networks:- Computed from genesis hash
- Prevents cross-network communication
- Identifies testnet vs mainnet
- Enforced at network layer
Gossip Service
The gossip service runs several threads:Listen Thread
Receives incoming gossip packets:- Read Socket - Receive UDP packets
- Deserialize - Parse gossip messages
- Process - Handle push/pull/prune
- Update CRDS - Merge new data
Respond Thread
Responds to pull requests:- Receive Request - Get pull request
- Filter Data - Apply bloom filter
- Create Response - Package matching data
- Send Response - Return filtered values
Gossip Thread
Generates outgoing gossip:- Push Messages - Send recent updates
- Pull Requests - Request missing data
- Prune Messages - Optimize topology
- Ping/Pong - Check peer liveness
Weighted Shuffle
Peer selection uses stake-weighted shuffle:- Faster propagation to high-stake nodes
- Better network utilization
- Improved consensus latency
- Sybil resistance
Duplicate Shred Detection
Gossip propagates duplicate shred alerts:- Detect Duplicate - Find conflicting shreds
- Create Proof - Bundle both shreds
- Gossip Duplicate - Broadcast to cluster
- Slash Validator - Penalize producer (if enabled)
Cluster Slots Service
The cluster_slots_service (~/workspace/source/core/src/cluster_slots_service.rs) tracks:- Slots observed by cluster
- Validator slot completion
- Network partition detection
- Repair prioritization
Ping/Pong Protocol
Nodes ping peers to check liveness:- Send Ping with random token
- Peer responds with Pong echoing token
- Verify signature and token
- Update peer last-seen time
- Remove unresponsive peers
Gossip Filters
Bloom filters optimize pull protocol:- Contain Local Data - Keys of known values
- Size Based on Set Size - Scales with data
- False Positive Rate - Tuned for bandwidth
- Prevents Redundant Sends - Only send new data
Timeouts
Gossip enforces timeouts:- CRDS Timeout - Remove old values (10 minutes)
- Gossip Timeout - Consider peer dead (60 seconds)
- Stake Timeout - Unstaked node timeout (shorter)
Security
Signature Verification
All gossip messages signed:- Verify sender identity
- Prevent spoofing
- Ensure data authenticity
Stake Weighting
Stake weight determines:- Gossip peer selection probability
- Value retention priority
- Network partition resolution
Rate Limiting
Prevent gossip spam:- Limit messages per peer
- Drop excessive push attempts
- Prune aggressive pushers
Performance Optimizations
Sharding
CRDS sharded for parallelism (~/workspace/source/gossip/src/crds.rs:56):LRU Caching
Recent values cached:- Faster lookup for hot data
- Reduces lock contention
- Better cache locality
Batch Processing
Gossip processed in batches:- Amortize lock overhead
- Better throughput
- Reduced latency variance
Network Partition Recovery
Gossip enables partition recovery:- Detect Partition - Missing cluster nodes
- Pull Aggressively - Request all data
- Reconcile State - Merge CRDS data
- Resume Consensus - Continue with majority
Key Files
- Cluster Info: ~/workspace/source/gossip/src/cluster_info.rs
- CRDS: ~/workspace/source/gossip/src/crds.rs
- Contact Info: ~/workspace/source/gossip/src/contact_info.rs
- CRDS Gossip: ~/workspace/source/gossip/src/crds_gossip.rs
- Weighted Shuffle: ~/workspace/source/gossip/src/weighted_shuffle.rs