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.

882 lines
72 KiB

abci: Synchronize FinalizeBlock with the updated specification (#7983) This change set implements the most recent version of `FinalizeBlock`. # What does this change actually contain? * This change set is rather large but fear not! The majority of the files touched and changes are renaming `ResponseDeliverTx` to `ExecTxResult`. This should be a pretty inoffensive change since they're effectively the same type but with a different name. * The `execBlockOnProxyApp` was totally removed since it served as just a wrapper around the logic that is now mostly encapsulated within `FinalizeBlock` * The `updateState` helper function has been made a public method on `State`. It was being exposed as a shim through the testing infrastructure, so this seemed innocuous. * Tests already existed to ensure that the application received the `ByzantineValidators` and the `ValidatorUpdates`, but one was fixed up to ensure that `LastCommitInfo` was being sent across. * Tests were removed from the `psql` indexer that seemed to search for an event in the indexer that was not being created. # Questions for reviewers * We store this [ABCIResponses](https://github.com/tendermint/tendermint/blob/5721a13ab1f4479f9807f449f0bf5c536b9a05f2/proto/tendermint/state/types.pb.go#L37) type in the data base as the block results. This type has changed since v0.35 to contain the `FinalizeBlock` response. I'm wondering if we need to do any shimming to keep the old data retrieveable? * Similarly, this change is exposed via the RPC through [ResultBlockResults](https://github.com/tendermint/tendermint/blob/5721a13ab1f4479f9807f449f0bf5c536b9a05f2/rpc/coretypes/responses.go#L69) changing. Should we somehow shim or notify for this change? closes: #7658
2 years ago
abci: Synchronize FinalizeBlock with the updated specification (#7983) This change set implements the most recent version of `FinalizeBlock`. # What does this change actually contain? * This change set is rather large but fear not! The majority of the files touched and changes are renaming `ResponseDeliverTx` to `ExecTxResult`. This should be a pretty inoffensive change since they're effectively the same type but with a different name. * The `execBlockOnProxyApp` was totally removed since it served as just a wrapper around the logic that is now mostly encapsulated within `FinalizeBlock` * The `updateState` helper function has been made a public method on `State`. It was being exposed as a shim through the testing infrastructure, so this seemed innocuous. * Tests already existed to ensure that the application received the `ByzantineValidators` and the `ValidatorUpdates`, but one was fixed up to ensure that `LastCommitInfo` was being sent across. * Tests were removed from the `psql` indexer that seemed to search for an event in the indexer that was not being created. # Questions for reviewers * We store this [ABCIResponses](https://github.com/tendermint/tendermint/blob/5721a13ab1f4479f9807f449f0bf5c536b9a05f2/proto/tendermint/state/types.pb.go#L37) type in the data base as the block results. This type has changed since v0.35 to contain the `FinalizeBlock` response. I'm wondering if we need to do any shimming to keep the old data retrieveable? * Similarly, this change is exposed via the RPC through [ResultBlockResults](https://github.com/tendermint/tendermint/blob/5721a13ab1f4479f9807f449f0bf5c536b9a05f2/rpc/coretypes/responses.go#L69) changing. Should we somehow shim or notify for this change? closes: #7658
2 years ago
  1. ---
  2. order: 2
  3. title: Methods
  4. ---
  5. # Methods
  6. ## Methods existing in ABCI
  7. ### Echo
  8. * **Request**:
  9. * `Message (string)`: A string to echo back
  10. * **Response**:
  11. * `Message (string)`: The input string
  12. * **Usage**:
  13. * Echo a string to test an abci client/server implementation
  14. ### Flush
  15. * **Usage**:
  16. * Signals that messages queued on the client should be flushed to
  17. the server. It is called periodically by the client
  18. implementation to ensure asynchronous requests are actually
  19. sent, and is called immediately to make a synchronous request,
  20. which returns when the Flush response comes back.
  21. ### Info
  22. * **Request**:
  23. | Name | Type | Description | Field Number |
  24. |---------------|--------|------------------------------------------|--------------|
  25. | version | string | The Tendermint software semantic version | 1 |
  26. | block_version | uint64 | The Tendermint Block Protocol version | 2 |
  27. | p2p_version | uint64 | The Tendermint P2P Protocol version | 3 |
  28. | abci_version | string | The Tendermint ABCI semantic version | 4 |
  29. * **Response**:
  30. | Name | Type | Description | Field Number |
  31. |---------------------|--------|--------------------------------------------------|--------------|
  32. | data | string | Some arbitrary information | 1 |
  33. | version | string | The application software semantic version | 2 |
  34. | app_version | uint64 | The application protocol version | 3 |
  35. | last_block_height | int64 | Latest block for which the app has called Commit | 4 |
  36. | last_block_app_hash | bytes | Latest result of Commit | 5 |
  37. * **Usage**:
  38. * Return information about the application state.
  39. * Used to sync Tendermint with the application during a handshake
  40. that happens on startup.
  41. * The returned `app_version` will be included in the Header of every block.
  42. * Tendermint expects `last_block_app_hash` and `last_block_height` to
  43. be updated during `Commit`, ensuring that `Commit` is never
  44. called twice for the same block height.
  45. > Note: Semantic version is a reference to [semantic versioning](https://semver.org/). Semantic versions in info will be displayed as X.X.x.
  46. ### InitChain
  47. * **Request**:
  48. | Name | Type | Description | Field Number |
  49. |------------------|--------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|--------------|
  50. | time | [google.protobuf.Timestamp](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp) | Genesis time | 1 |
  51. | chain_id | string | ID of the blockchain. | 2 |
  52. | consensus_params | [ConsensusParams](#consensusparams) | Initial consensus-critical parameters. | 3 |
  53. | validators | repeated [ValidatorUpdate](#validatorupdate) | Initial genesis validators, sorted by voting power. | 4 |
  54. | app_state_bytes | bytes | Serialized initial application state. JSON bytes. | 5 |
  55. | initial_height | int64 | Height of the initial block (typically `1`). | 6 |
  56. * **Response**:
  57. | Name | Type | Description | Field Number |
  58. |------------------|----------------------------------------------|-------------------------------------------------|--------------|
  59. | consensus_params | [ConsensusParams](#consensusparams) | Initial consensus-critical parameters (optional) | 1 |
  60. | validators | repeated [ValidatorUpdate](#validatorupdate) | Initial validator set (optional). | 2 |
  61. | app_hash | bytes | Initial application hash. | 3 |
  62. * **Usage**:
  63. * Called once upon genesis.
  64. * If ResponseInitChain.Validators is empty, the initial validator set will be the RequestInitChain.Validators
  65. * If ResponseInitChain.Validators is not empty, it will be the initial
  66. validator set (regardless of what is in RequestInitChain.Validators).
  67. * This allows the app to decide if it wants to accept the initial validator
  68. set proposed by tendermint (ie. in the genesis file), or if it wants to use
  69. a different one (perhaps computed based on some application specific
  70. information in the genesis file).
  71. ### Query
  72. * **Request**:
  73. | Name | Type | Description | Field Number |
  74. |--------|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
  75. | data | bytes | Raw query bytes. Can be used with or in lieu of Path. | 1 |
  76. | path | string | Path field of the request URI. Can be used with or in lieu of `data`. Apps MUST interpret `/store` as a query by key on the underlying store. The key SHOULD be specified in the `data` field. Apps SHOULD allow queries over specific types like `/accounts/...` or `/votes/...` | 2 |
  77. | height | int64 | The block height for which you want the query (default=0 returns data for the latest committed block). Note that this is the height of the block containing the application's Merkle root hash, which represents the state as it was after committing the block at Height-1 | 3 |
  78. | prove | bool | Return Merkle proof with response if possible | 4 |
  79. * **Response**:
  80. | Name | Type | Description | Field Number |
  81. |-----------|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
  82. | code | uint32 | Response code. | 1 |
  83. | log | string | The output of the application's logger. **May be non-deterministic.** | 3 |
  84. | info | string | Additional information. **May be non-deterministic.** | 4 |
  85. | index | int64 | The index of the key in the tree. | 5 |
  86. | key | bytes | The key of the matching data. | 6 |
  87. | value | bytes | The value of the matching data. | 7 |
  88. | proof_ops | [ProofOps](#proofops) | Serialized proof for the value data, if requested, to be verified against the `app_hash` for the given Height. | 8 |
  89. | height | int64 | The block height from which data was derived. Note that this is the height of the block containing the application's Merkle root hash, which represents the state as it was after committing the block at Height-1 | 9 |
  90. | codespace | string | Namespace for the `code`. | 10 |
  91. * **Usage**:
  92. * Query for data from the application at current or past height.
  93. * Optionally return Merkle proof.
  94. * Merkle proof includes self-describing `type` field to support many types
  95. of Merkle trees and encoding formats.
  96. ### CheckTx
  97. * **Request**:
  98. | Name | Type | Description | Field Number |
  99. |------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
  100. | tx | bytes | The request transaction bytes | 1 |
  101. | type | CheckTxType | One of `CheckTx_New` or `CheckTx_Recheck`. `CheckTx_New` is the default and means that a full check of the tranasaction is required. `CheckTx_Recheck` types are used when the mempool is initiating a normal recheck of a transaction. | 2 |
  102. * **Response**:
  103. | Name | Type | Description | Field Number |
  104. |------------|-------------------------------------------------------------|-----------------------------------------------------------------------|--------------|
  105. | code | uint32 | Response code. | 1 |
  106. | data | bytes | Result bytes, if any. | 2 |
  107. | log | string | The output of the application's logger. **May be non-deterministic.** | 3 |
  108. | info | string | Additional information. **May be non-deterministic.** | 4 |
  109. | gas_wanted | int64 | Amount of gas requested for transaction. | 5 |
  110. | gas_used | int64 | Amount of gas consumed by transaction. | 6 |
  111. | events | repeated [Event](abci++_basic_concepts_002_draft.md#events) | Type & Key-Value events for indexing transactions (eg. by account). | 7 |
  112. | codespace | string | Namespace for the `code`. | 8 |
  113. | sender | string | The transaction's sender (e.g. the signer) | 9 |
  114. | priority | int64 | The transaction's priority (for mempool ordering) | 10 |
  115. * **Usage**:
  116. * Technically optional - not involved in processing blocks.
  117. * Guardian of the mempool: every node runs `CheckTx` before letting a
  118. transaction into its local mempool.
  119. * The transaction may come from an external user or another node
  120. * `CheckTx` validates the transaction against the current state of the application,
  121. for example, checking signatures and account balances, but does not apply any
  122. of the state changes described in the transaction.
  123. not running code in a virtual machine.
  124. * Transactions where `ResponseCheckTx.Code != 0` will be rejected - they will not be broadcast to
  125. other nodes or included in a proposal block.
  126. * Tendermint attributes no other value to the response code
  127. ### ListSnapshots
  128. * **Request**:
  129. | Name | Type | Description | Field Number |
  130. |--------|-------|------------------------------------|--------------|
  131. Empty request asking the application for a list of snapshots.
  132. * **Response**:
  133. | Name | Type | Description | Field Number |
  134. |-----------|--------------------------------|--------------------------------|--------------|
  135. | snapshots | repeated [Snapshot](#snapshot) | List of local state snapshots. | 1 |
  136. * **Usage**:
  137. * Used during state sync to discover available snapshots on peers.
  138. * See `Snapshot` data type for details.
  139. ### LoadSnapshotChunk
  140. * **Request**:
  141. | Name | Type | Description | Field Number |
  142. |--------|--------|-----------------------------------------------------------------------|--------------|
  143. | height | uint64 | The height of the snapshot the chunk belongs to. | 1 |
  144. | format | uint32 | The application-specific format of the snapshot the chunk belongs to. | 2 |
  145. | chunk | uint32 | The chunk index, starting from `0` for the initial chunk. | 3 |
  146. * **Response**:
  147. | Name | Type | Description | Field Number |
  148. |-------|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
  149. | chunk | bytes | The binary chunk contents, in an arbitray format. Chunk messages cannot be larger than 16 MB _including metadata_, so 10 MB is a good starting point. | 1 |
  150. * **Usage**:
  151. * Used during state sync to retrieve snapshot chunks from peers.
  152. ### OfferSnapshot
  153. * **Request**:
  154. | Name | Type | Description | Field Number |
  155. |----------|-----------------------|--------------------------------------------------------------------------|--------------|
  156. | snapshot | [Snapshot](#snapshot) | The snapshot offered for restoration. | 1 |
  157. | app_hash | bytes | The light client-verified app hash for this height, from the blockchain. | 2 |
  158. * **Response**:
  159. | Name | Type | Description | Field Number |
  160. |--------|-------------------|-----------------------------------|--------------|
  161. | result | [Result](#result) | The result of the snapshot offer. | 1 |
  162. #### Result
  163. ```protobuf
  164. enum Result {
  165. UNKNOWN = 0; // Unknown result, abort all snapshot restoration
  166. ACCEPT = 1; // Snapshot is accepted, start applying chunks.
  167. ABORT = 2; // Abort snapshot restoration, and don't try any other snapshots.
  168. REJECT = 3; // Reject this specific snapshot, try others.
  169. REJECT_FORMAT = 4; // Reject all snapshots with this `format`, try others.
  170. REJECT_SENDER = 5; // Reject all snapshots from all senders of this snapshot, try others.
  171. }
  172. ```
  173. * **Usage**:
  174. * `OfferSnapshot` is called when bootstrapping a node using state sync. The application may
  175. accept or reject snapshots as appropriate. Upon accepting, Tendermint will retrieve and
  176. apply snapshot chunks via `ApplySnapshotChunk`. The application may also choose to reject a
  177. snapshot in the chunk response, in which case it should be prepared to accept further
  178. `OfferSnapshot` calls.
  179. * Only `AppHash` can be trusted, as it has been verified by the light client. Any other data
  180. can be spoofed by adversaries, so applications should employ additional verification schemes
  181. to avoid denial-of-service attacks. The verified `AppHash` is automatically checked against
  182. the restored application at the end of snapshot restoration.
  183. * For more information, see the `Snapshot` data type or the [state sync section](../p2p/messages/state-sync.md).
  184. ### ApplySnapshotChunk
  185. * **Request**:
  186. | Name | Type | Description | Field Number |
  187. |--------|--------|-----------------------------------------------------------------------------|--------------|
  188. | index | uint32 | The chunk index, starting from `0`. Tendermint applies chunks sequentially. | 1 |
  189. | chunk | bytes | The binary chunk contents, as returned by `LoadSnapshotChunk`. | 2 |
  190. | sender | string | The P2P ID of the node who sent this chunk. | 3 |
  191. * **Response**:
  192. | Name | Type | Description | Field Number |
  193. |----------------|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
  194. | result | Result (see below) | The result of applying this chunk. | 1 |
  195. | refetch_chunks | repeated uint32 | Refetch and reapply the given chunks, regardless of `result`. Only the listed chunks will be refetched, and reapplied in sequential order. | 2 |
  196. | reject_senders | repeated string | Reject the given P2P senders, regardless of `Result`. Any chunks already applied will not be refetched unless explicitly requested, but queued chunks from these senders will be discarded, and new chunks or other snapshots rejected. | 3 |
  197. ```proto
  198. enum Result {
  199. UNKNOWN = 0; // Unknown result, abort all snapshot restoration
  200. ACCEPT = 1; // The chunk was accepted.
  201. ABORT = 2; // Abort snapshot restoration, and don't try any other snapshots.
  202. RETRY = 3; // Reapply this chunk, combine with `RefetchChunks` and `RejectSenders` as appropriate.
  203. RETRY_SNAPSHOT = 4; // Restart this snapshot from `OfferSnapshot`, reusing chunks unless instructed otherwise.
  204. REJECT_SNAPSHOT = 5; // Reject this snapshot, try a different one.
  205. }
  206. ```
  207. * **Usage**:
  208. * The application can choose to refetch chunks and/or ban P2P peers as appropriate. Tendermint
  209. will not do this unless instructed by the application.
  210. * The application may want to verify each chunk, e.g. by attaching chunk hashes in
  211. `Snapshot.Metadata` and/or incrementally verifying contents against `AppHash`.
  212. * When all chunks have been accepted, Tendermint will make an ABCI `Info` call to verify that
  213. `LastBlockAppHash` and `LastBlockHeight` matches the expected values, and record the
  214. `AppVersion` in the node state. It then switches to fast sync or consensus and joins the
  215. network.
  216. * If Tendermint is unable to retrieve the next chunk after some time (e.g. because no suitable
  217. peers are available), it will reject the snapshot and try a different one via `OfferSnapshot`.
  218. The application should be prepared to reset and accept it or abort as appropriate.
  219. ## New methods introduced in ABCI++
  220. ### PrepareProposal
  221. #### Parameters and Types
  222. * **Request**:
  223. | Name | Type | Description | Field Number |
  224. |-------------------------|---------------------------------------------|------------------------------------------------------------------------------------------------------------------|--------------|
  225. | hash | bytes | The block header's hash of the block to propose. Present for convenience (can be derived from the block header). | 1 |
  226. | header | [Header](../core/data_structures.md#header) | The header of the block to propose. | 2 |
  227. | txs | repeated bytes | Preliminary list of transactions that have been picked as part of the block to propose. | 3 |
  228. | local_last_commit | [ExtendedCommitInfo](#extendedcommitinfo) | Info about the last commit, obtained locally from Tendermint's data structures. | 4 |
  229. | byzantine_validators | repeated [Evidence](#evidence) | List of evidence of validators that acted maliciously. | 5 |
  230. | max_tx_bytes | int64 | Currently configured maximum size in bytes taken by the modified transactions. | 6 |
  231. * **Response**:
  232. | Name | Type | Description | Field Number |
  233. |-------------------------|--------------------------------------------------|---------------------------------------------------------------------------------------------|--------------|
  234. | modified_tx | bool | The Application sets it to true to denote it made changes to transactions | 1 |
  235. | tx_records | repeated [TxRecord](#txrecord) | Possibly modified list of transactions that have been picked as part of the proposed block. | 2 |
  236. | app_hash | bytes | The Merkle root hash of the application state. | 3 |
  237. | tx_results | repeated [ExecTxResult](#txresult) | List of structures containing the data resulting from executing the transactions | 4 |
  238. | validator_updates | repeated [ValidatorUpdate](#validatorupdate) | Changes to validator set (set voting power to 0 to remove). | 5 |
  239. | consensus_param_updates | [ConsensusParams](#consensusparams) | Changes to consensus-critical gas, size, and other parameters. | 6 |
  240. | app_signed_updates | repeated bytes | Optional changes to the *app_signed* part of vote extensions. | 7 |
  241. * **Usage**:
  242. * The first five parameters of `RequestPrepareProposal` are the same as `RequestProcessProposal`
  243. and `RequestFinalizeBlock`.
  244. * The header contains the height, timestamp, and more - it exactly matches the
  245. Tendermint block header.
  246. * `RequestPrepareProposal` contains a preliminary set of transactions `txs` that Tendermint considers to be a good block proposal, called _raw block_. The Application can modify this set via `ResponsePrepareProposal.tx_records` (see [TxRecord](#txrecord)).
  247. * In this case, the Application should set `ResponsePrepareProposal.modified_tx` to true.
  248. * The Application _can_ reorder, remove or add transactions to the raw block. Let `tx` be a transaction in `txs`:
  249. * If the Application considers that `tx` should not be proposed in this block, e.g., there are other transactions with higher priority, then it should not include it in `tx_records`. In this case, Tendermint won't remove `tx` from the mempool. The Application should be extra-careful, as abusing this feature may cause transactions to stay forever in the mempool.
  250. * If the Application considers that a `tx` should not be included in the proposal and removed from the mempool, then the Application should include it in `tx_records` and _mark_ it as "REMOVE". In this case, Tendermint will remove `tx` from the mempool.
  251. * If the Application wants to add a new transaction, then the Application should include it in `tx_records` and _mark_ it as "ADD". In this case, Tendermint will add it to the mempool.
  252. * The Application should be aware that removing and adding transactions may compromise _traceability_.
  253. > Consider the following example: the Application transforms a client-submitted transaction `t1` into a second transaction `t2`, i.e., the Application asks Tendermint to remove `t1` and add `t2` to the mempool. If a client wants to eventually check what happened to `t1`, it will discover that `t_1` is not in the mempool or in a committed block, getting the wrong idea that `t_1` did not make it into a block. Note that `t_2` _will be_ in a committed block, but unless the Application tracks this information, no component will be aware of it. Thus, if the Application wants traceability, it is its responsability to support it. For instance, the Application could attach to a transformed transaction a list with the hashes of the transactions it derives from.
  254. * If the Application modifies the set of transactions, the modified transactions MUST NOT exceed the configured maximum size `RequestPrepareProposal.max_tx_bytes`.
  255. * If the Application does not modify the preliminary set of transactions `txs`, then it sets `ResponsePrepareProposal.modified_tx` to false. In this case, Tendermint will ignore the contents of `ResponsePrepareProposal.tx_records`.
  256. * If the Application modifies the *app_signed* part of vote extensions via `ResponsePrepareProposal.app_signed_updates`,
  257. the new total size of those extensions cannot exceed their initial size.
  258. * The Application may choose to not modify the *app_signed* part of vote extensions by leaving parameter
  259. `ResponsePrepareProposal.app_signed_updates` empty.
  260. * In same-block execution mode, the Application must provide values for `ResponsePrepareProposal.app_hash`,
  261. `ResponsePrepareProposal.tx_results`, `ResponsePrepareProposal.validator_updates`, and
  262. `ResponsePrepareProposal.consensus_param_updates`, as a result of fully executing the block.
  263. * The values for `ResponsePrepareProposal.validator_updates`, or
  264. `ResponsePrepareProposal.consensus_param_updates` may be empty. In this case, Tendermint will keep
  265. the current values.
  266. * `ResponsePrepareProposal.validator_updates`, triggered by block `H`, affect validation
  267. for blocks `H+1`, and `H+2`. Heights following a validator update are affected in the following way:
  268. * `H`: `NextValidatorsHash` includes the new `validator_updates` value.
  269. * `H+1`: The validator set change takes effect and `ValidatorsHash` is updated.
  270. * `H+2`: `local_last_commit` now includes the altered validator set.
  271. * `ResponseFinalizeBlock.consensus_param_updates` returned for block `H` apply to the consensus
  272. params for block `H+1` even if the change is agreed in block `H`.
  273. For more information on the consensus parameters,
  274. see the [application spec entry on consensus parameters](../abci/apps.md#consensus-parameters).
  275. * It is the responsibility of the Application to set the right value for _TimeoutPropose_ so that
  276. the (synchronous) execution of the block does not cause other processes to prevote `nil` because
  277. their propose timeout goes off.
  278. * In next-block execution mode, Tendermint will ignore parameters `ResponsePrepareProposal.tx_results`,
  279. `ResponsePrepareProposal.validator_updates`, and `ResponsePrepareProposal.consensus_param_updates`.
  280. * As a result of executing the prepared proposal, the Application may produce header events or transaction events.
  281. The Application must keep those events until a block is decided and then pass them on to Tendermint via
  282. `ResponseFinalizeBlock`.
  283. * Likewise, in next-block execution mode, the Application must keep all responses to executing transactions
  284. until it can call `ResponseFinalizeBlock`.
  285. * As a sanity check, Tendermint will check the returned parameters for validity if the Application modified them.
  286. In particular, `ResponsePrepareProposal.tx_records` will be deemed invalid if
  287. * There is a duplicate transaction in the list.
  288. * A new or modified transaction is marked as "TXUNMODIFIED" or "TXREMOVED".
  289. * An unmodified transaction is marked as "TXADDED".
  290. * A transaction is marked as "TXUNKNOWN".
  291. * If Tendermint's sanity checks on the parameters of `ResponsePrepareProposal` fails, then it will drop the proposal
  292. and proceed to the next round (thus simulating a network loss/delay of the proposal).
  293. * **TODO**: [From discussion with William] Another possibility here is to panic. What do folks think we should do here?
  294. * The implementation of `PrepareProposal` can be non-deterministic.
  295. #### When does Tendermint call it?
  296. When a validator _p_ enters Tendermint consensus round _r_, height _h_, in which _p_ is the proposer,
  297. and _p_'s _validValue_ is `nil`:
  298. 1. _p_'s Tendermint collects outstanding transactions from the mempool
  299. * The transactions will be collected in order of priority
  300. * Let $C$ the list of currently collected transactions
  301. * The collection stops when any of the following conditions are met
  302. * the mempool is empty
  303. * the total size of transactions $\in C$ is greater than or equal to `consensusParams.block.max_bytes`
  304. * the sum of `GasWanted` field of transactions $\in C$ is greater than or equal to
  305. `consensusParams.block.max_gas`
  306. * _p_'s Tendermint creates a block header.
  307. 2. _p_'s Tendermint calls `RequestPrepareProposal` with the newly generated block.
  308. The call is synchronous: Tendermint's execution will block until the Application returns from the call.
  309. 3. The Application checks the block (header, transactions, commit info, evidences). Besides,
  310. * in same-block execution mode, the Application can (and should) provide `ResponsePrepareProposal.app_hash`,
  311. `ResponsePrepareProposal.validator_updates`, or
  312. `ResponsePrepareProposal.consensus_param_updates`.
  313. * in "next-block execution" mode, _p_'s Tendermint will ignore the values for `ResponsePrepareProposal.app_hash`,
  314. `ResponsePrepareProposal.validator_updates`, and `ResponsePrepareProposal.consensus_param_updates`.
  315. * in both modes, the Application can manipulate transactions
  316. * leave transactions untouched - `TxAction = UNMODIFIED`
  317. * add new transactions (not previously in the mempool) - `TxAction = ADDED`
  318. * remove transactions (invalid) from the proposal and from the mempool - `TxAction = REMOVED`
  319. * remove transactions from the proposal but not from the mempool (effectively _delaying_ them) - the
  320. Application removes the transaction from the list
  321. * modify transactions (e.g. aggregate them) - `TxAction = ADDED` followed by `TxAction = REMOVED`. As explained above, this compromises client traceability, unless it is implemented at the Application level.
  322. * reorder transactions - the Application reorders transactions in the list
  323. 4. If the block is modified, the Application sets `ResponsePrepareProposal.modified` to true,
  324. and includes the modified block in the return parameters (see the rules in section _Usage_).
  325. The Application returns from the call.
  326. 5. _p_'s Tendermint uses the (possibly) modified block as _p_'s proposal in round _r_, height _h_.
  327. Note that, if _p_ has a non-`nil` _validValue_, Tendermint will use it as proposal and will not call `RequestPrepareProposal`.
  328. ### ProcessProposal
  329. #### Parameters and Types
  330. * **Request**:
  331. | Name | Type | Description | Field Number |
  332. |----------------------|---------------------------------------------|----------------------------------------------------------------------------------------------------------------|--------------|
  333. | hash | bytes | The block header's hash of the proposed block. Present for convenience (can be derived from the block header). | 1 |
  334. | header | [Header](../core/data_structures.md#header) | The proposed block's header. | 2 |
  335. | txs | repeated bytes | List of transactions that have been picked as part of the proposed block. | 3 |
  336. | proposed_last_commit | [CommitInfo](#commitinfo) | Info about the last commit, obtained from the information in the proposed block. | 4 |
  337. | byzantine_validators | repeated [Evidence](#evidence) | List of evidence of validators that acted maliciously. | 5 |
  338. * **Response**:
  339. | Name | Type | Description | Field Number |
  340. |-------------------------|--------------------------------------------------|-----------------------------------------------------------------------------------|--------------|
  341. | accept | bool | If false, the received block failed verification. | 1 |
  342. | app_hash | bytes | The Merkle root hash of the application state. | 2 |
  343. | tx_results | repeated [ExecTxResult](#txresult) | List of structures containing the data resulting from executing the transactions. | 3 |
  344. | validator_updates | repeated [ValidatorUpdate](#validatorupdate) | Changes to validator set (set voting power to 0 to remove). | 4 |
  345. | consensus_param_updates | [ConsensusParams](#consensusparams) | Changes to consensus-critical gas, size, and other parameters. | 5 |
  346. * **Usage**:
  347. * Contains a full proposed block.
  348. * The parameters and types of `RequestProcessProposal` are the same as `RequestPrepareProposal`
  349. and `RequestFinalizeBlock`.
  350. * The Application may fully execute the block as though it was handling `RequestFinalizeBlock`.
  351. However, any resulting state changes must be kept as _canditade state_,
  352. and the Application should be ready to backtrack/discard it in case the decided block is different.
  353. * The header exactly matches the Tendermint header of the proposed block.
  354. * In next-block execution mode, the header hashes _AppHash_, _LastResultHash_, _ValidatorHash_,
  355. and _ConsensusHash_ refer to the **last committed block** (data was provided by the last call to
  356. `ResponseFinalizeBlock`).
  357. * In same-block execution mode, the header hashes _AppHash_, _LastResultHash_, _ValidatorHash_,
  358. and _ConsensusHash_ refer to the **same** block being passed in the `Request*` call to this
  359. method (data was provided by the call to `ResponsePrepareProposal` at the current height that
  360. resulted in the block being passed in the `Request*` call to this method)
  361. * If `ResponseProcessProposal.accept` is _false_, Tendermint assumes the proposal received
  362. is not valid.
  363. * In same-block execution mode, the Application is required to fully execute the block and provide values
  364. for parameters `ResponseProcessProposal.app_hash`, `ResponseProcessProposal.tx_results`,
  365. `ResponseProcessProposal.validator_updates`, and `ResponseProcessProposal.consensus_param_updates`,
  366. so that Tendermint can then verify the hashes in the block's header are correct.
  367. If the hashes mismatch, Tendermint will reject the block even if `ResponseProcessProposal.accept`
  368. was set to _true_.
  369. * In next-block execution mode, the Application should *not* provide values for parameters
  370. `ResponseProcessProposal.app_hash`, `ResponseProcessProposal.tx_results`,
  371. `ResponseProcessProposal.validator_updates`, and `ResponseProcessProposal.consensus_param_updates`.
  372. * The implementation of `ProcessProposal` MUST be deterministic. Moreover, the value of
  373. `ResponseProcessProposal.accept` MUST **exclusively** depend on the parameters passed in
  374. the call to `RequestProcessProposal`, and the last committed Application state
  375. (see [Requirements](abci++_app_requirements_002_draft.md) section).
  376. * Moreover, application implementors SHOULD always set `ResponseProcessProposal.accept` to _true_,
  377. unless they _really_ know what the potential liveness implications of returning _false_ are.
  378. >**TODO**: should `ResponseProcessProposal.accept` be of type `Result` rather than `bool`? (so we are able to extend the possible values in the future?)
  379. #### When does Tendermint call it?
  380. When a validator _p_ enters Tendermint consensus round _r_, height _h_, in which _q_ is the proposer (possibly _p_ = _q_):
  381. 1. _p_ sets up timer `ProposeTimeout`.
  382. 2. If _p_ is the proposer, _p_ executes steps 1-6 in [PrepareProposal](#prepareproposal).
  383. 3. Upon reception of Proposal message (which contains the header) for round _r_, height _h_ from _q_, _p_'s Tendermint verifies the block header.
  384. 4. Upon reception of Proposal message, along with all the block parts, for round _r_, height _h_ from _q_, _p_'s Tendermint follows its algorithm
  385. to check whether it should prevote for the block just received, or `nil`
  386. 5. If Tendermint should prevote for the block just received
  387. 1. Tendermint calls `RequestProcessProposal` with the block. The call is synchronous.
  388. 2. The Application checks/processes the proposed block, which is read-only, and returns true (_accept_) or false (_reject_) in `ResponseProcessProposal.accept`.
  389. * The Application, depending on its needs, may call `ResponseProcessProposal`
  390. * either after it has completely processed the block (the simpler case),
  391. * or immediately (after doing some basic checks), and process the block asynchronously. In this case the Application will
  392. not be able to reject the block, or force prevote/precommit `nil` afterwards.
  393. 3. If the returned value is
  394. * _accept_, Tendermint prevotes on this proposal for round _r_, height _h_.
  395. * _reject_, Tendermint prevotes `nil`.
  396. ### ExtendVote
  397. #### Parameters and Types
  398. * **Request**:
  399. | Name | Type | Description | Field Number |
  400. |--------|-------|-------------------------------------------------------------------------------|--------------|
  401. | hash | bytes | The header hash of the proposed block that the vote extension is to refer to. | 1 |
  402. | height | int64 | Height of the proposed block (for sanity check). | 2 |
  403. * **Response**:
  404. | Name | Type | Description | Field Number |
  405. |-------------------|-------|-----------------------------------------------|--------------|
  406. | vote_extension | bytes | Optional information signed by by Tendermint. | 1 |
  407. * **Usage**:
  408. * `ResponseExtendVote.vote_extension` is optional information that, if present, will be signed by Tendermint and
  409. attached to the Precommit message.
  410. * `RequestExtendVote.hash` corresponds to the hash of a proposed block that was made available to the application
  411. in a previous call to `ProcessProposal` or `PrepareProposal` for the current height.
  412. * `ResponseExtendVote.vote_extension` will only be attached to a non-`nil` Precommit message. If Tendermint is to
  413. precommit `nil`, it will not call `RequestExtendVote`.
  414. * The Application logic that creates the extension can be non-deterministic.
  415. #### When does Tendermint call it?
  416. When a validator _p_ is in Tendermint consensus state _prevote_ of round _r_, height _h_, in which _q_ is the proposer; and _p_ has received
  417. * the Proposal message _v_ for round _r_, height _h_, along with all the block parts, from _q_,
  418. * `Prevote` messages from _2f + 1_ validators' voting power for round _r_, height _h_, prevoting for the same block _id(v)_,
  419. then _p_'s Tendermint locks _v_ and sends a Precommit message in the following way
  420. 1. _p_'s Tendermint sets _lockedValue_ and _validValue_ to _v_, and sets _lockedRound_ and _validRound_ to _r_
  421. 2. _p_'s Tendermint calls `RequestExtendVote` with _id(v)_ (`RequestExtendVote.hash`). The call is synchronous.
  422. 3. The Application optionally returns an array of bytes, `ResponseExtendVote.extension`, which is not interpreted by Tendermint.
  423. 4. _p_'s Tendermint includes `ResponseExtendVote.extension` in a field of type [CanonicalVoteExtension](#canonicalvoteextension),
  424. it then populates the other fields in [CanonicalVoteExtension](#canonicalvoteextension), and signs the populated
  425. data structure.
  426. 5. _p_'s Tendermint constructs and signs the [CanonicalVote](../core/data_structures.md#canonicalvote) structure.
  427. 6. _p_'s Tendermint constructs the Precommit message (i.e. [Vote](../core/data_structures.md#vote) structure)
  428. using [CanonicalVoteExtension](#canonicalvoteextension) and [CanonicalVote](../core/data_structures.md#canonicalvote).
  429. 7. _p_'s Tendermint broadcasts the Precommit message.
  430. In the cases when _p_'s Tendermint is to broadcast `precommit nil` messages (either _2f+1_ `prevote nil` messages received,
  431. or _timeoutPrevote_ triggered), _p_'s Tendermint does **not** call `RequestExtendVote` and will not include
  432. a [CanonicalVoteExtension](#canonicalvoteextension) field in the `precommit nil` message.
  433. ### VerifyVoteExtension
  434. #### Parameters and Types
  435. * **Request**:
  436. | Name | Type | Description | Field Number |
  437. |-------------------|-------|------------------------------------------------------------------------------------------|--------------|
  438. | hash | bytes | The header hash of the propsed block that the vote extension refers to. | 1 |
  439. | validator_address | bytes | [Address](../core/data_structures.md#address) of the validator that signed the extension | 2 |
  440. | height | int64 | Height of the block (for sanity check). | 3 |
  441. | vote_extension | bytes | Optional information signed by Tendermint. | 4 |
  442. * **Response**:
  443. | Name | Type | Description | Field Number |
  444. |--------|------|-------------------------------------------------------|--------------|
  445. | accept | bool | If false, Application is rejecting the vote extension | 1 |
  446. * **Usage**:
  447. * If `ResponseVerifyVoteExtension.accept` is _false_, Tendermint will reject the whole received vote.
  448. See the [Requirements](abci++_app_requirements_002_draft.md) section to understand the potential
  449. liveness implications of this.
  450. * The implementation of `VerifyVoteExtension` MUST be deterministic. Moreover, the value of
  451. `ResponseVerifyVoteExtension.accept` MUST **exclusively** depend on the parameters passed in
  452. the call to `RequestVerifyVoteExtension`, and the last committed Application state
  453. (see [Requirements](abci++_app_requirements_002_draft.md) section).
  454. * Moreover, application implementors SHOULD always set `ResponseVerifyVoteExtension.accept` to _true_,
  455. unless they _really_ know what the potential liveness implications of returning _false_ are.
  456. #### When does Tendermint call it?
  457. When a validator _p_ is in Tendermint consensus round _r_, height _h_, state _prevote_ (**TODO** discuss: I think I must remove the state
  458. from this condition, but not sure), and _p_ receives a Precommit message for round _r_, height _h_ from _q_:
  459. 1. _p_'s Tendermint calls `RequestVerifyVoteExtension`.
  460. 2. The Application returns _accept_ or _reject_ via `ResponseVerifyVoteExtension.accept`.
  461. 3. If the Application returns
  462. * _accept_, _p_'s Tendermint will keep the received vote, together with its corresponding
  463. vote extension in its internal data structures. It will be used to populate the [ExtendedCommitInfo](#extendedcommitinfo)
  464. structure in calls to `RequestPrepareProposal`, in rounds of height _h + 1_ where _p_ is the proposer.
  465. * _reject_, _p_'s Tendermint will deem the Precommit message invalid and discard it.
  466. ### FinalizeBlock
  467. #### Parameters and Types
  468. * **Request**:
  469. | Name | Type | Description | Field Number |
  470. |----------------------|---------------------------------------------|------------------------------------------------------------------------------------------|--------------|
  471. | hash | bytes | The block header's hash. Present for convenience (can be derived from the block header). | 1 |
  472. | header | [Header](../core/data_structures.md#header) | The block header. | 2 |
  473. | txs | repeated bytes | List of transactions committed as part of the block. | 3 |
  474. | decided_last_commit | [CommitInfo](#commitinfo) | Info about the last commit, obtained from the block that was just decided. | 4 |
  475. | byzantine_validators | repeated [Evidence](#evidence) | List of evidence of validators that acted maliciously. | 5 |
  476. * **Response**:
  477. | Name | Type | Description | Field Number |
  478. |-------------------------|-------------------------------------------------------------|----------------------------------------------------------------------------------|--------------|
  479. | events | repeated [Event](abci++_basic_concepts_002_draft.md#events) | Type & Key-Value events for indexing | 1 |
  480. | tx_results | repeated [ExecTxResult](#txresult) | List of structures containing the data resulting from executing the transactions | 2 |
  481. | validator_updates | repeated [ValidatorUpdate](#validatorupdate) | Changes to validator set (set voting power to 0 to remove). | 3 |
  482. | consensus_param_updates | [ConsensusParams](#consensusparams) | Changes to consensus-critical gas, size, and other parameters. | 4 |
  483. | app_hash | bytes | The Merkle root hash of the application state. | 5 |
  484. | retain_height | int64 | Blocks below this height may be removed. Defaults to `0` (retain all). | 6 |
  485. * **Usage**:
  486. * Contains a newly decided block.
  487. * This method is equivalent to the call sequence `BeginBlock`, [`DeliverTx`],
  488. `EndBlock`, `Commit` in the previous version of ABCI.
  489. * The header exactly matches the Tendermint header of the proposed block.
  490. * The Application can use `RequestFinalizeBlock.decided_last_commit` and `RequestFinalizeBlock.byzantine_validators`
  491. to determine rewards and punishments for the validators.
  492. * The application must execute the transactions in full, in the order they appear in `RequestFinalizeBlock.txs`,
  493. before returning control to Tendermint. Alternatively, it can commit the candidate state corresponding to the same block
  494. previously executed via `PrepareProposal` or `ProcessProposal`.
  495. * `ResponseFinalizeBlock.tx_results[i].Code == 0` only if the _i_-th transaction is fully valid.
  496. * In next-block execution mode, the Application must provide values for `ResponseFinalizeBlock.app_hash`,
  497. `ResponseFinalizeBlock.tx_results`, `ResponseFinalizeBlock.validator_updates`, and
  498. `ResponseFinalizeBlock.consensus_param_updates` as a result of executing the block.
  499. * The values for `ResponseFinalizeBlock.validator_updates`, or
  500. `ResponseFinalizeBlock.consensus_param_updates` may be empty. In this case, Tendermint will keep
  501. the current values.
  502. * `ResponseFinalizeBlock.validator_updates`, triggered by block `H`, affect validation
  503. for blocks `H+1`, `H+2`, and `H+3`. Heights following a validator update are affected in the following way:
  504. - Height `H+1`: `NextValidatorsHash` includes the new `validator_updates` value.
  505. - Height `H+2`: The validator set change takes effect and `ValidatorsHash` is updated.
  506. - Height `H+3`: `decided_last_commit` now includes the altered validator set.
  507. * `ResponseFinalizeBlock.consensus_param_updates` returned for block `H` apply to the consensus
  508. params for block `H+1`. For more information on the consensus parameters,
  509. see the [application spec entry on consensus parameters](../abci/apps.md#consensus-parameters).
  510. * In same-block execution mode, Tendermint will log an error and ignore values for
  511. `ResponseFinalizeBlock.app_hash`, `ResponseFinalizeBlock.tx_results`, `ResponseFinalizeBlock.validator_updates`,
  512. and `ResponsePrepareProposal.consensus_param_updates`, as those must have been provided by `PrepareProposal`.
  513. * Application is expected to persist its state at the end of this call, before calling `ResponseFinalizeBlock`.
  514. * `ResponseFinalizeBlock.app_hash` contains an (optional) Merkle root hash of the application state.
  515. * `ResponseFinalizeBlock.app_hash` is included
  516. * [in next-block execution mode] as the `Header.AppHash` in the next block.
  517. * [in same-block execution mode] as the `Header.AppHash` in the current block. In this case,
  518. `PrepareProposal` is required to fully execute the block and set the App hash before
  519. returning the proposed block to Tendermint.
  520. * `ResponseFinalizeBlock.app_hash` may also be empty or hard-coded, but MUST be
  521. **deterministic** - it must not be a function of anything that did not come from the parameters
  522. of `RequestFinalizeBlock` and the previous committed state.
  523. * Later calls to `Query` can return proofs about the application state anchored
  524. in this Merkle root hash.
  525. * Use `ResponseFinalizeBlock.retain_height` with caution! If all nodes in the network remove historical
  526. blocks then this data is permanently lost, and no new nodes will be able to join the network and
  527. bootstrap. Historical blocks may also be required for other purposes, e.g. auditing, replay of
  528. non-persisted heights, light client verification, and so on.
  529. * Just as `ProcessProposal`, the implementation of `FinalizeBlock` MUST be deterministic, since it is
  530. making the Application's state evolve in the context of state machine replication.
  531. * Currently, Tendermint will fill up all fields in `RequestFinalizeBlock`, even if they were
  532. already passed on to the Application via `RequestPrepareProposal` or `RequestProcessProposal`.
  533. If the Application is in same-block execution mode, it applies the right candidate state here
  534. (rather than executing the whole block). In this case the Application disregards all parameters in
  535. `RequestFinalizeBlock` except `RequestFinalizeBlock.hash`.
  536. #### When does Tendermint call it?
  537. When a validator _p_ is in Tendermint consensus height _h_, and _p_ receives
  538. * the Proposal message with block _v_ for a round _r_, along with all its block parts, from _q_,
  539. which is the proposer of round _r_, height _h_,
  540. * `Precommit` messages from _2f + 1_ validators' voting power for round _r_, height _h_,
  541. precommitting the same block _id(v)_,
  542. then _p_'s Tendermint decides block _v_ and finalizes consensus for height _h_ in the following way
  543. 1. _p_'s Tendermint persists _v_ as decision for height _h_.
  544. 2. _p_'s Tendermint locks the mempool -- no calls to checkTx on new transactions.
  545. 3. _p_'s Tendermint calls `RequestFinalizeBlock` with _id(v)_. The call is synchronous.
  546. 4. _p_'s Application processes block _v_, received in a previous call to `RequestProcessProposal`.
  547. 5. _p_'s Application commits and persists the state resulting from processing the block.
  548. 6. _p_'s Application calculates and returns the _AppHash_, along with an array of arrays of bytes representing the output of each of the transactions
  549. 7. _p_'s Tendermint hashes the array of transaction outputs and stores it in _ResultHash_
  550. 8. _p_'s Tendermint persists _AppHash_ and _ResultHash_
  551. 9. _p_'s Tendermint unlocks the mempool -- newly received transactions can now be checked.
  552. 10. _p_'s starts consensus for a new height _h+1_, round 0
  553. ## Data Types existing in ABCI
  554. Most of the data structures used in ABCI are shared [common data structures](../core/data_structures.md). In certain cases, ABCI uses different data structures which are documented here:
  555. ### Validator
  556. * **Fields**:
  557. | Name | Type | Description | Field Number |
  558. |---------|-------|---------------------------------------------------------------------|--------------|
  559. | address | bytes | [Address](../core/data_structures.md#address) of validator | 1 |
  560. | power | int64 | Voting power of the validator | 3 |
  561. * **Usage**:
  562. * Validator identified by address
  563. * Used in RequestBeginBlock as part of VoteInfo
  564. * Does not include PubKey to avoid sending potentially large quantum pubkeys
  565. over the ABCI
  566. ### ValidatorUpdate
  567. * **Fields**:
  568. | Name | Type | Description | Field Number |
  569. |---------|--------------------------------------------------|-------------------------------|--------------|
  570. | pub_key | [Public Key](../core/data_structures.md#pub_key) | Public key of the validator | 1 |
  571. | power | int64 | Voting power of the validator | 2 |
  572. * **Usage**:
  573. * Validator identified by PubKey
  574. * Used to tell Tendermint to update the validator set
  575. ### Evidence
  576. * **Fields**:
  577. | Name | Type | Description | Field Number |
  578. |--------------------|--------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|--------------|
  579. | type | [EvidenceType](#evidencetype) | Type of the evidence. An enum of possible evidence's. | 1 |
  580. | validator | [Validator](#validator) | The offending validator | 2 |
  581. | height | int64 | Height when the offense occurred | 3 |
  582. | time | [google.protobuf.Timestamp](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp) | Time of the block that was committed at the height that the offense occurred | 4 |
  583. | total_voting_power | int64 | Total voting power of the validator set at height `Height` | 5 |
  584. #### EvidenceType
  585. * **Fields**
  586. EvidenceType is an enum with the listed fields:
  587. | Name | Field Number |
  588. |---------------------|--------------|
  589. | UNKNOWN | 0 |
  590. | DUPLICATE_VOTE | 1 |
  591. | LIGHT_CLIENT_ATTACK | 2 |
  592. ### ConsensusParams
  593. * **Fields**:
  594. | Name | Type | Description | Field Number |
  595. |-----------|---------------------------------------------------------------|------------------------------------------------------------------------------|--------------|
  596. | block | [BlockParams](../core/data_structures.md#blockparams) | Parameters limiting the size of a block and time between consecutive blocks. | 1 |
  597. | evidence | [EvidenceParams](../core/data_structures.md#evidenceparams) | Parameters limiting the validity of evidence of byzantine behaviour. | 2 |
  598. | validator | [ValidatorParams](../core/data_structures.md#validatorparams) | Parameters limiting the types of public keys validators can use. | 3 |
  599. | version | [VersionsParams](../core/data_structures.md#versionparams) | The ABCI application version. | 4 |
  600. ### ProofOps
  601. * **Fields**:
  602. | Name | Type | Description | Field Number |
  603. |------|------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
  604. | ops | repeated [ProofOp](#proofop) | List of chained Merkle proofs, of possibly different types. The Merkle root of one op is the value being proven in the next op. The Merkle root of the final op should equal the ultimate root hash being verified against.. | 1 |
  605. ### ProofOp
  606. * **Fields**:
  607. | Name | Type | Description | Field Number |
  608. |------|--------|------------------------------------------------|--------------|
  609. | type | string | Type of Merkle proof and how it's encoded. | 1 |
  610. | key | bytes | Key in the Merkle tree that this proof is for. | 2 |
  611. | data | bytes | Encoded Merkle proof for the key. | 3 |
  612. ### Snapshot
  613. * **Fields**:
  614. | Name | Type | Description | Field Number |
  615. |----------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
  616. | height | uint64 | The height at which the snapshot was taken (after commit). | 1 |
  617. | format | uint32 | An application-specific snapshot format, allowing applications to version their snapshot data format and make backwards-incompatible changes. Tendermint does not interpret this. | 2 |
  618. | chunks | uint32 | The number of chunks in the snapshot. Must be at least 1 (even if empty). | 3 |
  619. | hash | bytes | TAn arbitrary snapshot hash. Must be equal only for identical snapshots across nodes. Tendermint does not interpret the hash, it only compares them. | 3 |
  620. | metadata | bytes | Arbitrary application metadata, for example chunk hashes or other verification data. | 3 |
  621. * **Usage**:
  622. * Used for state sync snapshots, see the [state sync section](../p2p/messages/state-sync.md) for details.
  623. * A snapshot is considered identical across nodes only if _all_ fields are equal (including
  624. `Metadata`). Chunks may be retrieved from all nodes that have the same snapshot.
  625. * When sent across the network, a snapshot message can be at most 4 MB.
  626. ## Data types introduced or modified in ABCI++
  627. ### VoteInfo
  628. * **Fields**:
  629. | Name | Type | Description | Field Number |
  630. |-----------------------------|-------------------------|----------------------------------------------------------------|--------------|
  631. | validator | [Validator](#validator) | The validator that sent the vote. | 1 |
  632. | signed_last_block | bool | Indicates whether or not the validator signed the last block. | 2 |
  633. * **Usage**:
  634. * Indicates whether a validator signed the last block, allowing for rewards based on validator availability.
  635. * This information is typically extracted from a proposed or decided block.
  636. ### ExtendedVoteInfo
  637. * **Fields**:
  638. | Name | Type | Description | Field Number |
  639. |-------------------|-------------------------|------------------------------------------------------------------------------|--------------|
  640. | validator | [Validator](#validator) | The validator that sent the vote. | 1 |
  641. | signed_last_block | bool | Indicates whether or not the validator signed the last block. | 2 |
  642. | vote_extension | bytes | Non-deterministic extension provided by the sending validator's Application. | 3 |
  643. * **Usage**:
  644. * Indicates whether a validator signed the last block, allowing for rewards based on validator availability.
  645. * This information is extracted from Tendermint's data structures in the local process.
  646. * `vote_extension` contains the sending validator's vote extension, which is signed by Tendermint. It can be empty
  647. ### CommitInfo
  648. * **Fields**:
  649. | Name | Type | Description | Field Number |
  650. |-------|--------------------------------|----------------------------------------------------------------------------------------------|--------------|
  651. | round | int32 | Commit round. Reflects the round at which the block proposer decided in the previous height. | 1 |
  652. | votes | repeated [VoteInfo](#voteinfo) | List of validators' addresses in the last validator set with their voting information. | 2 |
  653. ### ExtendedCommitInfo
  654. * **Fields**:
  655. | Name | Type | Description | Field Number |
  656. |-------|------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|--------------|
  657. | round | int32 | Commit round. Reflects the round at which the block proposer decided in the previous height. | 1 |
  658. | votes | repeated [ExtendedVoteInfo](#extendedvoteinfo) | List of validators' addresses in the last validator set with their voting information, including vote extensions. | 2 |
  659. ### ExecTxResult
  660. * **Fields**:
  661. | Name | Type | Description | Field Number |
  662. |------------|-------------------------------------------------------------|-----------------------------------------------------------------------|--------------|
  663. | code | uint32 | Response code. | 1 |
  664. | data | bytes | Result bytes, if any. | 2 |
  665. | log | string | The output of the application's logger. **May be non-deterministic.** | 3 |
  666. | info | string | Additional information. **May be non-deterministic.** | 4 |
  667. | gas_wanted | int64 | Amount of gas requested for transaction. | 5 |
  668. | gas_used | int64 | Amount of gas consumed by transaction. | 6 |
  669. | events | repeated [Event](abci++_basic_concepts_002_draft.md#events) | Type & Key-Value events for indexing transactions (e.g. by account). | 7 |
  670. | codespace | string | Namespace for the `code`. | 8 |
  671. ### TxAction
  672. ```protobuf
  673. enum TxAction {
  674. TXUNKNOWN = 0; // Unknown action
  675. TXUNMODIFIED = 1; // The Application did not modify this transaction.
  676. TXADDED = 2; // The Application added this transaction.
  677. TXREMOVED = 3; // The Application wants this transaction removed from the proposal and the mempool.
  678. }
  679. ```
  680. * **Usage**:
  681. * If `Action` is TXUNKNOWN, a problem happened in the Application. Tendermint will ignore this transaction. **TODO** should we panic?
  682. * If `Action` is TXUNMODIFIED, Tendermint includes the transaction in the proposal. Nothing to do on the mempool.
  683. * If `Action` is TXADDED, Tendermint includes the transaction in the proposal. The transaction is also added to the mempool and gossipped.
  684. * If `Action` is TXREMOVED, Tendermint excludes the transaction from the proposal. The transaction is also removed from the mempool if it exists,
  685. similar to `CheckTx` returning _false_.
  686. ### TxRecord
  687. * **Fields**:
  688. | Name | Type | Description | Field Number |
  689. |------------|-----------------------|------------------------------------------------------------------|--------------|
  690. | action | [TxAction](#txaction) | What should Tendermint do with this transaction? | 1 |
  691. | tx | bytes | Transaction contents | 2 |
  692. ### CanonicalVoteExtension
  693. >**TODO**: This protobuf message definition is not part of the ABCI++ interface, but rather belongs to the
  694. > Precommit message which is broadcast via P2P. So it is to be moved to the relevant section of the spec.
  695. * **Fields**:
  696. | Name | Type | Description | Field Number |
  697. |-----------|--------|--------------------------------------------------------------------------------------------|--------------|
  698. | extension | bytes | Vote extension provided by the Application. | 1 |
  699. | height | int64 | Height in which the extension was provided. | 2 |
  700. | round | int32 | Round in which the extension was provided. | 3 |
  701. | chain_id | string | ID of the blockchain running consensus. | 4 |
  702. | address | bytes | [Address](../core/data_structures.md#address) of the validator that provided the extension | 5 |
  703. * **Usage**:
  704. * Tendermint is to sign the whole data structure and attach it to a Precommit message
  705. * Upon reception, Tendermint validates the sender's signature and sanity-checks the values of `height`, `round`, and `chain_id`.
  706. Then it sends `extension` to the Application via `RequestVerifyVoteExtension` for verification.