Switch, Peer, PeerSet, Reactor, Envelope, …).
The transport implementation under those abstractions is lib-p2p instead of comet-p2p.
lib-p2p is a widely used networking stack with production-ready peer-to-peer features,
and implementations across many languages and transport protocols (TCP, QUIC, WebSockets, and more).
You can refer to the implementation in the CometBFT codebase here:
Performance and Liveness
In high-load conditions, legacycomet-p2p can become a networking bottleneck for modern blockchain workloads:
- It is more prone to congestion under concurrent message pressure.
- Stream/message handling is less effective at scaling with traffic spikes.
- This limits end-to-end throughput when the rest of the stack is optimized.
lib-p2p integration addresses this with native stream-oriented transport, concurrent receive pipelines,
and autoscaled worker pools per reactor, which helps reduce queue pressure and improve message flow under load.
Beyond raw throughput, this also improves network liveness by making peer communication and block propagation
more resilient under sustained congestion and sudden load spikes.
In our benchmarks, together with additional performance improvements across the stack, we reached over 2000 TPS,
and lib-p2p has been one of the key unblockers enabling that result.
Differences in Transport and Peer IDs
lib-p2p uses its own peer ID format,
which is different from comet-p2p. The two formats are not compatible.
Configuration
Configurelib-p2p in the p2p.libp2p section of config.toml.
All other p2p settings are ignored except external_address and laddr.
By default, the node listens on UDP port 26656.
To validate successful configuration, check logs for:
“EXPERIMENTAL: go-libp2p transport is enabled.”
“EXPERIMENTAL: go-libp2p transport is enabled.”
persistent: ensures the peer is always (re)connected.unconditional: not affected by the max number of peers limit.private: peer is not gossiped to other peers.
Queue Scaler
The queue scaler controls reactor receive concurrency using a throughput/latency feedback loop.min_workers,max_workers: lower/upper worker bounds per reactor.threshold_latency: target processing-latency threshold.overrides: per-reactor values (case-insensitive reactor name).
Resource Manager
Resource manager mode determines connection and stream limits:default: uses libp2p autoscaled limits and sane built-in protocol caps.custom: disables most cometbft p2p limits but enforces explicitmax_peersandmax_peer_streamscaps.disabled: no limits, useful for controlled benchmarking and local testing.
- Start with
mode = "default"and observe metrics under representative load. - If limits are still unclear, run short, controlled tests with
mode = "disabled"to discover required headroom. - Move to
mode = "custom"and set conservativemax_peers/max_peer_streamscaps based on measurements. - Re-test and keep safety margin; avoid running public networks long-term in
disabledmode.
- libp2p/go-libp2p: p2p/host/resource-manager/README.md
- libp2p/go-libp2p: p2p/host/resource-manager/limit_defaults.go
Implementation Details
From the CometBFT actor-model perspective, the API stays the same:Reactor, Peer, PeerSet, Switch, and envelope flow remain compatible,
so existing reactors can run without protocol-level rewrites.
At the connection layer, lib-p2p replaces CometBFT secret connection with lib-p2p native
identity and secure handshake mechanisms.
This means peer session establishment, encryption negotiation, and remote identification are handled
by the lib-p2p transport stack.
CometBFT channel traffic is mapped to lib-p2p protocol handlers:
- Each CometBFT channel is exposed under a lib-p2p
protocol.IDnamespace (for example/p2p/cometbft/1.0.0/...). - Messages are exchanged over lib-p2p streams bound to those protocol handlers.
- Inbound handling is concurrent, with a priority FIFO queue and worker pool to process reactor traffic in parallel under load.
autopool:
- It tracks per-message processing durations and computes decisions from throughput EWMA, queue pressure, and latency percentile (P90).
- High throughput growth or queue pressure scales workers up; high P90 latency above the configured threshold triggers shrink to avoid overload.
- Default limits are 4-32 workers per reactor; mempool uses a wider range (8-512) to absorb bursty transaction traffic.
- Priority ordering is preserved before dispatch (
Receive()pushes by priority, then workers consume in parallel).
Comparison and Limitations
| Area | comet-p2p | lib-p2p |
|---|---|---|
| Transport | TCP | QUIC |
| Peer identity | Comet peer IDs (<hex>@host:port) | lib-p2p peer IDs (12D3Koo...) |
| Connection handshake | Comet secret connection | lib-p2p identity and secure handshake |
| Peer exchange | PEX + address book flow | No PEX in this release |
comet-p2p / lib-p2p network.
Metrics
Key metrics forlib-p2p queue-scaler and resource tuning: