Architecture Overview
SSV’s networking stack is built on libp2p, a modular P2P framework used by protocols like Ethereum, IPFS, and Filecoin. The architecture consists of several key layers:Networking Stack
- Transport: TCP (default port 12001) and UDP (default port 13001)
- Security: Noise protocol for encrypted channels
- Multiplexing: yamux for multiple protocol streams
- Discovery: discv5 for peer discovery
- Messaging: GossipSub v1.1 for pubsub, streams for request/response
Transport Layer
Secure Transport
All SSV network communication is encrypted using the Noise Protocol:- Handshake: XX pattern provides mutual authentication
- Encryption: ChaCha20-Poly1305 authenticated encryption
- Forward Secrecy: New session keys for each connection
- Identity Verification: Based on libp2p peer IDs
go-libp2p-noise library
Connection Multiplexing
yamux (Yet Another Multiplexer) enables multiple logical streams over a single TCP connection:- Operators can run consensus, sync, and other protocols simultaneously
- Reduces connection overhead and NAT traversal complexity
- Flow control prevents any single stream from monopolizing bandwidth
- Open one TCP connection per peer, not per protocol
- Efficient resource usage for operators with hundreds of validators
- Better performance in restricted network environments
Peer Discovery
discv5 Overview
SSV uses discv5 (Discovery v5), Ethereum’s node discovery protocol, for finding and connecting to other operators:discv5 is a standalone UDP-based protocol that maintains a Kademlia-style DHT (Distributed Hash Table) for storing and discovering peer records (ENRs).
- DHT Routing: Kademlia-based peer organization by XOR distance
- ENR Storage: Ethereum Node Records contain peer metadata
- Topic Discovery: Find peers by subnet subscriptions
- Security: Encrypted discovery queries prevent passive eavesdropping
network/discovery/dv5_service.go
Ethereum Node Records (ENR)
Each SSV operator publishes an ENR containing network metadata:network/discovery/node_record.go
Bootnode Discovery
Bootnodes are public peers with static ENRs that help new operators join the network:- Role: Provide initial peer list to newcomers
- Configuration: ENRs hardcoded in node configuration or provided via flags
- Operation: Only run discv5, no libp2p host (lightweight)
- New operator starts with bootnode ENR(s)
- Queries bootnode for random peers via discv5
- Connects to discovered peers
- Begins discovering more peers through the DHT
- Operated by SSV Labs and community members
- Distributed geographically for resilience
- Configured per network (mainnet, holesky, etc.)
Subnet-based Discovery
SSV operators advertise which subnets they participate in via thesubnets ENR field:
- Operator determines required subnets based on validators
- Publishes subnet subscriptions in ENR
- Searches DHT for peers with overlapping subnets
- Prioritizes connecting to peers with common subnets
network/discovery/subnets.go
Subnets and Topics
Subnet Architecture
To scale beyond tens of thousands of validators, SSV partitions the network into 128 subnets (mainnet):Why Subnets?
Problem: Having one topic per validator creates O(validators) topics, which doesn’t scale.Solution: Hash validators to deterministic subnets, reusing topics across multiple validators.Benefit: O(√validators) topics with balanced distribution.
Validator to Subnet Mapping
Deterministic hash-based mapping:- Deterministic: Same validator always maps to the same subnet
- Uniform Distribution: Hash function distributes validators evenly
- Fixed Size: 128 subnets on mainnet (configurable per network)
network/commons/subnets.go
GossipSub Topics
Each subnet corresponds to a GossipSub topic where consensus messages are broadcast: Topic Naming:bloxstaking.ssv.0- Subnet 0 topicbloxstaking.ssv.47- Subnet 47 topicbloxstaking.ssv.127- Subnet 127 topic
Topic Subscriptions
Operators subscribe to topics based on their validators:- Query Validators: Operator checks which validators it manages
- Determine Subnets: Map each validator pubkey to subnet
- Subscribe: Join corresponding GossipSub topics
- Update ENR: Publish subnet subscriptions for discovery
- When a validator is added, subscribe to its subnet topic
- When a validator is removed, unsubscribe if no other validators use that subnet
- Maintain minimum subnet subscriptions for network health
network/p2p/p2p_pubsub.go
Message Propagation
GossipSub v1.1
SSV uses GossipSub v1.1, a pubsub protocol optimized for adversarial environments:GossipSub balances reliability, efficiency, and resilience by maintaining a mesh overlay for each topic and using gossip to disseminate messages quickly.
- Each operator maintains a mesh of 6-12 peers per topic (configurable)
- Full messages exchanged with mesh peers
- Provides redundancy and fast propagation
- Peers outside the mesh receive metadata (message IDs) only
- Can request full messages if interested (IWANT/IHAVE protocol)
- Reduces bandwidth while maintaining awareness
Message Validation
Before relaying messages, operators perform topic-level validation: Validation Stages:- Structural Validation: Verify protobuf encoding and required fields
- Signature Verification: Check operator signatures on consensus messages
- Subnet Check: Ensure message belongs to the topic
- Slashing Check: Verify message won’t cause slashable offense
ACCEPT: Valid message, propagate to meshREJECT: Invalid message, penalize sender, don’t relayIGNORE: Don’t process or relay, but don’t penalize sender
network/p2p/p2p_pubsub.go
Message Deduplication
Message ID Function: GossipSub uses message IDs to deduplicate:- Same logical message from different peers has the same ID
- Duplicate messages are ignored automatically
- Reduces redundant processing and network traffic
- Recent message IDs stored in LRU cache
- TTL-based expiration (typically 2-3 heartbeat intervals)
- Prevents replay of old messages
network/p2p/p2p_pubsub.go:426
Peer Scoring
GossipSub Scoring
Peer scoring protects the network from malicious or misbehaving operators:Scoring Components
- Topic Participation: Rewards active, useful peers
- Message Delivery: Penalizes peers sending invalid messages
- Behavior: Tracks grafts, prunes, and IWANT/IHAVE patterns
- Application-Specific: Custom scoring based on consensus message validity
| Threshold | Value | Effect |
|---|---|---|
| Gossip Threshold | -4000 | Below this, no gossip sent to peer |
| Publish Threshold | -8000 | Below this, no messages accepted from peer |
| Graylist Threshold | -16000 | Below this, peer completely ignored |
| Accept PX Threshold | 100 | Above this, accept peer exchange (PX) |
Consensus Scoring
Application-specific scoring based on consensus message validation: Scoring Events:Accept: Valid consensus message (+5 to +10)RejectLow: Minor issue, late message (-10 to -20)RejectMedium: Wrong height or round (-50 to -100)RejectHigh: Invalid signature, slashable (-500 to -1000)
- Validation happens in duty processing (outside pubsub)
- Results reported via validator result channel
- Applied during pubsub heartbeat (every 1 second)
network/p2p/p2p_pubsub.go (score functions)
Connection Gating
ConnectionGater prevents connections from bad peers:- Block peers with score below graylist threshold
- IP-based rate limiting (max connections per IP)
- Prevent reconnection attempts from pruned peers (backoff)
network/commons/gater.go
Sync Protocols
For historical data and catching up, SSV uses stream-based sync protocols (not pubsub):1. Highest Decided
Protocol ID:/ssv/sync/decided/highest/0.0.1
Purpose: Query the highest decided consensus message for a validator
Use Case: New operator joining a validator needs to know the latest state
Request:
2. Decided History
Protocol ID:/ssv/sync/decided/history/0.0.1
Purpose: Query historical decided messages in a range
Use Case: Exporter nodes collecting network data, audit logs
Request:
History sync is optional. Only full nodes and exporters run this protocol. Standard operators don’t save historical decided messages to conserve storage.
protocol/v2/sync/
Network Security
Sybil Resistance
Mechanisms:- Operator Registration: Operators must register on-chain (stake SSV tokens)
- Reputation Scoring: New peers start with neutral score, build reputation over time
- Connection Limits: Max peers per operator prevents resource exhaustion
- Subnet Diversity: Validators distributed across subnets limits Sybil impact
Eclipse Attack Prevention
Strategies:- Diverse Discovery: Multiple bootnodes, DHT random walk
- Subnet-based Routing: Ensures connection to committee members
- Peer Exchange (PX): Learn about new peers from trusted connections
- Outbound Connection Preference: Maintain ratio of outbound to inbound connections
DDoS Mitigation
Defenses:- Rate Limiting: Max messages per peer per second
- Connection Limits: Max total connections, max per IP
- Early Validation: Reject malformed messages at transport layer
- Backoff: Exponential backoff for failing peers
- Graylist: Completely ignore peers below threshold
Performance Characteristics
Latency
Message Propagation:- Intra-subnet: 100-500ms (mesh peer to mesh peer)
- Cross-subnet: N/A (validators don’t share topics)
- Consensus: 1-2 seconds (includes validation + propagation)
- Geographic distribution of operators
- Network congestion and packet loss
- Peer mesh connectivity
Bandwidth
Per Operator Estimates (128 subnets, 10,000 validators):- Consensus Messages: ~50-200 KB/s per subnet (depends on validator count)
- Gossip Overhead: ~20-50% additional (IHAVE/IWANT/PX)
- Discovery: ~5-10 KB/s (discv5 queries, ENR updates)
Scalability
Current Limits:- Subnets: 128 (mainnet), can be increased in future forks
- Validators per Subnet: ~78 (10,000 / 128)
- Message Rate: Scales with validator count per subnet
- Message aggregation (combine PREPARE/COMMIT from multiple signers)
- Partial message propagation (only send deltas)
- Adaptive subnet sizing based on network growth
Network Types
SSV supports different node types with varying responsibilities:Operator Node
- Full consensus participation: Runs QBFT for validators
- Subnet subscriptions: Subscribes to relevant validator subnets
- Sync protocol: Supports highest-decided sync
- Storage: Validator shares, latest decided messages
- Ports: TCP 12001, UDP 13001
Exporter Node
- Passive observation: Listens to all subnets
- No consensus: Doesn’t participate in QBFT
- Full history: Stores historical decided messages
- Sync protocol: Supports decided-history sync
- Use Case: Network monitoring, analytics, explorers
Bootnode
- Discovery only: Runs discv5 UDP service
- No libp2p: Doesn’t open TCP connections
- Static ENR: Publicly known, stable address
- Lightweight: Minimal resource requirements
Implementation Reference
Key files for networking implementation:| Component | File Path |
|---|---|
| P2P Host Setup | network/p2p/p2p_setup.go |
| GossipSub Config | network/p2p/p2p_pubsub.go |
| Discovery Service | network/discovery/dv5_service.go |
| ENR Management | network/discovery/node_record.go |
| Subnet Utils | network/commons/subnets.go |
| Connection Gater | network/commons/gater.go |
| Sync Protocols | protocol/v2/sync/ |
Next Steps
Consensus Mechanism
Understand QBFT consensus running over this network
Validator Duties
Learn what messages are propagated through the network
