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.

510 lines
17 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. syntax = "proto3";
  2. package tendermint.abci;
  3. option go_package = "github.com/tendermint/tendermint/abci/types";
  4. // For more information on gogo.proto, see:
  5. // https://github.com/gogo/protobuf/blob/master/extensions.md
  6. import "tendermint/crypto/proof.proto";
  7. import "tendermint/types/types.proto";
  8. import "tendermint/crypto/keys.proto";
  9. import "tendermint/types/params.proto";
  10. import "google/protobuf/timestamp.proto";
  11. import "gogoproto/gogo.proto";
  12. // This file is copied from http://github.com/tendermint/abci
  13. // NOTE: When using custom types, mind the warnings.
  14. // https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues
  15. //----------------------------------------
  16. // Request types
  17. message Request {
  18. oneof value {
  19. RequestEcho echo = 1;
  20. RequestFlush flush = 2;
  21. RequestInfo info = 3;
  22. RequestInitChain init_chain = 4;
  23. RequestQuery query = 5;
  24. RequestBeginBlock begin_block = 6 [deprecated = true];
  25. RequestCheckTx check_tx = 7;
  26. RequestDeliverTx deliver_tx = 8 [deprecated = true];
  27. RequestEndBlock end_block = 9 [deprecated = true];
  28. RequestCommit commit = 10;
  29. RequestListSnapshots list_snapshots = 11;
  30. RequestOfferSnapshot offer_snapshot = 12;
  31. RequestLoadSnapshotChunk load_snapshot_chunk = 13;
  32. RequestApplySnapshotChunk apply_snapshot_chunk = 14;
  33. RequestPrepareProposal prepare_proposal = 15;
  34. RequestProcessProposal process_proposal = 16;
  35. RequestExtendVote extend_vote = 17;
  36. RequestVerifyVoteExtension verify_vote_extension = 18;
  37. RequestFinalizeBlock finalize_block = 19;
  38. }
  39. }
  40. message RequestEcho {
  41. string message = 1;
  42. }
  43. message RequestFlush {}
  44. message RequestInfo {
  45. string version = 1;
  46. uint64 block_version = 2;
  47. uint64 p2p_version = 3;
  48. string abci_version = 4;
  49. }
  50. message RequestInitChain {
  51. google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  52. string chain_id = 2;
  53. tendermint.types.ConsensusParams consensus_params = 3;
  54. repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false];
  55. bytes app_state_bytes = 5;
  56. int64 initial_height = 6;
  57. }
  58. message RequestQuery {
  59. bytes data = 1;
  60. string path = 2;
  61. int64 height = 3;
  62. bool prove = 4;
  63. }
  64. message RequestBeginBlock {
  65. bytes hash = 1;
  66. tendermint.types.Header header = 2 [(gogoproto.nullable) = false];
  67. CommitInfo last_commit_info = 3 [(gogoproto.nullable) = false];
  68. repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false];
  69. }
  70. enum CheckTxType {
  71. NEW = 0 [(gogoproto.enumvalue_customname) = "New"];
  72. RECHECK = 1 [(gogoproto.enumvalue_customname) = "Recheck"];
  73. }
  74. message RequestCheckTx {
  75. bytes tx = 1;
  76. CheckTxType type = 2;
  77. }
  78. message RequestDeliverTx {
  79. bytes tx = 1;
  80. }
  81. message RequestEndBlock {
  82. int64 height = 1;
  83. }
  84. message RequestCommit {}
  85. // lists available snapshots
  86. message RequestListSnapshots {}
  87. // offers a snapshot to the application
  88. message RequestOfferSnapshot {
  89. Snapshot snapshot = 1; // snapshot offered by peers
  90. bytes app_hash = 2; // light client-verified app hash for snapshot height
  91. }
  92. // loads a snapshot chunk
  93. message RequestLoadSnapshotChunk {
  94. uint64 height = 1;
  95. uint32 format = 2;
  96. uint32 chunk = 3;
  97. }
  98. // Applies a snapshot chunk
  99. message RequestApplySnapshotChunk {
  100. uint32 index = 1;
  101. bytes chunk = 2;
  102. string sender = 3;
  103. }
  104. message RequestPrepareProposal {
  105. bytes hash = 1;
  106. tendermint.types.Header header = 2 [(gogoproto.nullable) = false];
  107. // txs is an array of transactions that will be included in a block,
  108. // sent to the app for possible modifications.
  109. repeated bytes txs = 3;
  110. ExtendedCommitInfo local_last_commit = 4 [(gogoproto.nullable) = false];
  111. repeated Evidence byzantine_validators = 5 [(gogoproto.nullable) = false];
  112. // the modified transactions cannot exceed this size.
  113. int64 max_tx_bytes = 6;
  114. }
  115. message RequestProcessProposal {
  116. bytes hash = 1;
  117. tendermint.types.Header header = 2 [(gogoproto.nullable) = false];
  118. repeated bytes txs = 3;
  119. CommitInfo proposed_last_commit = 4 [(gogoproto.nullable) = false];
  120. repeated Evidence byzantine_validators = 5 [(gogoproto.nullable) = false];
  121. }
  122. // Extends a vote with application-side injection
  123. message RequestExtendVote {
  124. bytes hash = 1;
  125. int64 height = 2;
  126. }
  127. // Verify the vote extension
  128. message RequestVerifyVoteExtension {
  129. bytes hash = 1;
  130. bytes validator_address = 2;
  131. int64 height = 3;
  132. bytes vote_extension = 4;
  133. }
  134. message RequestFinalizeBlock {
  135. bytes hash = 1;
  136. tendermint.types.Header header = 2 [(gogoproto.nullable) = false];
  137. repeated bytes txs = 3;
  138. CommitInfo decided_last_commit = 4 [(gogoproto.nullable) = false];
  139. repeated Evidence byzantine_validators = 5 [(gogoproto.nullable) = false];
  140. }
  141. //----------------------------------------
  142. // Response types
  143. message Response {
  144. oneof value {
  145. ResponseException exception = 1;
  146. ResponseEcho echo = 2;
  147. ResponseFlush flush = 3;
  148. ResponseInfo info = 4;
  149. ResponseInitChain init_chain = 5;
  150. ResponseQuery query = 6;
  151. ResponseBeginBlock begin_block = 7 [deprecated = true];
  152. ResponseCheckTx check_tx = 8;
  153. ResponseDeliverTx deliver_tx = 9 [deprecated = true];
  154. ResponseEndBlock end_block = 10 [deprecated = true];
  155. ResponseCommit commit = 11;
  156. ResponseListSnapshots list_snapshots = 12;
  157. ResponseOfferSnapshot offer_snapshot = 13;
  158. ResponseLoadSnapshotChunk load_snapshot_chunk = 14;
  159. ResponseApplySnapshotChunk apply_snapshot_chunk = 15;
  160. ResponsePrepareProposal prepare_proposal = 16;
  161. ResponseProcessProposal process_proposal = 17;
  162. ResponseExtendVote extend_vote = 18;
  163. ResponseVerifyVoteExtension verify_vote_extension = 19;
  164. ResponseFinalizeBlock finalize_block = 20;
  165. }
  166. }
  167. // nondeterministic
  168. message ResponseException {
  169. string error = 1;
  170. }
  171. message ResponseEcho {
  172. string message = 1;
  173. }
  174. message ResponseFlush {}
  175. message ResponseInfo {
  176. string data = 1;
  177. // this is the software version of the application. TODO: remove?
  178. string version = 2;
  179. uint64 app_version = 3;
  180. int64 last_block_height = 4;
  181. bytes last_block_app_hash = 5;
  182. }
  183. message ResponseInitChain {
  184. tendermint.types.ConsensusParams consensus_params = 1;
  185. repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false];
  186. bytes app_hash = 3;
  187. }
  188. message ResponseQuery {
  189. uint32 code = 1;
  190. // bytes data = 2; // use "value" instead.
  191. string log = 3; // nondeterministic
  192. string info = 4; // nondeterministic
  193. int64 index = 5;
  194. bytes key = 6;
  195. bytes value = 7;
  196. tendermint.crypto.ProofOps proof_ops = 8;
  197. int64 height = 9;
  198. string codespace = 10;
  199. }
  200. message ResponseBeginBlock {
  201. repeated Event events = 1 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  202. }
  203. message ResponseCheckTx {
  204. uint32 code = 1;
  205. bytes data = 2;
  206. string log = 3; // nondeterministic
  207. string info = 4; // nondeterministic
  208. int64 gas_wanted = 5;
  209. int64 gas_used = 6;
  210. repeated Event events = 7 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  211. string codespace = 8;
  212. string sender = 9;
  213. int64 priority = 10;
  214. // mempool_error is set by Tendermint.
  215. // ABCI applications creating a ResponseCheckTX should not set mempool_error.
  216. string mempool_error = 11;
  217. }
  218. message ResponseDeliverTx {
  219. uint32 code = 1;
  220. bytes data = 2;
  221. string log = 3; // nondeterministic
  222. string info = 4; // nondeterministic
  223. int64 gas_wanted = 5 [json_name = "gas_wanted"];
  224. int64 gas_used = 6 [json_name = "gas_used"];
  225. repeated Event events = 7
  226. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; // nondeterministic
  227. string codespace = 8;
  228. }
  229. message ResponseEndBlock {
  230. repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable) = false];
  231. tendermint.types.ConsensusParams consensus_param_updates = 2;
  232. repeated Event events = 3 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  233. }
  234. message ResponseCommit {
  235. // reserve 1
  236. bytes data = 2;
  237. int64 retain_height = 3;
  238. }
  239. message ResponseListSnapshots {
  240. repeated Snapshot snapshots = 1;
  241. }
  242. message ResponseOfferSnapshot {
  243. Result result = 1;
  244. enum Result {
  245. UNKNOWN = 0; // Unknown result, abort all snapshot restoration
  246. ACCEPT = 1; // Snapshot accepted, apply chunks
  247. ABORT = 2; // Abort all snapshot restoration
  248. REJECT = 3; // Reject this specific snapshot, try others
  249. REJECT_FORMAT = 4; // Reject all snapshots of this format, try others
  250. REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others
  251. }
  252. }
  253. message ResponseLoadSnapshotChunk {
  254. bytes chunk = 1;
  255. }
  256. message ResponseApplySnapshotChunk {
  257. Result result = 1;
  258. repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply
  259. repeated string reject_senders = 3; // Chunk senders to reject and ban
  260. enum Result {
  261. UNKNOWN = 0; // Unknown result, abort all snapshot restoration
  262. ACCEPT = 1; // Chunk successfully accepted
  263. ABORT = 2; // Abort all snapshot restoration
  264. RETRY = 3; // Retry chunk (combine with refetch and reject)
  265. RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject)
  266. REJECT_SNAPSHOT = 5; // Reject this snapshot, try others
  267. }
  268. }
  269. message ResponsePrepareProposal {
  270. bool modified_tx = 1;
  271. repeated TxRecord tx_records = 2;
  272. bytes app_hash = 3;
  273. repeated ExecTxResult tx_results = 4;
  274. repeated ValidatorUpdate validator_updates = 5;
  275. tendermint.types.ConsensusParams consensus_param_updates = 6;
  276. repeated bytes app_signed_updates = 7;
  277. }
  278. message ResponseProcessProposal {
  279. bool accept = 1;
  280. bytes app_hash = 2;
  281. repeated ExecTxResult tx_results = 3;
  282. repeated ValidatorUpdate validator_updates = 4;
  283. tendermint.types.ConsensusParams consensus_param_updates = 5;
  284. }
  285. message ResponseExtendVote {
  286. bytes vote_extension = 1;
  287. }
  288. message ResponseVerifyVoteExtension {
  289. bool accept = 1;
  290. }
  291. message ResponseFinalizeBlock {
  292. repeated Event events = 1
  293. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  294. repeated ExecTxResult tx_results = 2;
  295. repeated ValidatorUpdate validator_updates = 3;
  296. tendermint.types.ConsensusParams consensus_param_updates = 4;
  297. bytes app_hash = 5;
  298. int64 retain_height = 6;
  299. }
  300. //----------------------------------------
  301. // Misc.
  302. message CommitInfo {
  303. int32 round = 1;
  304. repeated VoteInfo votes = 2 [(gogoproto.nullable) = false];
  305. }
  306. message ExtendedCommitInfo {
  307. int32 round = 1;
  308. repeated ExtendedVoteInfo votes = 2 [(gogoproto.nullable) = false];
  309. }
  310. // Event allows application developers to attach additional information to
  311. // ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx.
  312. // Later, transactions may be queried using these events.
  313. message Event {
  314. string type = 1;
  315. repeated EventAttribute attributes = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "attributes,omitempty"];
  316. }
  317. // EventAttribute is a single key-value pair, associated with an event.
  318. message EventAttribute {
  319. string key = 1;
  320. string value = 2;
  321. bool index = 3; // nondeterministic
  322. }
  323. // ExecTxResult contains results of executing one individual transaction.
  324. //
  325. // * Its structure is equivalent to #ResponseDeliverTx which will be deprecated/deleted
  326. message ExecTxResult {
  327. uint32 code = 1;
  328. bytes data = 2;
  329. string log = 3; // nondeterministic
  330. string info = 4; // nondeterministic
  331. int64 gas_wanted = 5;
  332. int64 gas_used = 6;
  333. repeated Event events = 7
  334. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; // nondeterministic
  335. string codespace = 8;
  336. }
  337. // TxResult contains results of executing the transaction.
  338. //
  339. // One usage is indexing transaction results.
  340. message TxResult {
  341. int64 height = 1;
  342. uint32 index = 2;
  343. bytes tx = 3;
  344. ResponseDeliverTx result = 4 [(gogoproto.nullable) = false];
  345. }
  346. message TxRecord {
  347. TxAction action = 1;
  348. bytes tx = 2;
  349. // TxAction contains App-provided information on what to do with a transaction that is part of a raw proposal
  350. enum TxAction {
  351. UNKNOWN = 0; // Unknown action
  352. UNMODIFIED = 1; // The Application did not modify this transaction.
  353. ADDED = 2; // The Application added this transaction.
  354. REMOVED = 3; // The Application wants this transaction removed from the proposal and the mempool.
  355. }
  356. }
  357. //----------------------------------------
  358. // Blockchain Types
  359. // Validator
  360. message Validator {
  361. bytes address = 1; // The first 20 bytes of SHA256(public key)
  362. // PubKey pub_key = 2 [(gogoproto.nullable)=false];
  363. int64 power = 3; // The voting power
  364. }
  365. // ValidatorUpdate
  366. message ValidatorUpdate {
  367. tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false];
  368. int64 power = 2;
  369. }
  370. // VoteInfo
  371. message VoteInfo {
  372. Validator validator = 1 [(gogoproto.nullable) = false];
  373. bool signed_last_block = 2;
  374. }
  375. // ExtendedVoteInfo
  376. message ExtendedVoteInfo {
  377. Validator validator = 1 [(gogoproto.nullable) = false];
  378. bool signed_last_block = 2;
  379. bytes vote_extension = 3;
  380. }
  381. // CanonicalVoteExtension
  382. // TODO: move this to core Tendermint data structures
  383. message CanonicalVoteExtension {
  384. bytes extension = 1;
  385. int64 height = 2;
  386. int32 round = 3;
  387. string chain_id = 4;
  388. bytes address = 5;
  389. }
  390. enum EvidenceType {
  391. UNKNOWN = 0;
  392. DUPLICATE_VOTE = 1;
  393. LIGHT_CLIENT_ATTACK = 2;
  394. }
  395. message Evidence {
  396. EvidenceType type = 1;
  397. // The offending validator
  398. Validator validator = 2 [(gogoproto.nullable) = false];
  399. // The height when the offense occurred
  400. int64 height = 3;
  401. // The corresponding time where the offense occurred
  402. google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  403. // Total voting power of the validator set in case the ABCI application does
  404. // not store historical validators.
  405. // https://github.com/tendermint/tendermint/issues/4581
  406. int64 total_voting_power = 5;
  407. }
  408. //----------------------------------------
  409. // State Sync Types
  410. message Snapshot {
  411. uint64 height = 1; // The height at which the snapshot was taken
  412. uint32 format = 2; // The application-specific snapshot format
  413. uint32 chunks = 3; // Number of chunks in the snapshot
  414. bytes hash = 4; // Arbitrary snapshot hash, equal only if identical
  415. bytes metadata = 5; // Arbitrary application metadata
  416. }
  417. //----------------------------------------
  418. // Service Definition
  419. service ABCIApplication {
  420. rpc Echo(RequestEcho) returns (ResponseEcho);
  421. rpc Flush(RequestFlush) returns (ResponseFlush);
  422. rpc Info(RequestInfo) returns (ResponseInfo);
  423. rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx);
  424. rpc Query(RequestQuery) returns (ResponseQuery);
  425. rpc Commit(RequestCommit) returns (ResponseCommit);
  426. rpc InitChain(RequestInitChain) returns (ResponseInitChain);
  427. rpc ListSnapshots(RequestListSnapshots) returns (ResponseListSnapshots);
  428. rpc OfferSnapshot(RequestOfferSnapshot) returns (ResponseOfferSnapshot);
  429. rpc LoadSnapshotChunk(RequestLoadSnapshotChunk) returns (ResponseLoadSnapshotChunk);
  430. rpc ApplySnapshotChunk(RequestApplySnapshotChunk) returns (ResponseApplySnapshotChunk);
  431. rpc PrepareProposal(RequestPrepareProposal) returns (ResponsePrepareProposal);
  432. rpc ProcessProposal(RequestProcessProposal) returns (ResponseProcessProposal);
  433. rpc ExtendVote(RequestExtendVote) returns (ResponseExtendVote);
  434. rpc VerifyVoteExtension(RequestVerifyVoteExtension) returns (ResponseVerifyVoteExtension);
  435. rpc FinalizeBlock(RequestFinalizeBlock) returns (ResponseFinalizeBlock);
  436. }