Skip to main content

Walkthrough example

We first create three connections (mempool, consensus, and query) to the application (running kvstore locally in this case).
Then CometBFT and the application perform a handshake.
After that, we start a few more things like the event switch and reactors.
Notice the second row where CometBFT reports that “This node is a validator”. It could also be just an observer (regular node). Next, we replay all the messages from the WAL.
The “Started node” message signals that everything is ready for work.
Next follows a standard block creation cycle, where we enter a new round, propose a block, receive more than 2/3 of prevotes, then precommits, and finally have a chance to commit a block. For details, please refer to Byzantine Consensus Algorithm.

List of modules

Here is the list of modules you may encounter in CometBFT’s logs and a brief overview of what they do.
  • abci-client As mentioned in Application Development Guide, CometBFT acts as an ABCI client with respect to the application and maintains 3 connections: mempool, consensus, and query. The code used by CometBFT can be found here.
  • blockchain Provides storage, pool (a group of peers), and reactor for both storing and exchanging blocks between peers.
  • consensus The heart of CometBFT, which is the implementation of the consensus algorithm. Includes two “submodules”: wal (write-ahead logging) for ensuring data integrity and replay to replay blocks and messages on recovery from a crash.
  • events Simple event notification system. The list of events can be found here. You can subscribe to them by calling subscribe RPC method. Refer to RPC docs for additional information.
  • mempool Mempool module handles all incoming transactions, whenever they are coming from peers or the application.
  • p2p Provides an abstraction around peer-to-peer communication. For more details, please check out the README.
  • rpc CometBFT’s RPC.
  • rpc-server RPC server. For implementation details, please read the doc.go.
  • state Represents the latest state and execution submodule, which executes blocks against the application.
  • types A collection of the publicly exposed types and methods to work with them.