Skip to content
Cosmopediaby Unity Nodes
DocumentationCometBFT specificationcometbft/cometbft › spec › p2p › implementationView on CometBFT specification ↗

Implementation of the p2p layer

Implementation of the p2p layer

This section documents the implementation of the peer-to-peer (p2p) communication layer in CometBFT.

The documentation was produced using the v0.34.* releases and the branch v0.34.x of this repository as reference. As there were no substantial changes in the p2p implementation, the documentation also applies to the releases v0.37.* and v0.38.* [^v35].

refactoring of the p2p layer implementation, were discontinued.

Contents

The documentation follows the organization of the p2p package, which implements the following abstractions:

  • Transport: establishes secure and authenticated connections with peers;
  • Switch: responsible for dialing peers and accepting connections from peers, for managing established connections, and for routing messages between the reactors and peers, that is, between local and remote instances of the CometBFT protocols;
  • PEX Reactor: due to the several roles of this component, the documentation is split in several parts:
    • Peer Exchange protocol: enables nodes to exchange peer addresses, thus implementing a peer discovery service;
    • Address Book: stores discovered peer addresses and quality metrics associated to peers with which the node has interacted;
    • Peer Manager: defines when and to which peers a node should dial, in order to establish outbound connections;
  • Types: provide a list of existing types parameters used by the p2p package.