Purpose and Scope
This document provides an overview of StableNet’s peer-to-peer networking subsystem, which handles node discovery, peer connection management, blockchain synchronization, and message propagation.The networking layer is built on Ethereum’s DevP2P protocol stack and implements the
eth protocol for block and transaction exchange.
For detailed information on specific networking components, refer to the following documents:
- Connection lifecycle and peer tracking: P2P Server and Peer Management
- Node discovery mechanisms and peer compatibility: Discovery and Fork ID
- Blockchain download and synchronization strategies: Chain Synchronization
- Message routing and protocol version management: Protocol Handlers
For block production and broadcasting, see Block Production and Mining.
Networking Architecture Overview
StableNet’s networking layer consists of four major subsystems that work together to maintain network connectivity and synchronize blockchain state.P2P Server
p2p.Server is the foundation of the networking stack and manages the lifecycle of all peer connections.It coordinates peer discovery, connection establishment, protocol negotiation, and graceful disconnection. The server maintains different categories of peers:
- Dynamic peers: Discovered through DHT mechanisms and subject to connection limits
- Static peers: Preconfigured nodes that are always reconnected upon disconnection
- Trusted peers: Nodes that bypass
MaxPeerslimits and receive priority treatment
The server runs a main event loop that handles:
- Peer connection setup stages
- Peer disconnection processing
- Dynamic updates to the trusted peer list
- Thread-safe access to the peer set
Peer Discovery
StableNet supports multiple peer discovery mechanisms that can operate simultaneously:
Discovery services forward candidate peers to the
dialScheduler and apply the following policies:
- Maintain inbound/outbound connection ratios
- Prevent duplicate dials
- Apply exponential backoff for failed connections
- Relax limits for trusted peers
Fork ID Validation
Before establishing full peer relationships, nodes exchange fork IDs (EIP-2124) to verify chain compatibility.The fork ID is computed based on the genesis hash and upcoming fork block numbers:
Chain Synchronization
The chain synchronization subsystem downloads and verifies blockchain data from peers.This system operates through the collaboration of multiple components. Diagram: Synchronization component interaction
Synchronization Modes
StableNet supports the following synchronization modes depending on node state:Downloader
The downloader performs the following tasks:- Common ancestor block discovery
- Skeleton chain construction
- Parallel data downloads
- Memory-based queue limiting
- Chain insertion after verification
Protocol Handlers
Protocol handlers bridge the P2P layer and blockchain logic and are responsible for routing messages. Diagram: Protocol handler message flowProtocol Version Management
StableNet implements theeth/68 protocol.During the handshake, protocol version and chain information are exchanged:
Message Handling
Request/response messages:- GetBlockHeaders / BlockHeaders
- GetBlockBodies / BlockBodies
- GetReceipts / Receipts
- GetPooledTransactions / PooledTransactions
- NewBlock
- NewBlockHashes
- Transactions
- NewPooledTransactionHashes
Peer Management
Each peer goes through the following lifecycle:- Discovery
- Dialing
- Encryption handshake
- Protocol handshake
- Registration
- Message exchange
- Disconnection
eth layer handles blockchain logic.
Peer Reputation
The downloader continuously tracks peer performance:- Header processing capacity
- Body processing capacity
- Receipt processing capacity
- Round-trip latency
Network Security
The networking layer includes the following security mechanisms:
Peers may be disconnected due to protocol violations, excessive resource usage, or compatibility issues.

