P2P Networking
How Terp Network nodes communicate — CometBFT, peer discovery, gossip protocol, network topology
P2P Networking
Terp Network uses CometBFT (formerly Tendermint Core) for peer-to-peer networking. Nodes discover each other, gossip transactions and blocks, and maintain the network topology without central coordination.
CometBFT P2P Layer
Every Terp Network node runs a CometBFT P2P node that:
- Discovers peers — via seed nodes, persistent peers, and peer exchange (PEX)
- Gossips transactions — transactions broadcast across the network until included in a block
- Propagates blocks — new blocks are rapidly distributed to all nodes
- Maintains connections — nodes maintain a configurable number of outbound and inbound peers
Peer Discovery
Nodes find each other through:
- Seed nodes — well-known, stable nodes that provide initial peer lists
- Persistent peers — explicitly configured peers to always connect to
- PEX (Peer Exchange) — nodes share peer addresses they know about
# config.toml
[p2p]
seeds = "id@host:26656,id@host:26656"
persistent_peers = "id@host:26656"
pex = truePeer Addressing
Peers are identified by their node ID (first 20 bytes of the node's Ed25519 public key, hex-encoded) and IP address:
<node-id>@<host>:<p2p-port>The default P2P port is 26656.
Network Topology
Terp Network recommends a sentry node architecture for validators:
- Validator node — private, only connects to sentry nodes
- Sentry nodes — public, connect to the wider network, relay traffic to the validator
- Full nodes — public, sync chain state, serve RPC queries
Internet
┌─────┴─────┐
Sentry 1 Sentry 2 ← public, DDoS-resistant
└────┬─────┘
Validator ← private, only sentry peersSentry architecture diagram scaffold — a network diagram showing validator behind sentry nodes, with client connections to sentries and sentries connecting to the wider P2P network.
Transaction Gossip
When a transaction is broadcast to a node:
- Node validates the tx (signature, fee, nonce)
- Tx is added to the mempool
- Node gossips the tx to its peers
- Peers validate and relay further
- Eventually a validator includes the tx in a block
Block Propagation
When a validator produces a block:
- Block is proposed via consensus messages (Proposal, Prevote, Precommit)
- Validators gossip their votes
- Once +2/3 precommits received, the block is committed
- The block is gossiped to all nodes via the P2P layer
Block propagation sequence scaffold — a sequence diagram showing how a block moves from proposer validator through consensus rounds to all full nodes.
Key Configurations
| Parameter | Default | Description |
|---|---|---|
max_peers | 50 | Maximum outbound + inbound peers |
flush_throttle_timeout | 100ms | Peer send throttle |
send_rate | 5120000 | Bytes/sec per connection |
recv_rate | 5120000 | Bytes/sec per connection |
max_tx_bytes | 1MB | Maximum tx size in bytes |
Further Reading
- Node setup guide — configure P2P for your node
- Sentry node guide — DDoS-resistant topology
- CometBFT P2P docs — full specification