github.com/vipernet-xyz/tm@v0.34.24/spec/abci/client-server.md (about)

     1  ---
     2  order: 3
     3  title: Client and Server
     4  ---
     5  
     6  # Client and Server
     7  
     8  This section is for those looking to implement their own ABCI Server, perhaps in
     9  a new programming language.
    10  
    11  You are expected to have read [ABCI Methods and Types](./abci.md) and [ABCI
    12  Applications](./apps.md).
    13  
    14  ## Message Protocol
    15  
    16  The message protocol consists of pairs of requests and responses defined in the
    17  [protobuf file](https://github.com/vipernet-xyz/tm/blob/v0.34.x/proto/tendermint/abci/types.proto).
    18  
    19  Some messages have no fields, while others may include byte-arrays, strings, integers,
    20  or custom protobuf types.
    21  
    22  For more details on protobuf, see the [documentation](https://developers.google.com/protocol-buffers/docs/overview).
    23  
    24  For each request, a server should respond with the corresponding
    25  response, where the order of requests is preserved in the order of
    26  responses.
    27  
    28  ## Server Implementations
    29  
    30  To use ABCI in your programming language of choice, there must be a ABCI
    31  server in that language. Tendermint supports three implementations of the ABCI, written in Go:
    32  
    33  - In-process ([Golang](https://github.com/vipernet-xyz/tm/tree/v0.34.x/abci), [Rust](https://github.com/tendermint/rust-abci))
    34  - ABCI-socket
    35  - GRPC
    36  
    37  The latter two can be tested using the `abci-cli` by setting the `--abci` flag
    38  appropriately (ie. to `socket` or `grpc`).
    39  
    40  See examples, in various stages of maintenance, in
    41  [Go](https://github.com/vipernet-xyz/tm/tree/v0.34.x/abci/server),
    42  [JavaScript](https://github.com/tendermint/js-abci),
    43  [C++](https://github.com/mdyring/cpp-tmsp), and
    44  [Java](https://github.com/jTendermint/jabci).
    45  
    46  ### In Process
    47  
    48  The simplest implementation uses function calls within Golang.
    49  This means ABCI applications written in Golang can be compiled with Tendermint Core and run as a single binary.
    50  
    51  ### GRPC
    52  
    53  If GRPC is available in your language, this is the easiest approach,
    54  though it will have significant performance overhead.
    55  
    56  To get started with GRPC, copy in the [protobuf
    57  file](https://github.com/vipernet-xyz/tm/blob/v0.34.x/proto/tendermint/abci/types.proto)
    58  and compile it using the GRPC plugin for your language. For instance,
    59  for golang, the command is `protoc --go_out=plugins=grpc:. types.proto`.
    60  See the [grpc documentation for more details](http://www.grpc.io/docs/).
    61  `protoc` will autogenerate all the necessary code for ABCI client and
    62  server in your language, including whatever interface your application
    63  must satisfy to be used by the ABCI server for handling requests.
    64  
    65  Note the length-prefixing used in the socket implementation (TSP) does not apply for GRPC.
    66  
    67  ### TSP
    68  
    69  Tendermint Socket Protocol is an asynchronous, raw socket server which provides ordered message passing over unix or tcp.
    70  Messages are serialized using Protobuf3 and length-prefixed with a [signed Varint](https://developers.google.com/protocol-buffers/docs/encoding?csw=1#signed-integers)
    71  
    72  If GRPC is not available in your language, or you require higher
    73  performance, or otherwise enjoy programming, you may implement your own
    74  ABCI server using the Tendermint Socket Protocol. The first step is still to auto-generate the relevant data
    75  types and codec in your language using `protoc`. In addition to being proto3 encoded, messages coming over
    76  the socket are length-prefixed to facilitate use as a streaming protocol. proto3 doesn't have an
    77  official length-prefix standard, so we use our own. The first byte in
    78  the prefix represents the length of the Big Endian encoded length. The
    79  remaining bytes in the prefix are the Big Endian encoded length.
    80  
    81  For example, if the proto3 encoded ABCI message is 0xDEADBEEF (4
    82  bytes), the length-prefixed message is 0x0104DEADBEEF. If the proto3
    83  encoded ABCI message is 65535 bytes long, the length-prefixed message
    84  would be like 0x02FFFF....
    85  
    86  The benefit of using this `varint` encoding over the old version (where integers were encoded as `<len of len><big endian len>` is that
    87  it is the standard way to encode integers in Protobuf. It is also generally shorter.
    88  
    89  As noted above, this prefixing does not apply for GRPC.
    90  
    91  An ABCI server must also be able to support multiple connections, as
    92  Tendermint uses four connections.
    93  
    94  ### Async vs Sync
    95  
    96  The main ABCI server (ie. non-GRPC) provides ordered asynchronous messages.
    97  This is useful for DeliverTx and CheckTx, since it allows Tendermint to forward
    98  transactions to the app before it's finished processing previous ones.
    99  
   100  Thus, DeliverTx and CheckTx messages are sent asynchronously, while all other
   101  messages are sent synchronously.
   102  
   103  ## Client
   104  
   105  There are currently two use-cases for an ABCI client. One is a testing
   106  tool, as in the `abci-cli`, which allows ABCI requests to be sent via
   107  command line. The other is a consensus engine, such as Tendermint Core,
   108  which makes requests to the application every time a new transaction is
   109  received or a block is committed.
   110  
   111  It is unlikely that you will need to implement a client. For details of
   112  our client, see
   113  [here](https://github.com/vipernet-xyz/tm/tree/v0.34.x/abci/client).