Jae Kwon 3798f9fa8e | 7 years ago | |
---|---|---|
client | 7 years ago | |
cmd/abci-cli | 7 years ago | |
example | 7 years ago | |
scripts | 7 years ago | |
server | 7 years ago | |
tests | 7 years ago | |
types | 7 years ago | |
version | 7 years ago | |
.editorconfig | 7 years ago | |
.gitignore | 7 years ago | |
CHANGELOG.md | 7 years ago | |
Dockerfile.develop | 7 years ago | |
LICENSE | 8 years ago | |
Makefile | 7 years ago | |
README.md | 7 years ago | |
circle.yml | 7 years ago | |
glide.lock | 7 years ago | |
glide.yaml | 7 years ago | |
test.sh | 7 years ago |
Blockchains are systems for multi-master state machine replication. ABCI is an interface that defines the boundary between the replication engine (the blockchain), and the state machine (the application). By using a socket protocol, we enable a consensus engine running in one process to manage an application state running in another.
For background information on ABCI, motivations, and tendermint, please visit the documentation.
The two guides to focus on are the Application Development Guide
and Using ABCI-CLI
.
Previously, the ABCI was referred to as TMSP.
The community has provided a number of addtional implementations, see the Tendermint Ecosystem
in the documentation.
We provide three implementations of the ABCI in Go:
Note the GRPC version is maintained primarily to simplify onboarding and prototyping and is not receiving the same attention to security and performance as the others.
The simplest implementation just uses function calls within Go. This means ABCI applications written in Golang can be compiled with TendermintCore and run as a single binary.
ABCI is best implemented as a streaming protocol. The socket implementation provides for asynchronous, ordered message passing over unix or tcp. Messages are serialized using Protobuf3 and length-prefixed. Protobuf3 doesn't have an official length-prefix standard, so we use our own. The first byte represents the length of the big-endian encoded length.
For example, if the Protobuf3 encoded ABCI message is 0xDEADBEEF
(4 bytes), the length-prefixed message is 0x0104DEADBEEF
. If the Protobuf3 encoded ABCI message is 65535 bytes long, the length-prefixed message would be like 0x02FFFF...
.
GRPC is an rpc framework native to Protocol Buffers with support in many languages. Implementing the ABCI using GRPC can allow for faster prototyping, but is expected to be much slower than the ordered, asynchronous socket protocol. The implementation has also not received as much testing or review.
Note the length-prefixing used in the socket implementation does not apply for GRPC.
The abci-cli
tool wraps an ABCI client and can be used for probing/testing an ABCI server.
For instance, abci-cli test
will run a test sequence against a listening server running the Counter application (see below).
It can also be used to run some example applications.
See the documentation for more details.
Multiple example apps are included:
abci-cli counter
application, which illustrates nonce checking in txsabci-cli dummy
application, which illustrates a simple key-value Merkle treeabci-cli dummy --persistent
application, which augments the dummy with persistence and validator set changesgo get github.com/tendermint/abci
cd $GOPATH/src/github.com/tendermint/abci
make get_vendor_deps
make install
The primary specification is made using Protocol Buffers. To build it, run
make protoc
See protoc --help
and the Protocol Buffers site for details on compiling for other languages.
Note we also include a GRPC service definition.
For the specification as an interface in Go, see the types/application.go file.
ABCI requests/responses are defined as simple Protobuf messages in this schema file. TendermintCore sends the requests, and the ABCI application sends the responses. Here, we describe the requests and responses as function arguments and return values, and make some notes about usage:
Message (string)
: A string to echo backMessage (string)
: The input stringReturns:
Data (string)
: Some arbitrary informationVersion (Version)
: Version informationLastBlockHeight (int64)
: Latest block for which the app has called CommitLastBlockAppHash ([]byte)
: Latest result of CommitUsage:
Return information about the application state. Used to sync the app with Tendermint on crash/restart.
Key (string)
: Key to setValue (string)
: Value to set for keyCode (uint32)
: Response codeLog (string)
: Debug or error messageValidators ([]Validator)
: Initial genesis validatorsData ([]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 codeKey ([]byte)
: The key of the matching dataValue ([]byte)
: The value of the matching dataProof ([]byte)
: Proof for the data, if requestedHeight (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-1Log (string)
: Debug or error messageHash ([]byte)
: The block's hash. This can be derived from the block header.Header (struct{})
: The block headerAbsentValidators ([]int32)
: List of indices of validators not included in the LastCommitByzantineValidators ([]Evidence)
: List of evidence of validators that acted maliciouslyAbsentValidators
and ByzantineValidators
can be used to determine rewards and punishments for the validators.Arguments:
Data ([]byte)
: The request transaction bytesReturns:
Code (uint32)
: Response codeData ([]byte)
: Result bytes, if anyLog (string)
: Debug or error messageGas (int64)
: Amount of gas consumed by transactionFee (int64)
: Fee paid by transactionUsage:
Validate a mempool transaction, prior to broadcasting or proposing. This message should not mutate the main state, but application
developers may want to keep a separate CheckTx state that gets reset upon Commit.
CheckTx can happen interspersed with DeliverTx, but they happen on different ABCI connections - CheckTx from the mempool connection, and DeliverTx from the consensus connection. During Commit, the mempool is locked, so you can reset the mempool state to the latest state after running all those DeliverTxs, and then the mempool will re-run whatever txs it has against that latest mempool state.
Transactions are first run through CheckTx before broadcast to peers in the mempool layer.
You can make CheckTx semi-stateful and clear the state upon Commit
or BeginBlock
,
to allow for dependent sequences of transactions in the same block.
Data ([]byte)
: The request transaction bytesCode (uint32)
: Response codeData ([]byte)
: Result bytes, if anyLog (string)
: Debug or error messageTags ([]*KVPair)
: Optional tags for indexingHeight (int64)
: The block height that endedValidatorUpdates ([]Validator)
: Changes to validator set (set voting power to 0 to remove)ConsensusParamUpdates (ConsensusParams)
: Changes to consensus-critical time/size parametersData ([]byte)
: The Merkle root hashLog (string)
: Debug or error message