ABCI
Application Blockchain Interface(ABCI) is an interface that defines the boundary between the replication engine(blockchain), and the state machine(application). Using a socket protocol(as v0.38.x, it supports gRPC), a consensus engine running in one process can manage an application state running in another.
https://github.com/cometbft/cometbft/tree/v1.0.1/abci
With this repository, developers can build their own blockchains(or applications) in any language that supports sockets since the ABCI is a socket protocol.
Below is super simple Counter using ABCI that i made.
https://github.com/canu0205/cosmos_hands_on_ex/tree/master/abci-counter
Key Functions in ABCI¶
CheckTx
¶
Many functions that could be broadcast should not be broadcast.
Exwamples include malformed transactions and spam-like artifacts. However, CometBFT cannot determine the transaction interpretation because it is agnostic to it. To address this, the ABCI includes CheckTx
method. CometBFT uses this method to ask the application layer if a transaction is valid. Applications implement this function. After the txs pass this function, they are added to a mempool.
DeliverTx
¶
CometBFT calls the DeliverTx
method to pass block information to the application layer for interpretation and possible state machine transition.
Commit
¶
Instructs the Application to persist its state. It is a fundamental part of CometBFT's crash-recovery mechanism that ensures the synchronization between CometBFT and the Application upon recovery. CometBFT calls it just after having persisted the data returned by calls to DeliverTx
and EndBlock
. The Application can now discard any state or data except the one resulting from executing the transactions in the decided block.
BeginBlock
and EndBlock
¶
BeginBlock
and EndBlock
messages are sent through the ABCI even if blocks contain no transactions. This provides positive confirmation of basic connectivity and helps identify time periods with no operations. These methods facilitate the execution of scheduled processes that should always run because they call methods at the application level, where developers define processes.
Only communicates at the FinalizeCommit
Phase.
Backlinks:
CometBFT
5. ABCI Commit -> passes the block to the application for state update.