Networking
libp2p host, gossip, sync, and direct messaging
XE is a fully peer-to-peer network with no central servers. All node communication -- block propagation, consensus voting, synchronization, marketplace negotiation, and peer discovery -- happens over direct connections between nodes using libp2p.
Components
| Component | Purpose | Protocol / mechanism |
|---|---|---|
| Host | TCP transport, connection management, persistent identity | libp2p core |
| GossipSub | Broadcast blocks, votes, marketplace, statechain, directory, certificates | libp2p GossipSub |
| Sync | Frontier-based block synchronization | /xe/sync/1.0.0 stream |
| Messaging | Request-response over streams | /xe/msg/1.0.0 stream |
| DHT | Kademlia peer discovery | /xe prefixed DHT |
| Netcheck | Network-ID and version handshake on connect | /xe/netcheck/1 stream |
| Tunnel | SSH-over-network to a leased VM | /xe/tunnel/2.0.0 stream |
| State chain sync | Governance chain catch-up | /xe/statechain-sync/1.0.0 stream |
Architecture Overview
┌──────────────────────────────────────────────────────────┐
│ Node │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
│ │ Ledger │ │ State Chain │ │ Directory │ │
│ └──────┬──────┘ └──────┬──────┘ └───────┬─────────┘ │
│ │ │ │ │
│ ┌──────┴────────────────┴──────────────────┴─────────┐ │
│ │ Network Layer (net package) │ │
│ │ │ │
│ │ ┌──────────┐ ┌──────┐ ┌──────────┐ ┌───────────┐ │ │
│ │ │ GossipSub│ │ Sync │ │Messenger │ │ DHT │ │ │
│ │ └────┬─────┘ └──┬───┘ └────┬─────┘ └─────┬─────┘ │ │
│ └───────┼──────────┼──────────┼──────────────┼───────┘ │
│ │ │ │ │ │
│ ┌───────┴──────────┴──────────┴──────────────┴───────┐ │
│ │ libp2p Host (TCP transport) │ │
│ └────────────────────────┬───────────────────────────┘ │
└───────────────────────────┼──────────────────────────────┘
│
TCP / InternetHow Data Flows
Block Propagation
- A node creates a new block (send, receive, lease, burn, etc.)
- The block is added to the local ledger
- The block is published via GossipSub on the
xe/blockstopic - All subscribed peers receive the block, validate it, and add it to their ledgers
- Representatives vote on the block's chain position and broadcast those votes on
xe/votes
Synchronization
When a new node joins or reconnects after downtime, it uses the sync protocol to catch up:
- On connection to a peer, the node sends its current frontiers (latest block per account)
- The peer compares frontiers and streams back any missing blocks
- A background loop ticks every 10 seconds, but only opens streams when local state has changed — with a forced full re-sync every 60 seconds as a safety net
[!NOTE] Sync carries blocks, not finality The frontier-sync protocol transfers block bodies. It does not transfer finalization state, which is why a node that fell behind may additionally need to pull votes for a position it cannot resolve locally.
Peer-to-Peer Messaging
The messaging protocol provides request-response semantics for targeted communication:
- VM credential delivery and status queries between provider and consumer
- Timekeeper attestation requests
- Account-to-account chat
- Targeted pulls: a missing block body by hash, the votes at a stuck position, a peer's provider certificates
Discovery Mechanisms
Peers find each other through three mechanisms:
- mDNS -- Automatic local network discovery. Nodes on the same LAN find each other without configuration.
- Bootstrap peers -- Explicit peer addresses passed via
xe node --dial. A watchdog re-dials any disconnected bootstrap peer every 30 seconds for the lifetime of the node. - Kademlia DHT -- Distributed hash table for discovering peers by their peer ID. Used by the Messenger to locate peers not already in the peerstore.
[!INFO] No Central Infrastructure XE has no tracker servers, seed nodes, or central coordination points. Any node can bootstrap from any other node. The DHT protocol prefix
/xeisolates the XE network from public IPFS DHT traffic.
Security Properties
- Transport encryption: libp2p provides encrypted connections by default (Noise or TLS 1.3)
- Peer identity: Each node has a persistent Ed25519 identity key, giving it a stable peer ID across restarts
- Network-ID handshake:
/xe/netcheck/1checks the peer's network ID and version on connect; a mismatch bans the peer for a bounded period - Message validation: GossipSub pre-validates field lengths before accepting messages, and vote signatures are verified before a vote can touch dedup state
- Rate limiting: The sync protocol enforces a 5-second cooldown per peer, per direction
- Per-IP connection limits: The libp2p resource manager caps inbound connections per source IP (default 8,
--max-conns-per-ip), with loopback exempt - Size limits: All protocols enforce maximum message sizes to prevent memory exhaustion
Source Code
The networking layer lives in the net/ package of xeprotocol/core:
| File | Contents |
|---|---|
host.go | Host creation, resource manager, mDNS discovery, peer dialing |
gossip.go | GossipSub for all broadcast topics |
sync.go | Frontier-based block synchronization |
msg.go | Request-response messaging protocol |
dht.go | Kademlia DHT setup |
messages.go | Wire format types for gossip and sync |
blocksync.go | Targeted block-by-hash pull (block_request) |
votesync.go | Targeted vote-by-position pull (vote_request) |
certsync.go | Provider certificate exchange (cert_request) |
netcheck.go | Network-ID and version handshake, peer banning |
tunnel.go | SSH-over-network tunnel streams |