github.com/aakash4dev/cometbft@v0.38.2/spec/abci/abci++_client_server.md (about)

     1  ---
     2  order: 5
     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 all previous sections of ABCI++ specification, namely
    12  [Basic Concepts](./abci%2B%2B_basic_concepts.md),
    13  [Methods](./abci%2B%2B_methods.md),
    14  [Application Requirements](./abci%2B%2B_app_requirements.md), and
    15  [Expected Behavior](./abci%2B%2B_comet_expected_behavior.md).
    16  
    17  ## Message Protocol and Synchrony
    18  
    19  The message protocol consists of pairs of requests and responses defined in the
    20  [protobuf file](https://github.com/aakash4dev/cometbft/blob/main/proto/tendermint/abci/types.proto).
    21  
    22  Some messages have no fields, while others may include byte-arrays, strings, integers,
    23  or custom protobuf types.
    24  
    25  For more details on protobuf, see the [documentation](https://developers.google.com/protocol-buffers/docs/overview).
    26  
    27  <!--
    28  As of v0.36 requests are synchronous. For each of ABCI++'s four connections (see
    29  [Connections](./abci%2B%2B_app_requirements.md)), when CometBFT issues a request to the
    30  Application, it will wait for the response before continuing execution. As a side effect,
    31  requests and responses are ordered for each connection, but not necessarily across connections.
    32  -->
    33  ## Server Implementations
    34  
    35  To use ABCI in your programming language of choice, there must be an ABCI
    36  server in that language. CometBFT supports four implementations of the ABCI server:
    37  
    38  - in CometBFT's repository:
    39      - In-process
    40      - ABCI-socket
    41      - GRPC
    42  - [tendermint-rs](https://github.com/informalsystems/tendermint-rs)
    43  - [tower-abci](https://github.com/penumbra-zone/tower-abci)
    44  
    45  The implementations in CometBFT's repository can be tested using `abci-cli` by setting
    46  the `--abci` flag appropriately.
    47  
    48  See examples, in various stages of maintenance, in
    49  [Go](https://github.com/aakash4dev/cometbft/tree/master/abci/server),
    50  [JavaScript](https://github.com/tendermint/js-abci),
    51  [C++](https://github.com/mdyring/cpp-tmsp), and
    52  [Java](https://github.com/jTendermint/jabci).
    53  
    54  ### In Process
    55  
    56  The simplest implementation uses function calls in Golang.
    57  This means ABCI applications written in Golang can be linked with CometBFT and run as a single binary.
    58  
    59  ### GRPC
    60  
    61  If you are not using Golang,
    62  but [GRPC](https://grpc.io/) is available in your language, this is the easiest approach,
    63  though it will have significant performance overhead.
    64  
    65  Please check GRPC's documentation to know to set up the Application as an
    66  ABCI GRPC server.
    67  
    68  ### Socket
    69  
    70  The CometBFT Socket Protocol is an asynchronous, raw socket server protocol which provides ordered
    71  message passing over Unix or TCP sockets. Messages are serialized using Protobuf3 and length-prefixed
    72  with an [unsigned varint](https://developers.google.com/protocol-buffers/docs/encoding?csw=1#varints)
    73  
    74  If gRPC is not available in your language, or you require higher performance, or
    75  otherwise enjoy programming, you may implement your own ABCI server using the
    76  CometBFT Socket Protocol. The first step is still to auto-generate the
    77  relevant data types and codec in your language using `protoc`, and then you need to
    78  ensure you handle the unsigned `varint`-based message length encoding scheme
    79  when reading and writing messages to the socket.
    80  
    81  Note that our length prefixing scheme does not apply to gRPC.
    82  
    83  Also note that your ABCI server must be able to handle multiple connections,
    84  as CometBFT uses four connections.
    85  
    86  ## Client
    87  
    88  There are currently two use-cases for an ABCI client. One is testing
    89  tools that allow ABCI requests to be sent to the actual application via
    90  command line. An example of this is `abci-cli`, which accepts CLI commands
    91  to send corresponding ABCI requests.
    92  The other is a consensus engine, such as CometBFT,
    93  which makes ABCI requests to the application as prescribed by the consensus
    94  algorithm used.