点对点通信

一个 CometBFT 网络由多个 CometBFT 实例组成,下文将其称为 nodes,它们通过交换消息进行交互。 CometBFT 协议的设计基于部分连通网络模型这一假设。 这意味着,不假定一个节点会与网络中的其他每个 节点都直接相连。 相反,每个节点只会与其他节点的一个子集直接连接, 下文将这些节点称为它的 peers。 因此,点对点(p2p)通信层是 CometBFT 中负责以下事项的组件:
  1. 在 CometBFT 网络中的节点之间建立连接
  2. 管理节点与其已连接 peers 之间的通信
  3. 在 CometBFT 协议中为 peers 之间的消息交换提供中介
p2p 层的规范仍在编写中, 相关进展可见 issue #19。 当前内容组织如下:
  • implementation:记录 p2p 层实现的当前状态,涵盖 p2p 包的主要组件。该文档以相当全面的方式说明了 上述列表中的第 1 项和第 2 项。
  • reactor-api:规定 p2p 层通过 Reactor 抽象向 协议层提供的 API。 这是对 p2p 层 API 的高层规范(即不应依赖具体实现), 对应上述列表中的第 3 项。
  • legacy-docs:我们将较早的文档保存在 legacy-docs 目录中,因为总体来看,其中仍包含有用的信息。 不过,这部分内容中有一些是冗余的, 因为较新的文档已经进行了更全面的覆盖, 并且某些实现细节可能已经过时 (见 issue #981)。
除上述内容外,还可以在 knowledge-base 仓库中找到一些尚未完成、仍在进行中的以及辅助性材料。

Peer-to-Peer Communication

A CometBFT network is composed of multiple CometBFT instances, hereafter called nodes, that interact by exchanging messages. The CometBFT protocols are designed under the assumption of a partially-connected network model. This means that a node is not assumed to be directly connected to every other node in the network. Instead, each node is directly connected to only a subset of other nodes, hereafter called its peers. The peer-to-peer (p2p) communication layer is then the component of CometBFT that:
  1. establishes connections between nodes in a CometBFT network
  2. manages the communication between a node and the connected peers
  3. intermediates the exchange of messages between peers in CometBFT protocols
The specification the p2p layer is a work in progress, tracked by issue #19. The current content is organized as follows:
  • implementation: documents the current state of the implementation of the p2p layer, covering the main components of the p2p package. The documentation covers, in a fairly comprehensive way, the items 1. and 2. from the list above.
  • reactor-api: specifies the API offered by the p2p layer to the protocol layer, through the Reactor abstraction. This is a high-level specification (i.e., it should not be implementation-specific) of the p2p layer API, covering item 3. from the list above.
  • legacy-docs: We keep older documentation in the legacy-docs directory, as overall, it contains useful information. However, part of this content is redundant, being more comprehensively covered in more recent documents, and some implementation details might be outdated (see issue #981).
In addition to this content, some unfinished, work in progress, and auxiliary material can be found in the knowledge-base repository.