The ABCI message types are defined in a protobuf file.
ABCI methods are split across 3 separate ABCI connections:
Consensus Connection
: InitChain, BeginBlock, DeliverTx, EndBlock, Commit
Mempool Connection
: CheckTx
Info Connection
: Info, SetOption, Query
The Consensus Connection
is driven by a consensus protocol and is responsible
for block execution.
The Mempool Connection
is for validating new transactions, before they're
shared or included in a block.
The Info Connection
is for initialization and for queries from the user.
Additionally, there is a Flush
method that is called on every connection,
and an Echo
method that is just for debugging.
More details on managing state across connections can be found in the section on ABCI Applications.
Some methods (Echo, Info, InitChain, BeginBlock, EndBlock, Commit
),
don't return errors because an error would indicate a critical failure
in the application and there's nothing Tendermint can do. The problem
should be addressed and both Tendermint and the application restarted.
All other methods (SetOption, Query, CheckTx, DeliverTx
) return an
application-specific response Code uint32
, where only 0
is reserved
for OK
.
Finally, Query
, CheckTx
, and DeliverTx
include a Codespace string
, whose
intended use is to disambiguate Code
values returned by different domains of the
application. The Codespace
is a namespace for the Code
.
Some methods (CheckTx, BeginBlock, DeliverTx, EndBlock
)
include a Tags
field in their Response*
. Each tag is key-value pair denoting
something about what happened during the methods execution.
Tags can be used to index transactions and blocks according to what happened during their execution.
Keys and values in tags must be UTF-8 encoded strings (e.g. "account.owner": "Bob", "balance": "100.0", "time": "2018-01-02T12:30:00Z")
ABCI applications must implement deterministic finite-state machines to be securely replicated by the Tendermint consensus. This means block execution over the Consensus Connection must be strictly deterministic: given the same ordered set of requests, all nodes will compute identical responses, for all BeginBlock, DeliverTx, EndBlock, and Commit. This is critical, because the responses are included in the header of the next block, either via a Merkle root or directly, so all nodes must agree on exactly what they are.
For this reason, it is recommended that applications not be exposed to any external user or process except via the ABCI connections to a consensus engine like Tendermint Core. The application must only change its state based on input from block execution (BeginBlock, DeliverTx, EndBlock, Commit), and not through any other kind of request. This is the only way to ensure all nodes see the same transactions and compute the same results.
If there is some non-determinism in the state machine, consensus will eventually fail as nodes disagree over the correct values for the block header. The non-determinism must be fixed and the nodes restarted.
Sources of non-determinism in applications may include:
See #56 for original discussion.
Note that some methods (SetOption, Query, CheckTx, DeliverTx
) return
explicitly non-deterministic data in the form of Info
and Log
fields. The Log
is
intended for the literal output from the application's logger, while the
Info
is any additional info that should be returned. These are the only fields
that are not included in block header computations, so we don't need agreement
on them. All other fields in the Response*
must be strictly deterministic.
The first time a new blockchain is started, Tendermint calls
InitChain
. From then on, the follow sequence of methods is executed for each
block:
BeginBlock, [DeliverTx], EndBlock, Commit
where one DeliverTx
is called for each transaction in the block.
The result is an updated application state.
Cryptographic commitments to the results of DeliverTx, EndBlock, and
Commit are included in the header of the next block.
Message (string)
: A string to echo backMessage (string)
: The input stringVersion (string)
: The Tendermint software semantic versionBlockVersion (uint64)
: The Tendermint Block Protocol versionP2PVersion (uint64)
: The Tendermint P2P Protocol versionData (string)
: Some arbitrary informationVersion (string)
: The application software semantic versionAppVersion (uint64)
: The application protocol versionLastBlockHeight (int64)
: Latest block for which the app has
called CommitLastBlockAppHash ([]byte)
: Latest result of CommitAppVersion
will be included in the Header of every block.LastBlockAppHash
and LastBlockHeight
to
be updated during Commit
, ensuring that Commit
is never
called twice for the same block height.Key (string)
: Key to setValue (string)
: Value to set for keyCode (uint32)
: Response codeLog (string)
: The output of the application's logger. May
be non-deterministic.Info (string)
: Additional information. May
be non-deterministic.Time (google.protobuf.Timestamp)
: Genesis time.ChainID (string)
: ID of the blockchain.ConsensusParams (ConsensusParams)
: Initial consensus-critical parameters.Validators ([]ValidatorUpdate)
: Initial genesis validators.AppStateBytes ([]byte)
: Serialized initial application state. Amino-encoded JSON bytes.ConsensusParams (ConsensusParams)
: Initial
consensus-critical parameters.Validators ([]ValidatorUpdate)
: Initial validator set (if non empty).Data ([]byte)
: Raw query bytes. Can be used with or in lieu
of Path.Path (string)
: Path of request, like an HTTP GET path. Can be
used with or in liue of Data.
Height (int64)
: The block height for which you want the query
(default=0 returns data for the latest committed block). Note
that this is the height of the block containing the
application's Merkle root hash, which represents the state as it
was after committing the block at Height-1Prove (bool)
: Return Merkle proof with response if possibleCode (uint32)
: Response code.Log (string)
: The output of the application's logger. May
be non-deterministic.Info (string)
: Additional information. May
be non-deterministic.Index (int64)
: The index of the key in the tree.Key ([]byte)
: The key of the matching data.Value ([]byte)
: The value of the matching data.Proof (Proof)
: Serialized proof for the value data, if requested, to be
verified against the AppHash
for the given Height.Height (int64)
: The block height from which data was derived.
Note that this is the height of the block containing the
application's Merkle root hash, which represents the state as it
was after committing the block at Height-1Codespace (string)
: Namespace for the Code
.type
field to support many types
of Merkle trees and encoding formats.Hash ([]byte)
: The block's hash. This can be derived from the
block header.Header (struct{})
: The block header.LastCommitInfo (LastCommitInfo)
: Info about the last commit, including the
round, and the list of validators and which ones signed the last block.ByzantineValidators ([]Evidence)
: List of evidence of
validators that acted maliciously.Tags ([]cmn.KVPair)
: Key-Value tags for filtering and indexingLastCommitInfo
and ByzantineValidators
can be used to determine
rewards and punishments for the validators. NOTE validators here do not
include pubkeys.Tx ([]byte)
: The request transaction bytesCode (uint32)
: Response codeData ([]byte)
: Result bytes, if any.Log (string)
: The output of the application's logger. May
be non-deterministic.Info (string)
: Additional information. May
be non-deterministic.GasWanted (int64)
: Amount of gas requested for transaction.GasUsed (int64)
: Amount of gas consumed by transaction.Tags ([]cmn.KVPair)
: Key-Value tags for filtering and indexing
transactions (eg. by account).Codespace (string)
: Namespace for the Code
.ResponseCheckTx.Code != 0
will be rejected - they will not be broadcast to
other nodes or included in a proposal block.Tx ([]byte)
: The request transaction bytes.Code (uint32)
: Response code.Data ([]byte)
: Result bytes, if any.Log (string)
: The output of the application's logger. May
be non-deterministic.Info (string)
: Additional information. May
be non-deterministic.GasWanted (int64)
: Amount of gas requested for transaction.GasUsed (int64)
: Amount of gas consumed by transaction.Tags ([]cmn.KVPair)
: Key-Value tags for filtering and indexing
transactions (eg. by account).Codespace (string)
: Namespace for the Code
.ResponseDeliverTx.Code == 0
only if the transaction is fully valid.Height (int64)
: Height of the block just executed.ValidatorUpdates ([]ValidatorUpdate)
: Changes to validator set (set
voting power to 0 to remove).ConsensusParamUpdates (ConsensusParams)
: Changes to
consensus-critical time, size, and other parameters.Tags ([]cmn.KVPair)
: Key-Value tags for filtering and indexingH
impact blocks H+1
, H+2
, and
H+3
, but only effects changes on the validator set of H+2
:
H+1
: NextValidatorsHashH+2
: ValidatorsHash (and thus the validator set)H+3
: LastCommitInfo (ie. the last validator set)H
apply for block H+1
Data ([]byte)
: The Merkle root hash of the application stateResponseCommit.Data
is included as the Header.AppHash
in the next block
Query
can return proofs about the application state anchored
in this Merkle root hashVersion (Version)
: Version of the blockchain and the applicationChainID (string)
: ID of the blockchainHeight (int64)
: Height of the block in the chainTime (google.protobuf.Timestamp)
: Time of the block. It is the proposer's
local time when block was created.NumTxs (int32)
: Number of transactions in the blockTotalTxs (int64)
: Total number of transactions in the blockchain until
nowLastBlockID (BlockID)
: Hash of the previous (parent) blockLastCommitHash ([]byte)
: Hash of the previous block's commitValidatorsHash ([]byte)
: Hash of the validator set for this blockNextValidatorsHash ([]byte)
: Hash of the validator set for the next blockConsensusHash ([]byte)
: Hash of the consensus parameters for this blockAppHash ([]byte)
: Data returned by the last call to Commit
- typically the
Merkle root of the application state after executing the previous block's
transactionsLastResultsHash ([]byte)
: Hash of the ABCI results returned by the last blockEvidenceHash ([]byte)
: Hash of the evidence included in this blockProposerAddress ([]byte)
: Original proposer for the blockBlock (uint64)
: Protocol version of the blockchain data structures.App (uint64)
: Protocol version of the application.Address ([]byte)
: Address of the validator (hash of the public key)Power (int64)
: Voting power of the validatorPubKey (PubKey)
: Public key of the validatorPower (int64)
: Voting power of the validatorValidator (Validator)
: A validatorSignedLastBlock (bool)
: Indicates whether or not the validator signed
the last blockType (string)
: Type of the public key. A simple string like "ed25519"
.
In the future, may indicate a serialization algorithm to parse the Data
,
for instance "amino"
.Data ([]byte)
: Public key data. For a simple public key, it's just the
raw bytes. If the Type
indicates an encoding algorithm, this is the
encoded public key.Type (string)
: Type of the evidence. A hierarchical path like
"duplicate/vote".Validator (Validator
: The offending validatorHeight (int64)
: Height when the offense was committedTime (google.protobuf.Timestamp)
: Time of the block at height Height
.
It is the proposer's local time when block was created.TotalVotingPower (int64)
: Total voting power of the validator set at
height Height
Round (int32)
: Commit round.Votes ([]VoteInfo)
: List of validators addresses in the last validator set
with their voting power and whether or not they signed a vote.BlockSize (BlockSize)
: Parameters limiting the size of a block.EvidenceParams (EvidenceParams)
: Parameters limiting the validity of
evidence of byzantine behaviour.MaxBytes (int64)
: Max size of a block, in bytes.MaxGas (int64)
: Max sum of GasWanted
in a proposed block.
MaxAge (int64)
: Max age of evidence, in blocks. Evidence older than this
is considered stale and ignored.
- This should correspond with an app's "unbonding period" or other
similar mechanism for handling Nothing-At-Stake attacks.
- NOTE: this should change to time (instead of blocks)!Ops ([]ProofOp)
: List of chained Merkle proofs, of possibly different types
Type (string)
: Type of Merkle proof and how it's encoded.Key ([]byte)
: Key in the Merkle tree that this proof is for.Data ([]byte)
: Encoded Merkle proof for the key.