Files
tendermint/spec/abci/client-server.md
Thane Thomson daaf5d6441 docs: Update all docs to prepare for v0.37 (#9243)
* Update docs references from master to main

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update DOCS_README to reflect current reality

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update vuepress config with current versions and updated discussions link

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update generated docs versions

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update docs build to use temp folder instead of home

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Document build-docs Makefile target

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add serve-docs Makefile target to serve local build of docs

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Ensure 404 page is copied during docs build

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Redirect /master/ to /main/

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Attempt to resolve #7908

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update OpenAPI references from master to main

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update CHANGELOG references from master to main

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update Docker readme references from master to main

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update UPGRADING references from master to main

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update package-specific documentation references from master to main

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update spec references from master to main

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update all code comment references to docs site from master to main

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Build v0.34.x as "latest"

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Explicitly mark v0.34 docs as latest in version selector

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update all links from docs.tendermint.com/main to docs.tendermint.com/latest

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* ci: Redeploy docs on pushes to v0.34.x

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Temporarily copy spec directory into docs while building

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add nav link to main and clearly mark as unstable

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Revert to only publishing docs in nav for v0.34 and v0.33 with no latest

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Link to docs.tendermint.com/v0.34 from RFCs

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Rather just use main for all docs.tendermint.com references on main branch

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Rename GitHub tree links from master to main

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update link for ABCI Rust client

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update github links from master to main

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update badges in root readme

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Remove codecov badge since we do not use it any more

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Remove Java and Kotlin tutorials

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Remove specs from docs build

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Migrate spec links to GitHub repo from docs site

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Remove references to non-existent PEX reactor spec

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Fix linting badge in README

Signed-off-by: Thane Thomson <connect@thanethomson.com>

Signed-off-by: Thane Thomson <connect@thanethomson.com>
2022-08-19 13:18:33 -04:00

4.9 KiB

order, title
order title
3 Client and Server

Client and Server

This section is for those looking to implement their own ABCI Server, perhaps in a new programming language.

You are expected to have read ABCI Methods and Types and ABCI Applications.

Message Protocol

The message protocol consists of pairs of requests and responses defined in the protobuf file.

Some messages have no fields, while others may include byte-arrays, strings, integers, or custom protobuf types.

For more details on protobuf, see the documentation.

For each request, a server should respond with the corresponding response, where the order of requests is preserved in the order of responses.

Server Implementations

To use ABCI in your programming language of choice, there must be a ABCI server in that language. Tendermint supports three implementations of the ABCI, written in Go:

The latter two can be tested using the abci-cli by setting the --abci flag appropriately (ie. to socket or grpc).

See examples, in various stages of maintenance, in Go, JavaScript, C++, and Java.

In Process

The simplest implementation uses function calls within Golang. This means ABCI applications written in Golang can be compiled with Tendermint Core and run as a single binary.

GRPC

If GRPC is available in your language, this is the easiest approach, though it will have significant performance overhead.

To get started with GRPC, copy in the protobuf file and compile it using the GRPC plugin for your language. For instance, for golang, the command is protoc --go_out=plugins=grpc:. types.proto. See the grpc documentation for more details. protoc will autogenerate all the necessary code for ABCI client and server in your language, including whatever interface your application must satisfy to be used by the ABCI server for handling requests.

Note the length-prefixing used in the socket implementation (TSP) does not apply for GRPC.

TSP

Tendermint Socket Protocol is an asynchronous, raw socket server which provides ordered message passing over unix or tcp. Messages are serialized using Protobuf3 and length-prefixed with an unsigned varint

If GRPC is not available in your language, or you require higher performance, or otherwise enjoy programming, you may implement your own ABCI server using the Tendermint Socket Protocol. The first step is still to auto-generate the relevant data types and codec in your language using protoc. In addition to being proto3 encoded, messages coming over the socket are length-prefixed to facilitate use as a streaming protocol. proto3 doesn't have an official length-prefix standard, so we use our own. The first byte in the prefix represents the length of the Big Endian encoded length. The remaining bytes in the prefix are the Big Endian encoded length.

For example, if the proto3 encoded ABCI message is 0xDEADBEEF (4 bytes), the length-prefixed message is 0x0104DEADBEEF. If the proto3 encoded ABCI message is 65535 bytes long, the length-prefixed message would be like 0x02FFFF....

The benefit of using this varint encoding over the old version (where integers were encoded as <len of len><big endian len> is that it is the common way to encode integers in Protobuf. It is also generally shorter.

As noted above, this prefixing does not apply for GRPC.

An ABCI server must also be able to support multiple connections, as Tendermint uses four connections.

Async vs Sync

The main ABCI server (ie. non-GRPC) provides ordered asynchronous messages. This is useful for DeliverTx and CheckTx, since it allows Tendermint to forward transactions to the app before it's finished processing previous ones.

Thus, DeliverTx and CheckTx messages are sent asynchronously, while all other messages are sent synchronously.

Client

There are currently two use-cases for an ABCI client. One is a testing tool, as in the abci-cli, which allows ABCI requests to be sent via command line. The other is a consensus engine, such as Tendermint Core, which makes requests to the application every time a new transaction is received or a block is committed.

It is unlikely that you will need to implement a client. For details of our client, see here.