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.

204 lines
6.2 KiB

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