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.

344 lines
8.5 KiB

8 years ago
7 years ago
7 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
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
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 types;
  3. // For more information on gogo.proto, see:
  4. // https://github.com/gogo/protobuf/blob/master/extensions.md
  5. import "github.com/gogo/protobuf/gogoproto/gogo.proto";
  6. import "github.com/tendermint/tendermint/crypto/merkle/merkle.proto";
  7. import "github.com/tendermint/tendermint/libs/common/types.proto";
  8. import "google/protobuf/timestamp.proto";
  9. // This file is copied from http://github.com/tendermint/abci
  10. // NOTE: When using custom types, mind the warnings.
  11. // https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues
  12. option (gogoproto.marshaler_all) = true;
  13. option (gogoproto.unmarshaler_all) = true;
  14. option (gogoproto.sizer_all) = true;
  15. option (gogoproto.goproto_registration) = true;
  16. // Generate tests
  17. option (gogoproto.populate_all) = true;
  18. option (gogoproto.equal_all) = true;
  19. option (gogoproto.testgen_all) = true;
  20. //----------------------------------------
  21. // Request types
  22. message Request {
  23. oneof value {
  24. RequestEcho echo = 2;
  25. RequestFlush flush = 3;
  26. RequestInfo info = 4;
  27. RequestSetOption set_option = 5;
  28. RequestInitChain init_chain = 6;
  29. RequestQuery query = 7;
  30. RequestBeginBlock begin_block = 8;
  31. RequestCheckTx check_tx = 9;
  32. RequestDeliverTx deliver_tx = 19;
  33. RequestEndBlock end_block = 11;
  34. RequestCommit commit = 12;
  35. }
  36. }
  37. message RequestEcho {
  38. string message = 1;
  39. }
  40. message RequestFlush {
  41. }
  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. //----------------------------------------
  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. }
  114. message ResponseInfo {
  115. string data = 1;
  116. string version = 2;
  117. uint64 app_version = 3;
  118. int64 last_block_height = 4;
  119. bytes last_block_app_hash = 5;
  120. }
  121. // nondeterministic
  122. message ResponseSetOption {
  123. uint32 code = 1;
  124. // bytes data = 2;
  125. string log = 3;
  126. string info = 4;
  127. }
  128. message ResponseInitChain {
  129. ConsensusParams consensus_params = 1;
  130. repeated ValidatorUpdate validators = 2 [(gogoproto.nullable)=false];
  131. }
  132. message ResponseQuery {
  133. uint32 code = 1;
  134. // bytes data = 2; // use "value" instead.
  135. string log = 3; // nondeterministic
  136. string info = 4; // nondeterministic
  137. int64 index = 5;
  138. bytes key = 6;
  139. bytes value = 7;
  140. merkle.Proof proof = 8;
  141. int64 height = 9;
  142. string codespace = 10;
  143. }
  144. message ResponseBeginBlock {
  145. repeated Event events = 1 [(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 [(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 [(gogoproto.nullable)=false, (gogoproto.jsontag)="events,omitempty"];
  165. string codespace = 8;
  166. }
  167. message ResponseEndBlock {
  168. repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable)=false];
  169. ConsensusParams consensus_param_updates = 2;
  170. repeated Event events = 3 [(gogoproto.nullable)=false, (gogoproto.jsontag)="events,omitempty"];
  171. }
  172. message ResponseCommit {
  173. // reserve 1
  174. bytes data = 2;
  175. }
  176. //----------------------------------------
  177. // Misc.
  178. // ConsensusParams contains all consensus-relevant parameters
  179. // that can be adjusted by the abci app
  180. message ConsensusParams {
  181. BlockParams block = 1;
  182. EvidenceParams evidence = 2;
  183. ValidatorParams validator = 3;
  184. }
  185. // BlockParams contains limits on the block size.
  186. message BlockParams {
  187. // Note: must be greater than 0
  188. int64 max_bytes = 1;
  189. // Note: must be greater or equal to -1
  190. int64 max_gas = 2;
  191. }
  192. // EvidenceParams contains limits on the evidence.
  193. message EvidenceParams {
  194. // Note: must be greater than 0
  195. int64 max_age = 1;
  196. }
  197. // ValidatorParams contains limits on validators.
  198. message ValidatorParams {
  199. repeated string pub_key_types = 1;
  200. }
  201. message LastCommitInfo {
  202. int32 round = 1;
  203. repeated VoteInfo votes = 2 [(gogoproto.nullable)=false];
  204. }
  205. message Event {
  206. string type = 1;
  207. repeated common.KVPair attributes = 2 [(gogoproto.nullable)=false, (gogoproto.jsontag)="attributes,omitempty"];
  208. }
  209. //----------------------------------------
  210. // Blockchain Types
  211. message Header {
  212. // basic block info
  213. Version version = 1 [(gogoproto.nullable)=false];
  214. string chain_id = 2 [(gogoproto.customname)="ChainID"];
  215. int64 height = 3;
  216. google.protobuf.Timestamp time = 4 [(gogoproto.nullable)=false, (gogoproto.stdtime)=true];
  217. int64 num_txs = 5;
  218. int64 total_txs = 6;
  219. // prev block info
  220. BlockID last_block_id = 7 [(gogoproto.nullable)=false];
  221. // hashes of block data
  222. bytes last_commit_hash = 8; // commit from validators from the last block
  223. bytes data_hash = 9; // transactions
  224. // hashes from the app output from the prev block
  225. bytes validators_hash = 10; // validators for the current block
  226. bytes next_validators_hash = 11; // validators for the next block
  227. bytes consensus_hash = 12; // consensus params for current block
  228. bytes app_hash = 13; // state after txs from the previous block
  229. bytes last_results_hash = 14;// root hash of all results from the txs from the previous block
  230. // consensus info
  231. bytes evidence_hash = 15; // evidence included in the block
  232. bytes proposer_address = 16; // original proposer of the block
  233. }
  234. message Version {
  235. uint64 Block = 1;
  236. uint64 App = 2;
  237. }
  238. message BlockID {
  239. bytes hash = 1;
  240. PartSetHeader parts_header = 2 [(gogoproto.nullable)=false];
  241. }
  242. message PartSetHeader {
  243. int32 total = 1;
  244. bytes hash = 2;
  245. }
  246. // Validator
  247. message Validator {
  248. bytes address = 1;
  249. //PubKey pub_key = 2 [(gogoproto.nullable)=false];
  250. int64 power = 3;
  251. }
  252. // ValidatorUpdate
  253. message ValidatorUpdate {
  254. PubKey pub_key = 1 [(gogoproto.nullable)=false];
  255. int64 power = 2;
  256. }
  257. // VoteInfo
  258. message VoteInfo {
  259. Validator validator = 1 [(gogoproto.nullable)=false];
  260. bool signed_last_block = 2;
  261. }
  262. message PubKey {
  263. string type = 1;
  264. bytes data = 2;
  265. }
  266. message Evidence {
  267. string type = 1;
  268. Validator validator = 2 [(gogoproto.nullable)=false];
  269. int64 height = 3;
  270. google.protobuf.Timestamp time = 4 [(gogoproto.nullable)=false, (gogoproto.stdtime)=true];
  271. int64 total_voting_power = 5;
  272. }
  273. //----------------------------------------
  274. // Service Definition
  275. service ABCIApplication {
  276. rpc Echo(RequestEcho) returns (ResponseEcho) ;
  277. rpc Flush(RequestFlush) returns (ResponseFlush);
  278. rpc Info(RequestInfo) returns (ResponseInfo);
  279. rpc SetOption(RequestSetOption) returns (ResponseSetOption);
  280. rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx);
  281. rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx);
  282. rpc Query(RequestQuery) returns (ResponseQuery);
  283. rpc Commit(RequestCommit) returns (ResponseCommit);
  284. rpc InitChain(RequestInitChain) returns (ResponseInitChain);
  285. rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock);
  286. rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock);
  287. }