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.

205 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. - ``AppStateBytes ([]byte)``: Serialized initial application state
  53. - **Usage**: Called once upon genesis
  54. Query
  55. ^^^^^
  56. - **Arguments**:
  57. - ``Data ([]byte)``: Raw query bytes. Can be used with or in lieu of
  58. Path.
  59. - ``Path (string)``: Path of request, like an HTTP GET path. Can be
  60. used with or in liue of Data.
  61. - Apps MUST interpret '/store' as a query by key on the underlying
  62. store. The key SHOULD be specified in the Data field.
  63. - Apps SHOULD allow queries over specific types like '/accounts/...'
  64. or '/votes/...'
  65. - ``Height (int64)``: The block height for which you want the query
  66. (default=0 returns data for the latest committed block). Note that
  67. this is the height of the block containing the application's
  68. Merkle root hash, which represents the state as it was after
  69. committing the block at Height-1
  70. - ``Prove (bool)``: Return Merkle proof with response if possible
  71. - **Returns**:
  72. - ``Code (uint32)``: Response code
  73. - ``Key ([]byte)``: The key of the matching data
  74. - ``Value ([]byte)``: The value of the matching data
  75. - ``Proof ([]byte)``: Proof for the data, if requested
  76. - ``Height (int64)``: The block height from which data was derived.
  77. Note that this is the height of the block containing the
  78. application's Merkle root hash, which represents the state as it
  79. was after committing the block at Height-1
  80. - ``Log (string)``: Debug or error message
  81. BeginBlock
  82. ^^^^^^^^^^
  83. - **Arguments**:
  84. - ``Hash ([]byte)``: The block's hash. This can be derived from the
  85. block header.
  86. - ``Header (struct{})``: The block header
  87. - ``AbsentValidators ([]int32)``: List of indices of validators not
  88. included in the LastCommit
  89. - ``ByzantineValidators ([]Evidence)``: List of evidence of
  90. validators that acted maliciously
  91. - **Usage**: Signals the beginning of a new block. Called prior to any
  92. DeliverTxs. The header is expected to at least contain the Height.
  93. The ``AbsentValidators`` and ``ByzantineValidators`` can be used to
  94. determine rewards and punishments for the validators.
  95. CheckTx
  96. ^^^^^^^
  97. - **Arguments**:
  98. - ``Data ([]byte)``: The request transaction bytes
  99. - **Returns**:
  100. - ``Code (uint32)``: Response code
  101. - ``Data ([]byte)``: Result bytes, if any
  102. - ``Log (string)``: Debug or error message
  103. - ``Gas (int64)``: Amount of gas consumed by transaction
  104. - ``Fee (int64)``: Fee paid by transaction
  105. - **Usage**: Validate a mempool transaction, prior to broadcasting or
  106. proposing. This message should not mutate the main state, but
  107. application developers may want to keep a separate CheckTx state that
  108. gets reset upon Commit.
  109. CheckTx can happen interspersed with DeliverTx, but they happen on
  110. different ABCI connections - CheckTx from the mempool connection, and
  111. DeliverTx from the consensus connection. During Commit, the mempool
  112. is locked, so you can reset the mempool state to the latest state
  113. after running all those DeliverTxs, and then the mempool will re-run
  114. whatever txs it has against that latest mempool state.
  115. Transactions are first run through CheckTx before broadcast to peers
  116. in the mempool layer. You can make CheckTx semi-stateful and clear
  117. the state upon ``Commit`` or ``BeginBlock``, to allow for dependent
  118. sequences of transactions in the same block.
  119. DeliverTx
  120. ^^^^^^^^^
  121. - **Arguments**:
  122. - ``Data ([]byte)``: The request transaction bytes
  123. - **Returns**:
  124. - ``Code (uint32)``: Response code
  125. - ``Data ([]byte)``: Result bytes, if any
  126. - ``Log (string)``: Debug or error message
  127. - ``Tags ([]*KVPair)``: Optional tags for indexing
  128. - **Usage**: Append and run a transaction. If the transaction is valid,
  129. returns CodeType.OK
  130. EndBlock
  131. ^^^^^^^^
  132. - **Arguments**:
  133. - ``Height (int64)``: The block height that ended
  134. - **Returns**:
  135. - ``ValidatorUpdates ([]Validator)``: Changes to validator set (set
  136. voting power to 0 to remove)
  137. - ``ConsensusParamUpdates (ConsensusParams)``: Changes to
  138. consensus-critical time/size parameters
  139. - **Usage**: Signals the end of a block. Called prior to each Commit
  140. after all transactions. Validator set is updated with the result.
  141. Commit
  142. ^^^^^^
  143. - **Returns**:
  144. - ``Data ([]byte)``: The Merkle root hash
  145. - ``Log (string)``: Debug or error message
  146. - **Usage**: Return a Merkle root hash of the application state.