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.

527 lines
18 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
  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. ModifiedTxStatus modified_tx_status = 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. enum ModifiedTxStatus {
  277. UNKNOWN = 0;
  278. UNMODIFIED = 1;
  279. MODIFIED = 2;
  280. }
  281. }
  282. message ResponseProcessProposal {
  283. ProposalStatus status = 1;
  284. bytes app_hash = 2;
  285. repeated ExecTxResult tx_results = 3;
  286. repeated ValidatorUpdate validator_updates = 4;
  287. tendermint.types.ConsensusParams consensus_param_updates = 5;
  288. enum ProposalStatus {
  289. UNKNOWN = 0;
  290. ACCEPT = 1;
  291. REJECT = 2;
  292. }
  293. }
  294. message ResponseExtendVote {
  295. bytes vote_extension = 1;
  296. }
  297. message ResponseVerifyVoteExtension {
  298. VerifyStatus status = 1;
  299. enum VerifyStatus {
  300. UNKNOWN = 0;
  301. ACCEPT = 1;
  302. REJECT = 2;
  303. }
  304. }
  305. message ResponseFinalizeBlock {
  306. repeated Event events = 1
  307. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  308. repeated ExecTxResult tx_results = 2;
  309. repeated ValidatorUpdate validator_updates = 3;
  310. tendermint.types.ConsensusParams consensus_param_updates = 4;
  311. bytes app_hash = 5;
  312. int64 retain_height = 6;
  313. }
  314. //----------------------------------------
  315. // Misc.
  316. message CommitInfo {
  317. int32 round = 1;
  318. repeated VoteInfo votes = 2 [(gogoproto.nullable) = false];
  319. }
  320. message ExtendedCommitInfo {
  321. int32 round = 1;
  322. repeated ExtendedVoteInfo votes = 2 [(gogoproto.nullable) = false];
  323. }
  324. // Event allows application developers to attach additional information to
  325. // ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx.
  326. // Later, transactions may be queried using these events.
  327. message Event {
  328. string type = 1;
  329. repeated EventAttribute attributes = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "attributes,omitempty"];
  330. }
  331. // EventAttribute is a single key-value pair, associated with an event.
  332. message EventAttribute {
  333. string key = 1;
  334. string value = 2;
  335. bool index = 3; // nondeterministic
  336. }
  337. // ExecTxResult contains results of executing one individual transaction.
  338. //
  339. // * Its structure is equivalent to #ResponseDeliverTx which will be deprecated/deleted
  340. message ExecTxResult {
  341. uint32 code = 1;
  342. bytes data = 2;
  343. string log = 3; // nondeterministic
  344. string info = 4; // nondeterministic
  345. int64 gas_wanted = 5;
  346. int64 gas_used = 6;
  347. repeated Event events = 7
  348. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; // nondeterministic
  349. string codespace = 8;
  350. }
  351. // TxResult contains results of executing the transaction.
  352. //
  353. // One usage is indexing transaction results.
  354. message TxResult {
  355. int64 height = 1;
  356. uint32 index = 2;
  357. bytes tx = 3;
  358. ResponseDeliverTx result = 4 [(gogoproto.nullable) = false];
  359. }
  360. message TxRecord {
  361. TxAction action = 1;
  362. bytes tx = 2;
  363. // TxAction contains App-provided information on what to do with a transaction that is part of a raw proposal
  364. enum TxAction {
  365. UNKNOWN = 0; // Unknown action
  366. UNMODIFIED = 1; // The Application did not modify this transaction.
  367. ADDED = 2; // The Application added this transaction.
  368. REMOVED = 3; // The Application wants this transaction removed from the proposal and the mempool.
  369. }
  370. }
  371. //----------------------------------------
  372. // Blockchain Types
  373. // Validator
  374. message Validator {
  375. bytes address = 1; // The first 20 bytes of SHA256(public key)
  376. // PubKey pub_key = 2 [(gogoproto.nullable)=false];
  377. int64 power = 3; // The voting power
  378. }
  379. // ValidatorUpdate
  380. message ValidatorUpdate {
  381. tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false];
  382. int64 power = 2;
  383. }
  384. // VoteInfo
  385. message VoteInfo {
  386. Validator validator = 1 [(gogoproto.nullable) = false];
  387. bool signed_last_block = 2;
  388. }
  389. // ExtendedVoteInfo
  390. message ExtendedVoteInfo {
  391. Validator validator = 1 [(gogoproto.nullable) = false];
  392. bool signed_last_block = 2;
  393. bytes vote_extension = 3;
  394. }
  395. // CanonicalVoteExtension
  396. // TODO: move this to core Tendermint data structures
  397. message CanonicalVoteExtension {
  398. bytes extension = 1;
  399. int64 height = 2;
  400. int32 round = 3;
  401. string chain_id = 4;
  402. bytes address = 5;
  403. }
  404. enum EvidenceType {
  405. UNKNOWN = 0;
  406. DUPLICATE_VOTE = 1;
  407. LIGHT_CLIENT_ATTACK = 2;
  408. }
  409. message Evidence {
  410. EvidenceType type = 1;
  411. // The offending validator
  412. Validator validator = 2 [(gogoproto.nullable) = false];
  413. // The height when the offense occurred
  414. int64 height = 3;
  415. // The corresponding time where the offense occurred
  416. google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  417. // Total voting power of the validator set in case the ABCI application does
  418. // not store historical validators.
  419. // https://github.com/tendermint/tendermint/issues/4581
  420. int64 total_voting_power = 5;
  421. }
  422. //----------------------------------------
  423. // State Sync Types
  424. message Snapshot {
  425. uint64 height = 1; // The height at which the snapshot was taken
  426. uint32 format = 2; // The application-specific snapshot format
  427. uint32 chunks = 3; // Number of chunks in the snapshot
  428. bytes hash = 4; // Arbitrary snapshot hash, equal only if identical
  429. bytes metadata = 5; // Arbitrary application metadata
  430. }
  431. //----------------------------------------
  432. // Service Definition
  433. service ABCIApplication {
  434. rpc Echo(RequestEcho) returns (ResponseEcho);
  435. rpc Flush(RequestFlush) returns (ResponseFlush);
  436. rpc Info(RequestInfo) returns (ResponseInfo);
  437. rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx);
  438. rpc Query(RequestQuery) returns (ResponseQuery);
  439. rpc Commit(RequestCommit) returns (ResponseCommit);
  440. rpc InitChain(RequestInitChain) returns (ResponseInitChain);
  441. rpc ListSnapshots(RequestListSnapshots) returns (ResponseListSnapshots);
  442. rpc OfferSnapshot(RequestOfferSnapshot) returns (ResponseOfferSnapshot);
  443. rpc LoadSnapshotChunk(RequestLoadSnapshotChunk) returns (ResponseLoadSnapshotChunk);
  444. rpc ApplySnapshotChunk(RequestApplySnapshotChunk) returns (ResponseApplySnapshotChunk);
  445. rpc PrepareProposal(RequestPrepareProposal) returns (ResponsePrepareProposal);
  446. rpc ProcessProposal(RequestProcessProposal) returns (ResponseProcessProposal);
  447. rpc ExtendVote(RequestExtendVote) returns (ResponseExtendVote);
  448. rpc VerifyVoteExtension(RequestVerifyVoteExtension) returns (ResponseVerifyVoteExtension);
  449. rpc FinalizeBlock(RequestFinalizeBlock) returns (ResponseFinalizeBlock);
  450. }