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.

347 lines
9.7 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 "libs/kv/types.proto";
  9. import "google/protobuf/timestamp.proto";
  10. import "google/protobuf/duration.proto";
  11. // This file is copied from http://github.com/tendermint/abci
  12. // NOTE: When using custom types, mind the warnings.
  13. // https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues
  14. option (gogoproto.marshaler_all) = true;
  15. option (gogoproto.unmarshaler_all) = true;
  16. option (gogoproto.sizer_all) = true;
  17. option (gogoproto.goproto_registration) = true;
  18. // Generate tests
  19. option (gogoproto.populate_all) = true;
  20. option (gogoproto.equal_all) = true;
  21. option (gogoproto.testgen_all) = true;
  22. //----------------------------------------
  23. // Request types
  24. message Request {
  25. oneof value {
  26. RequestEcho echo = 2;
  27. RequestFlush flush = 3;
  28. RequestInfo info = 4;
  29. RequestSetOption set_option = 5;
  30. RequestInitChain init_chain = 6;
  31. RequestQuery query = 7;
  32. RequestBeginBlock begin_block = 8;
  33. RequestCheckTx check_tx = 9;
  34. RequestDeliverTx deliver_tx = 19;
  35. RequestEndBlock end_block = 11;
  36. RequestCommit commit = 12;
  37. }
  38. }
  39. message RequestEcho {
  40. string message = 1;
  41. }
  42. message RequestFlush {}
  43. message RequestInfo {
  44. string version = 1;
  45. uint64 block_version = 2;
  46. uint64 p2p_version = 3;
  47. }
  48. // nondeterministic
  49. message RequestSetOption {
  50. string key = 1;
  51. string value = 2;
  52. }
  53. message RequestInitChain {
  54. google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  55. string chain_id = 2;
  56. ConsensusParams consensus_params = 3;
  57. repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false];
  58. bytes app_state_bytes = 5;
  59. }
  60. message RequestQuery {
  61. bytes data = 1;
  62. string path = 2;
  63. int64 height = 3;
  64. bool prove = 4;
  65. }
  66. message RequestBeginBlock {
  67. bytes hash = 1;
  68. Header header = 2 [(gogoproto.nullable) = false];
  69. LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false];
  70. repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false];
  71. }
  72. enum CheckTxType {
  73. New = 0;
  74. Recheck = 1;
  75. }
  76. message RequestCheckTx {
  77. bytes tx = 1;
  78. CheckTxType type = 2;
  79. }
  80. message RequestDeliverTx {
  81. bytes tx = 1;
  82. }
  83. message RequestEndBlock {
  84. int64 height = 1;
  85. }
  86. message RequestCommit {}
  87. //----------------------------------------
  88. // Response types
  89. message Response {
  90. oneof value {
  91. ResponseException exception = 1;
  92. ResponseEcho echo = 2;
  93. ResponseFlush flush = 3;
  94. ResponseInfo info = 4;
  95. ResponseSetOption set_option = 5;
  96. ResponseInitChain init_chain = 6;
  97. ResponseQuery query = 7;
  98. ResponseBeginBlock begin_block = 8;
  99. ResponseCheckTx check_tx = 9;
  100. ResponseDeliverTx deliver_tx = 10;
  101. ResponseEndBlock end_block = 11;
  102. ResponseCommit commit = 12;
  103. }
  104. }
  105. // nondeterministic
  106. message ResponseException {
  107. string error = 1;
  108. }
  109. message ResponseEcho {
  110. string message = 1;
  111. }
  112. message ResponseFlush {}
  113. message ResponseInfo {
  114. string data = 1;
  115. string version = 2;
  116. uint64 app_version = 3;
  117. int64 last_block_height = 4;
  118. bytes last_block_app_hash = 5;
  119. }
  120. // nondeterministic
  121. message ResponseSetOption {
  122. uint32 code = 1;
  123. // bytes data = 2;
  124. string log = 3;
  125. string info = 4;
  126. }
  127. message ResponseInitChain {
  128. ConsensusParams consensus_params = 1;
  129. repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false];
  130. }
  131. message ResponseQuery {
  132. uint32 code = 1;
  133. // bytes data = 2; // use "value" instead.
  134. string log = 3; // nondeterministic
  135. string info = 4; // nondeterministic
  136. int64 index = 5;
  137. bytes key = 6;
  138. bytes value = 7;
  139. tendermint.crypto.merkle.Proof proof = 8;
  140. int64 height = 9;
  141. string codespace = 10;
  142. }
  143. message ResponseBeginBlock {
  144. repeated Event events = 1
  145. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  146. }
  147. message ResponseCheckTx {
  148. uint32 code = 1;
  149. bytes data = 2;
  150. string log = 3; // nondeterministic
  151. string info = 4; // nondeterministic
  152. int64 gas_wanted = 5;
  153. int64 gas_used = 6;
  154. repeated Event events = 7
  155. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  156. string codespace = 8;
  157. }
  158. message ResponseDeliverTx {
  159. uint32 code = 1;
  160. bytes data = 2;
  161. string log = 3; // nondeterministic
  162. string info = 4; // nondeterministic
  163. int64 gas_wanted = 5;
  164. int64 gas_used = 6;
  165. repeated Event events = 7
  166. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  167. string codespace = 8;
  168. }
  169. message ResponseEndBlock {
  170. repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable) = false];
  171. ConsensusParams consensus_param_updates = 2;
  172. repeated Event events = 3
  173. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
  174. }
  175. message ResponseCommit {
  176. // reserve 1
  177. bytes data = 2;
  178. int64 retain_height = 3;
  179. }
  180. //----------------------------------------
  181. // Misc.
  182. // ConsensusParams contains all consensus-relevant parameters
  183. // that can be adjusted by the abci app
  184. message ConsensusParams {
  185. BlockParams block = 1;
  186. EvidenceParams evidence = 2;
  187. ValidatorParams validator = 3;
  188. }
  189. // BlockParams contains limits on the block size.
  190. message BlockParams {
  191. // Note: must be greater than 0
  192. int64 max_bytes = 1;
  193. // Note: must be greater or equal to -1
  194. int64 max_gas = 2;
  195. }
  196. message EvidenceParams {
  197. // Note: must be greater than 0
  198. int64 max_age_num_blocks = 1;
  199. google.protobuf.Duration max_age_duration = 2
  200. [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
  201. }
  202. // ValidatorParams contains limits on validators.
  203. message ValidatorParams {
  204. repeated string pub_key_types = 1;
  205. }
  206. message LastCommitInfo {
  207. int32 round = 1;
  208. repeated VoteInfo votes = 2 [(gogoproto.nullable) = false];
  209. }
  210. message Event {
  211. string type = 1;
  212. repeated tendermint.libs.kv.Pair attributes = 2
  213. [(gogoproto.nullable) = false, (gogoproto.jsontag) = "attributes,omitempty"];
  214. }
  215. //----------------------------------------
  216. // Blockchain Types
  217. message Header {
  218. // basic block info
  219. Version version = 1 [(gogoproto.nullable) = false];
  220. string chain_id = 2 [(gogoproto.customname) = "ChainID"];
  221. int64 height = 3;
  222. google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  223. // prev block info
  224. BlockID last_block_id = 5 [(gogoproto.nullable) = false];
  225. // hashes of block data
  226. bytes last_commit_hash = 6; // commit from validators from the last block
  227. bytes data_hash = 7; // transactions
  228. // hashes from the app output from the prev block
  229. bytes validators_hash = 8; // validators for the current block
  230. bytes next_validators_hash = 9; // validators for the next block
  231. bytes consensus_hash = 10; // consensus params for current block
  232. bytes app_hash = 11; // state after txs from the previous block
  233. bytes last_results_hash = 12; // root hash of all results from the txs from the previous block
  234. // consensus info
  235. bytes evidence_hash = 13; // evidence included in the block
  236. bytes proposer_address = 14; // original proposer of the block
  237. }
  238. message Version {
  239. uint64 Block = 1;
  240. uint64 App = 2;
  241. }
  242. message BlockID {
  243. bytes hash = 1;
  244. PartSetHeader parts_header = 2 [(gogoproto.nullable) = false];
  245. }
  246. message PartSetHeader {
  247. int32 total = 1;
  248. bytes hash = 2;
  249. }
  250. // Validator
  251. message Validator {
  252. bytes address = 1;
  253. // PubKey pub_key = 2 [(gogoproto.nullable)=false];
  254. int64 power = 3;
  255. }
  256. // ValidatorUpdate
  257. message ValidatorUpdate {
  258. PubKey pub_key = 1 [(gogoproto.nullable) = false];
  259. int64 power = 2;
  260. }
  261. // VoteInfo
  262. message VoteInfo {
  263. Validator validator = 1 [(gogoproto.nullable) = false];
  264. bool signed_last_block = 2;
  265. }
  266. message PubKey {
  267. string type = 1;
  268. bytes data = 2;
  269. }
  270. message Evidence {
  271. string type = 1;
  272. Validator validator = 2 [(gogoproto.nullable) = false];
  273. int64 height = 3;
  274. google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  275. int64 total_voting_power = 5;
  276. }
  277. //----------------------------------------
  278. // Service Definition
  279. service ABCIApplication {
  280. rpc Echo(RequestEcho) returns (ResponseEcho);
  281. rpc Flush(RequestFlush) returns (ResponseFlush);
  282. rpc Info(RequestInfo) returns (ResponseInfo);
  283. rpc SetOption(RequestSetOption) returns (ResponseSetOption);
  284. rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx);
  285. rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx);
  286. rpc Query(RequestQuery) returns (ResponseQuery);
  287. rpc Commit(RequestCommit) returns (ResponseCommit);
  288. rpc InitChain(RequestInitChain) returns (ResponseInitChain);
  289. rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock);
  290. rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock);
  291. }