**ABCI Communication for CometBFT and Cosmos SDK** ### Overview Application Blockchain Interface (ABCI) enables communication between **CometBFT** (formerly Tendermint Core) and the **Cosmos SDK**. ABCI functions as a bridge for consensus and networking logic handled by CometBFT and application-specific logic (state machine) handled by the Cosmos SDK. This separation allows Cosmos blockchains to be built in any language, though Go is most commonly used due to Cosmos SDK's Go implementation. ### ABCI Architecture and Communication Flow The ABCI protocol consists of three main message types: `BeginBlock`, `DeliverTx`, and `EndBlock`. CometBFT Core utilizes these message types to interact with the Cosmos SDK application's state machine, updating blockchain state after transactions are validated and included in blocks. Here's a breakdown: 1. **BeginBlock**: Called at the start of each block, it includes preliminary information (e.g., header, validator set) required for processing the block's transactions. 2. **DeliverTx**: Invoked for every transaction within the block, `DeliverTx` verifies and executes transactions, adding them to the application's state. 3. **EndBlock**: Signals the end of block processing, performing operations like validator updates and returning information to CometBFT for finalizing the block. These messages use **protobuf** for encoding, making the protocol language-agnostic. ### Implementation in Cosmos SDK and CometBFT - **Cosmos SDK**: The ABCI functions are implemented within the Cosmos SDK modules (e.g., `x/bank`, `x/staking`) using methods like `BeginBlocker`, `DeliverTx`, and `EndBlocker` within each module's logic. Each module can define specific ABCI hooks to handle custom logic during block processing. - **CometBFT**: Implements the ABCI server, handling requests from the Cosmos SDK application through the ABCI's gRPC layer. CometBFT’s **ABCI++** extends ABCI by introducing new message types and methods, enhancing the flexibility and modularity of the protocol. ### Components of ABCI applications: Connection State - the interplay between ABCI connections and application state and the differences between CheckTx and DeliverTx. Transaction Results - rules around transaction results and validity Validator Set Updates - how validator sets are changed during InitChain and EndBlock Query - standards for using the Query method and proofs about the application state Crash Recovery - handshake protocol to synchronize CometBFT and the application on startup. State Sync - rapid bootstrapping of new nodes by restoring state machine snapshots ### Key Resources and Documentation - Cosmos SDK ABCI Integration: [Cosmos SDK ABCI Documentation](https://docs.cosmos.network/v0.52/build/abci/introduction) - CometBFT ABCI 2.0 Protocol Reference: [CometBFT ABCI 2.0 Docs](https://docs.cometbft.com/v1.0/spec/abci/) - CometBFT ABCI Protocol Reference: [CometBFT ABCI](https://docs.cometbft.com/v0.34/spec/abci/abci) - Components of ABCI applications [Components of ABCI applications](https://docs.cometbft.com/v0.34/spec/abci/apps)