You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
6.7 KiB

  1. Specification
  2. =============
  3. The `primary
  4. specification <https://github.com/tendermint/abci/blob/master/types/types.proto>`__
  5. is made using Protocol Buffers. To build it, run
  6. ::
  7. make protoc
  8. See ``protoc --help`` and `the Protocol Buffers
  9. site <https://developers.google.com/protocol-buffers/>`__ for details on
  10. compiling for other languages. Note we also include a
  11. `GRPC <http://www.grpc.io/docs>`__ service definition.
  12. For the specification as an interface in Go, see the
  13. `types/application.go
  14. file <https://github.com/tendermint/abci/blob/master/types/application.go>`__.
  15. Message Types
  16. ~~~~~~~~~~~~~
  17. ABCI requests/responses are defined as simple Protobuf messages in `this
  18. schema
  19. file <https://github.com/tendermint/abci/blob/master/types/types.proto>`__.
  20. TendermintCore sends the requests, and the ABCI application sends the
  21. responses. Here, we describe the requests and responses as function
  22. arguments and return values, and make some notes about usage:
  23. Echo
  24. ^^^^
  25. - **Arguments**:
  26. - ``Message (string)``: A string to echo back
  27. - **Returns**:
  28. - ``Message (string)``: The input string
  29. - **Usage**:
  30. - Echo a string to test an abci client/server implementation
  31. Flush
  32. ^^^^^
  33. - **Usage**:
  34. - Signals that messages queued on the client should be flushed to
  35. the server. It is called periodically by the client implementation
  36. to ensure asynchronous requests are actually sent, and is called
  37. immediately to make a synchronous request, which returns when the
  38. Flush response comes back.
  39. Info
  40. ^^^^
  41. - **Returns**:
  42. - ``Data (string)``: Some arbitrary information
  43. - ``Version (Version)``: Version information
  44. - ``LastBlockHeight (int64)``: Latest block for which the app has
  45. called Commit
  46. - ``LastBlockAppHash ([]byte)``: Latest result of Commit
  47. - **Usage**: Return information about the application state. Used to
  48. sync the app with Tendermint on crash/restart.
  49. SetOption
  50. ^^^^^^^^^
  51. - **Arguments**:
  52. - ``Key (string)``: Key to set
  53. - ``Value (string)``: Value to set for key
  54. - **Returns**:
  55. - ``Code (uint32)``: Response code
  56. - ``Log (string)``: Debug or error message
  57. - **Usage**: Set application options. E.g. Key="mode", Value="mempool"
  58. for a mempool connection, or Key="mode", Value="consensus" for a
  59. consensus connection. Other options are application specific.
  60. InitChain
  61. ^^^^^^^^^
  62. - **Arguments**:
  63. - ``Validators ([]Validator)``: Initial genesis validators
  64. - **Usage**: Called once upon genesis
  65. Query
  66. ^^^^^
  67. - **Arguments**:
  68. - ``Data ([]byte)``: Raw query bytes. Can be used with or in lieu of
  69. Path.
  70. - ``Path (string)``: Path of request, like an HTTP GET path. Can be
  71. used with or in liue of Data.
  72. - Apps MUST interpret '/store' as a query by key on the underlying
  73. store. The key SHOULD be specified in the Data field.
  74. - Apps SHOULD allow queries over specific types like '/accounts/...'
  75. or '/votes/...'
  76. - ``Height (int64)``: The block height for which you want the query
  77. (default=0 returns data for the latest committed block). Note that
  78. this is the height of the block containing the application's
  79. Merkle root hash, which represents the state as it was after
  80. committing the block at Height-1
  81. - ``Prove (bool)``: Return Merkle proof with response if possible
  82. - **Returns**:
  83. - ``Code (uint32)``: Response code
  84. - ``Key ([]byte)``: The key of the matching data
  85. - ``Value ([]byte)``: The value of the matching data
  86. - ``Proof ([]byte)``: Proof for the data, if requested
  87. - ``Height (int64)``: The block height from which data was derived.
  88. Note that this is the height of the block containing the
  89. application's Merkle root hash, which represents the state as it
  90. was after committing the block at Height-1
  91. - ``Log (string)``: Debug or error message
  92. BeginBlock
  93. ^^^^^^^^^^
  94. - **Arguments**:
  95. - ``Hash ([]byte)``: The block's hash. This can be derived from the
  96. block header.
  97. - ``Header (struct{})``: The block header
  98. - ``AbsentValidators ([]int32)``: List of indices of validators not
  99. included in the LastCommit
  100. - ``ByzantineValidators ([]Evidence)``: List of evidence of
  101. validators that acted maliciously
  102. - **Usage**: Signals the beginning of a new block. Called prior to any
  103. DeliverTxs. The header is expected to at least contain the Height.
  104. The ``AbsentValidators`` and ``ByzantineValidators`` can be used to
  105. determine rewards and punishments for the validators.
  106. CheckTx
  107. ^^^^^^^
  108. - **Arguments**:
  109. - ``Data ([]byte)``: The request transaction bytes
  110. - **Returns**:
  111. - ``Code (uint32)``: Response code
  112. - ``Data ([]byte)``: Result bytes, if any
  113. - ``Log (string)``: Debug or error message
  114. - ``Gas (int64)``: Amount of gas consumed by transaction
  115. - ``Fee (int64)``: Fee paid by transaction
  116. - **Usage**: Validate a mempool transaction, prior to broadcasting or
  117. proposing. This message should not mutate the main state, but
  118. application developers may want to keep a separate CheckTx state that
  119. gets reset upon Commit.
  120. CheckTx can happen interspersed with DeliverTx, but they happen on
  121. different ABCI connections - CheckTx from the mempool connection, and
  122. DeliverTx from the consensus connection. During Commit, the mempool
  123. is locked, so you can reset the mempool state to the latest state
  124. after running all those DeliverTxs, and then the mempool will re-run
  125. whatever txs it has against that latest mempool state.
  126. Transactions are first run through CheckTx before broadcast to peers
  127. in the mempool layer. You can make CheckTx semi-stateful and clear
  128. the state upon ``Commit`` or ``BeginBlock``, to allow for dependent
  129. sequences of transactions in the same block.
  130. DeliverTx
  131. ^^^^^^^^^
  132. - **Arguments**:
  133. - ``Data ([]byte)``: The request transaction bytes
  134. - **Returns**:
  135. - ``Code (uint32)``: Response code
  136. - ``Data ([]byte)``: Result bytes, if any
  137. - ``Log (string)``: Debug or error message
  138. - ``Tags ([]*KVPair)``: Optional tags for indexing
  139. - **Usage**: Append and run a transaction. If the transaction is valid,
  140. returns CodeType.OK
  141. EndBlock
  142. ^^^^^^^^
  143. - **Arguments**:
  144. - ``Height (int64)``: The block height that ended
  145. - **Returns**:
  146. - ``ValidatorUpdates ([]Validator)``: Changes to validator set (set
  147. voting power to 0 to remove)
  148. - ``ConsensusParamUpdates (ConsensusParams)``: Changes to
  149. consensus-critical time/size parameters
  150. - **Usage**: Signals the end of a block. Called prior to each Commit
  151. after all transactions. Validator set is updated with the result.
  152. Commit
  153. ^^^^^^
  154. - **Returns**:
  155. - ``Data ([]byte)``: The Merkle root hash
  156. - ``Log (string)``: Debug or error message
  157. - **Usage**: Return a Merkle root hash of the application state.