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.

354 lines
9.8 KiB

8 years ago
7 years ago
add support for block pruning via ABCI Commit response (#4588) * Added BlockStore.DeleteBlock() * Added initial block pruner prototype * wip * Added BlockStore.PruneBlocks() * Added consensus setting for block pruning * Added BlockStore base * Error on replay if base does not have blocks * Handle missing blocks when sending VoteSetMaj23Message * Error message tweak * Properly update blockstore state * Error message fix again * blockchain: ignore peer missing blocks * Added FIXME * Added test for block replay with truncated history * Handle peer base in blockchain reactor * Improved replay error handling * Added tests for Store.PruneBlocks() * Fix non-RPC handling of truncated block history * Panic on missing block meta in needProofBlock() * Updated changelog * Handle truncated block history in RPC layer * Added info about earliest block in /status RPC * Reorder height and base in blockchain reactor messages * Updated changelog * Fix tests * Appease linter * Minor review fixes * Non-empty BlockStores should always have base > 0 * Update code to assume base > 0 invariant * Added blockstore tests for pruning to 0 * Make sure we don't prune below the current base * Added BlockStore.Size() * config: added retain_blocks recommendations * Update v1 blockchain reactor to handle blockstore base * Added state database pruning * Propagate errors on missing validator sets * Comment tweaks * Improved error message Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * use ABCI field ResponseCommit.retain_height instead of retain-blocks config option * remove State.RetainHeight, return value instead * fix minor issues * rename pruneHeights() to pruneBlocks() * noop to fix GitHub borkage Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
5 years ago
abci: Refactor tagging events using list of lists (#3643) ## PR This PR introduces a fundamental breaking change to the structure of ABCI response and tx tags and the way they're processed. Namely, the SDK can support more complex and aggregated events for distribution and slashing. In addition, block responses can include duplicate keys in events. Implement new Event type. An event has a type and a list of KV pairs (ie. list-of-lists). Typical events may look like: "rewards": [{"amount": "5000uatom", "validator": "...", "recipient": "..."}] "sender": [{"address": "...", "balance": "100uatom"}] The events are indexed by {even.type}.{even.attribute[i].key}/.... In this case a client would subscribe or query for rewards.recipient='...' ABCI response types and related types now include Events []Event instead of Tags []cmn.KVPair. PubSub logic now publishes/matches against map[string][]string instead of map[string]string to support duplicate keys in response events (from #1385). A match is successful if the value is found in the slice of strings. closes: #1859 closes: #2905 ## Commits: * Implement Event ABCI type and updates responses to use events * Update messages_test.go * Update kvstore.go * Update event_bus.go * Update subscription.go * Update pubsub.go * Update kvstore.go * Update query logic to handle slice of strings in events * Update Empty#Matches and unit tests * Update pubsub logic * Update EventBus#Publish * Update kv tx indexer * Update godocs * Update ResultEvent to use slice of strings; update RPC * Update more tests * Update abci.md * Check for key in validateAndStringifyEvents * Fix KV indexer to skip empty keys * Fix linting errors * Update CHANGELOG_PENDING.md * Update docs/spec/abci/abci.md Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update abci/types/types.proto Co-Authored-By: Ethan Buchman <ethan@coinculture.info> * Update docs/spec/abci/abci.md Co-Authored-By: Ethan Buchman <ethan@coinculture.info> * Update libs/pubsub/query/query.go Co-Authored-By: Ethan Buchman <ethan@coinculture.info> * Update match function to match if ANY value matches * Implement TestSubscribeDuplicateKeys * Update TestMatches to include multi-key test cases * Update events.go * Update Query interface godoc * Update match godoc * Add godoc for matchValue * DRY-up tx indexing * Return error from PublishWithEvents in EventBus#Publish * Update PublishEventNewBlockHeader to return an error * Fix build * Update events doc in ABCI * Update ABCI events godoc * Implement TestEventBusPublishEventTxDuplicateKeys * Update TestSubscribeDuplicateKeys to be table-driven * Remove mod file * Remove markdown from events godoc * Implement TestTxSearchDeprecatedIndexing test
6 years ago
abci: Refactor tagging events using list of lists (#3643) ## PR This PR introduces a fundamental breaking change to the structure of ABCI response and tx tags and the way they're processed. Namely, the SDK can support more complex and aggregated events for distribution and slashing. In addition, block responses can include duplicate keys in events. Implement new Event type. An event has a type and a list of KV pairs (ie. list-of-lists). Typical events may look like: "rewards": [{"amount": "5000uatom", "validator": "...", "recipient": "..."}] "sender": [{"address": "...", "balance": "100uatom"}] The events are indexed by {even.type}.{even.attribute[i].key}/.... In this case a client would subscribe or query for rewards.recipient='...' ABCI response types and related types now include Events []Event instead of Tags []cmn.KVPair. PubSub logic now publishes/matches against map[string][]string instead of map[string]string to support duplicate keys in response events (from #1385). A match is successful if the value is found in the slice of strings. closes: #1859 closes: #2905 ## Commits: * Implement Event ABCI type and updates responses to use events * Update messages_test.go * Update kvstore.go * Update event_bus.go * Update subscription.go * Update pubsub.go * Update kvstore.go * Update query logic to handle slice of strings in events * Update Empty#Matches and unit tests * Update pubsub logic * Update EventBus#Publish * Update kv tx indexer * Update godocs * Update ResultEvent to use slice of strings; update RPC * Update more tests * Update abci.md * Check for key in validateAndStringifyEvents * Fix KV indexer to skip empty keys * Fix linting errors * Update CHANGELOG_PENDING.md * Update docs/spec/abci/abci.md Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update abci/types/types.proto Co-Authored-By: Ethan Buchman <ethan@coinculture.info> * Update docs/spec/abci/abci.md Co-Authored-By: Ethan Buchman <ethan@coinculture.info> * Update libs/pubsub/query/query.go Co-Authored-By: Ethan Buchman <ethan@coinculture.info> * Update match function to match if ANY value matches * Implement TestSubscribeDuplicateKeys * Update TestMatches to include multi-key test cases * Update events.go * Update Query interface godoc * Update match godoc * Add godoc for matchValue * DRY-up tx indexing * Return error from PublishWithEvents in EventBus#Publish * Update PublishEventNewBlockHeader to return an error * Fix build * Update events doc in ABCI * Update ABCI events godoc * Implement TestEventBusPublishEventTxDuplicateKeys * Update TestSubscribeDuplicateKeys to be table-driven * Remove mod file * Remove markdown from events godoc * Implement TestTxSearchDeprecatedIndexing test
6 years ago
8 years ago
  1. syntax = "proto3";
  2. package tendermint.abci.types;
  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 "third_party/proto/gogoproto/gogo.proto";
  7. import "crypto/merkle/merkle.proto";
  8. import "google/protobuf/timestamp.proto";
  9. import "google/protobuf/duration.proto";
  10. // This file is copied from http://github.com/tendermint/abci
  11. // NOTE: When using custom types, mind the warnings.
  12. // https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues
  13. option (gogoproto.marshaler_all) = true;
  14. option (gogoproto.unmarshaler_all) = true;
  15. option (gogoproto.sizer_all) = true;
  16. option (gogoproto.goproto_registration) = true;
  17. // Generate tests
  18. option (gogoproto.populate_all) = true;
  19. option (gogoproto.equal_all) = true;
  20. option (gogoproto.testgen_all) = true;
  21. //----------------------------------------
  22. // Request types
  23. message Request {
  24. oneof value {
  25. RequestEcho echo = 2;
  26. RequestFlush flush = 3;
  27. RequestInfo info = 4;
  28. RequestSetOption set_option = 5;
  29. RequestInitChain init_chain = 6;
  30. RequestQuery query = 7;
  31. RequestBeginBlock begin_block = 8;
  32. RequestCheckTx check_tx = 9;
  33. RequestDeliverTx deliver_tx = 19;
  34. RequestEndBlock end_block = 11;
  35. RequestCommit commit = 12;
  36. }
  37. }
  38. message RequestEcho {
  39. string message = 1;
  40. }
  41. message RequestFlush {}
  42. message RequestInfo {
  43. string version = 1;
  44. uint64 block_version = 2;
  45. uint64 p2p_version = 3;
  46. }
  47. // nondeterministic
  48. message RequestSetOption {
  49. string key = 1;
  50. string value = 2;
  51. }
  52. message RequestInitChain {
  53. google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  54. string chain_id = 2;
  55. ConsensusParams consensus_params = 3;
  56. repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false];
  57. bytes app_state_bytes = 5;
  58. }
  59. message RequestQuery {
  60. bytes data = 1;
  61. string path = 2;
  62. int64 height = 3;
  63. bool prove = 4;
  64. }
  65. message RequestBeginBlock {
  66. bytes hash = 1;
  67. Header header = 2 [(gogoproto.nullable) = false];
  68. LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false];
  69. repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false];
  70. }
  71. enum CheckTxType {
  72. New = 0;
  73. Recheck = 1;
  74. }
  75. message RequestCheckTx {
  76. bytes tx = 1;
  77. CheckTxType type = 2;
  78. }
  79. message RequestDeliverTx {
  80. bytes tx = 1;
  81. }
  82. message RequestEndBlock {
  83. int64 height = 1;
  84. }
  85. message RequestCommit {}
  86. //----------------------------------------
  87. // Response types
  88. message Response {
  89. oneof value {
  90. ResponseException exception = 1;
  91. ResponseEcho echo = 2;
  92. ResponseFlush flush = 3;
  93. ResponseInfo info = 4;
  94. ResponseSetOption set_option = 5;
  95. ResponseInitChain init_chain = 6;
  96. ResponseQuery query = 7;
  97. ResponseBeginBlock begin_block = 8;
  98. ResponseCheckTx check_tx = 9;
  99. ResponseDeliverTx deliver_tx = 10;
  100. ResponseEndBlock end_block = 11;
  101. ResponseCommit commit = 12;
  102. }
  103. }
  104. // nondeterministic
  105. message ResponseException {
  106. string error = 1;
  107. }
  108. message ResponseEcho {
  109. string message = 1;
  110. }
  111. message ResponseFlush {}
  112. message ResponseInfo {
  113. string data = 1;
  114. string version = 2;
  115. uint64 app_version = 3;
  116. int64 last_block_height = 4;
  117. bytes last_block_app_hash = 5;
  118. }
  119. // nondeterministic
  120. message ResponseSetOption {
  121. uint32 code = 1;
  122. // bytes data = 2;
  123. string log = 3;
  124. string info = 4;
  125. }
  126. message ResponseInitChain {
  127. ConsensusParams consensus_params = 1;
  128. repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false];
  129. }
  130. message ResponseQuery {
  131. uint32 code = 1;
  132. // bytes data = 2; // use "value" instead.
  133. string log = 3; // nondeterministic
  134. string info = 4; // nondeterministic
  135. int64 index = 5;
  136. bytes key = 6;
  137. bytes value = 7;
  138. tendermint.crypto.merkle.Proof proof = 8;
  139. int64 height = 9;
  140. string codespace = 10;
  141. }
  142. message ResponseBeginBlock {
  143. repeated Event events = 1
  144. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  145. }
  146. message ResponseCheckTx {
  147. uint32 code = 1;
  148. bytes data = 2;
  149. string log = 3; // nondeterministic
  150. string info = 4; // nondeterministic
  151. int64 gas_wanted = 5;
  152. int64 gas_used = 6;
  153. repeated Event events = 7
  154. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  155. string codespace = 8;
  156. }
  157. message ResponseDeliverTx {
  158. uint32 code = 1;
  159. bytes data = 2;
  160. string log = 3; // nondeterministic
  161. string info = 4; // nondeterministic
  162. int64 gas_wanted = 5;
  163. int64 gas_used = 6;
  164. repeated Event events = 7
  165. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  166. string codespace = 8;
  167. }
  168. message ResponseEndBlock {
  169. repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable) = false];
  170. ConsensusParams consensus_param_updates = 2;
  171. repeated Event events = 3
  172. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  173. }
  174. message ResponseCommit {
  175. // reserve 1
  176. bytes data = 2;
  177. int64 retain_height = 3;
  178. }
  179. //----------------------------------------
  180. // Misc.
  181. // ConsensusParams contains all consensus-relevant parameters
  182. // that can be adjusted by the abci app
  183. message ConsensusParams {
  184. BlockParams block = 1;
  185. EvidenceParams evidence = 2;
  186. ValidatorParams validator = 3;
  187. }
  188. // BlockParams contains limits on the block size.
  189. message BlockParams {
  190. // Note: must be greater than 0
  191. int64 max_bytes = 1;
  192. // Note: must be greater or equal to -1
  193. int64 max_gas = 2;
  194. }
  195. message EvidenceParams {
  196. // Note: must be greater than 0
  197. int64 max_age_num_blocks = 1;
  198. google.protobuf.Duration max_age_duration = 2
  199. [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
  200. }
  201. // ValidatorParams contains limits on validators.
  202. message ValidatorParams {
  203. repeated string pub_key_types = 1;
  204. }
  205. message LastCommitInfo {
  206. int32 round = 1;
  207. repeated VoteInfo votes = 2 [(gogoproto.nullable) = false];
  208. }
  209. // EventAttribute represents an event to the indexing service.
  210. message EventAttribute {
  211. bytes key = 1;
  212. bytes value = 2;
  213. bool index = 3;
  214. }
  215. message Event {
  216. string type = 1;
  217. repeated EventAttribute attributes = 2
  218. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "attributes,omitempty"];
  219. }
  220. //----------------------------------------
  221. // Blockchain Types
  222. message Header {
  223. // basic block info
  224. Version version = 1 [(gogoproto.nullable) = false];
  225. string chain_id = 2 [(gogoproto.customname) = "ChainID"];
  226. int64 height = 3;
  227. google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  228. // prev block info
  229. BlockID last_block_id = 5 [(gogoproto.nullable) = false];
  230. // hashes of block data
  231. bytes last_commit_hash = 6; // commit from validators from the last block
  232. bytes data_hash = 7; // transactions
  233. // hashes from the app output from the prev block
  234. bytes validators_hash = 8; // validators for the current block
  235. bytes next_validators_hash = 9; // validators for the next block
  236. bytes consensus_hash = 10; // consensus params for current block
  237. bytes app_hash = 11; // state after txs from the previous block
  238. bytes last_results_hash = 12; // root hash of all results from the txs from the previous block
  239. // consensus info
  240. bytes evidence_hash = 13; // evidence included in the block
  241. bytes proposer_address = 14; // original proposer of the block
  242. }
  243. message Version {
  244. uint64 Block = 1;
  245. uint64 App = 2;
  246. }
  247. message BlockID {
  248. bytes hash = 1;
  249. PartSetHeader parts_header = 2 [(gogoproto.nullable) = false];
  250. }
  251. message PartSetHeader {
  252. int32 total = 1;
  253. bytes hash = 2;
  254. }
  255. // Validator
  256. message Validator {
  257. bytes address = 1;
  258. // PubKey pub_key = 2 [(gogoproto.nullable)=false];
  259. int64 power = 3;
  260. }
  261. // ValidatorUpdate
  262. message ValidatorUpdate {
  263. PubKey pub_key = 1 [(gogoproto.nullable) = false];
  264. int64 power = 2;
  265. }
  266. // VoteInfo
  267. message VoteInfo {
  268. Validator validator = 1 [(gogoproto.nullable) = false];
  269. bool signed_last_block = 2;
  270. }
  271. message PubKey {
  272. string type = 1;
  273. bytes data = 2;
  274. }
  275. message Evidence {
  276. string type = 1;
  277. Validator validator = 2 [(gogoproto.nullable) = false];
  278. int64 height = 3;
  279. google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  280. int64 total_voting_power = 5;
  281. }
  282. //----------------------------------------
  283. // Service Definition
  284. service ABCIApplication {
  285. rpc Echo(RequestEcho) returns (ResponseEcho);
  286. rpc Flush(RequestFlush) returns (ResponseFlush);
  287. rpc Info(RequestInfo) returns (ResponseInfo);
  288. rpc SetOption(RequestSetOption) returns (ResponseSetOption);
  289. rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx);
  290. rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx);
  291. rpc Query(RequestQuery) returns (ResponseQuery);
  292. rpc Commit(RequestCommit) returns (ResponseCommit);
  293. rpc InitChain(RequestInitChain) returns (ResponseInitChain);
  294. rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock);
  295. rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock);
  296. }