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.

277 lines
5.6 KiB

  1. syntax = "proto3";
  2. package types;
  3. // This file is copied from http://github.com/tendermint/tmsp
  4. //----------------------------------------
  5. // Message types
  6. // Not being used
  7. // Could be added to request/response
  8. // so we don't have to type switch
  9. // (would be twice as fast, but we're talking about 15ns)
  10. enum MessageType {
  11. NullMessage = 0x00;
  12. Echo = 0x01;
  13. Flush = 0x02;
  14. Info = 0x03;
  15. SetOption = 0x04;
  16. Exception = 0x05;
  17. AppendTx = 0x11;
  18. CheckTx = 0x12;
  19. Commit = 0x13;
  20. Query = 0x14;
  21. InitChain = 0x15;
  22. BeginBlock = 0x16;
  23. EndBlock = 0x17;
  24. }
  25. //----------------------------------------
  26. // Code types
  27. enum CodeType {
  28. OK = 0;
  29. // General response codes, 0 ~ 99
  30. InternalError = 1;
  31. EncodingError = 2;
  32. BadNonce = 3;
  33. Unauthorized = 4;
  34. InsufficientFunds = 5;
  35. UnknownRequest = 6;
  36. // Reserved for basecoin, 100 ~ 199
  37. BaseDuplicateAddress = 101;
  38. BaseEncodingError = 102;
  39. BaseInsufficientFees = 103;
  40. BaseInsufficientFunds = 104;
  41. BaseInsufficientGasPrice = 105;
  42. BaseInvalidInput = 106;
  43. BaseInvalidOutput = 107;
  44. BaseInvalidPubKey = 108;
  45. BaseInvalidSequence = 109;
  46. BaseInvalidSignature = 110;
  47. BaseUnknownAddress = 111;
  48. BaseUnknownPubKey = 112;
  49. BaseUnknownPlugin = 113;
  50. // Reserved for governance, 200 ~ 299
  51. GovUnknownEntity = 201;
  52. GovUnknownGroup = 202;
  53. GovUnknownProposal = 203;
  54. GovDuplicateGroup = 204;
  55. GovDuplicateMember = 205;
  56. GovDuplicateProposal = 206;
  57. GovDuplicateVote = 207;
  58. GovInvalidMember = 208;
  59. GovInvalidVote = 209;
  60. GovInvalidVotingPower = 210;
  61. }
  62. //----------------------------------------
  63. // Request types
  64. message Request {
  65. oneof value{
  66. RequestEcho echo = 1;
  67. RequestFlush flush = 2;
  68. RequestInfo info = 3;
  69. RequestSetOption set_option = 4;
  70. RequestAppendTx append_tx = 5;
  71. RequestCheckTx check_tx = 6;
  72. RequestCommit commit = 7;
  73. RequestQuery query = 8;
  74. RequestInitChain init_chain = 9;
  75. RequestBeginBlock begin_block = 10;
  76. RequestEndBlock end_block = 11;
  77. }
  78. }
  79. message RequestEcho {
  80. string message = 1;
  81. }
  82. message RequestFlush {
  83. }
  84. message RequestInfo {
  85. }
  86. message RequestSetOption{
  87. string key = 1;
  88. string value = 2;
  89. }
  90. message RequestAppendTx{
  91. bytes tx = 1;
  92. }
  93. message RequestCheckTx{
  94. bytes tx = 1;
  95. }
  96. message RequestQuery{
  97. bytes query = 1;
  98. }
  99. message RequestCommit{
  100. }
  101. message RequestInitChain{
  102. repeated Validator validators = 1;
  103. }
  104. message RequestBeginBlock{
  105. bytes hash = 1;
  106. Header header = 2;
  107. }
  108. message RequestEndBlock{
  109. uint64 height = 1;
  110. }
  111. //----------------------------------------
  112. // Response types
  113. message Response {
  114. oneof value{
  115. ResponseException exception = 1;
  116. ResponseEcho echo = 2;
  117. ResponseFlush flush = 3;
  118. ResponseInfo info = 4;
  119. ResponseSetOption set_option = 5;
  120. ResponseAppendTx append_tx = 6;
  121. ResponseCheckTx check_tx = 7;
  122. ResponseCommit commit = 8;
  123. ResponseQuery query = 9;
  124. ResponseInitChain init_chain = 10;
  125. ResponseBeginBlock begin_block = 11;
  126. ResponseEndBlock end_block = 12;
  127. }
  128. }
  129. message ResponseException{
  130. string error = 1;
  131. }
  132. message ResponseEcho {
  133. string message = 1;
  134. }
  135. message ResponseFlush{
  136. }
  137. message ResponseInfo {
  138. string info = 1; // backwards compatible
  139. TMSPInfo tmsp_info = 2;
  140. LastBlockInfo last_block = 3;
  141. ConfigInfo config = 4;
  142. }
  143. message ResponseSetOption{
  144. string log = 1;
  145. }
  146. message ResponseAppendTx{
  147. CodeType code = 1;
  148. bytes data = 2;
  149. string log = 3;
  150. }
  151. message ResponseCheckTx{
  152. CodeType code = 1;
  153. bytes data = 2;
  154. string log = 3;
  155. }
  156. message ResponseQuery{
  157. CodeType code = 1;
  158. bytes data = 2;
  159. string log = 3;
  160. }
  161. message ResponseCommit{
  162. CodeType code = 1;
  163. bytes data = 2;
  164. string log = 3;
  165. }
  166. message ResponseInitChain{
  167. }
  168. message ResponseBeginBlock{
  169. }
  170. message ResponseEndBlock{
  171. repeated Validator diffs = 4;
  172. }
  173. //----------------------------------------
  174. // Info types
  175. message TMSPInfo {
  176. string Version = 1;
  177. }
  178. message LastBlockInfo {
  179. uint64 block_height = 1;
  180. bytes app_hash = 2;
  181. }
  182. message ConfigInfo {
  183. uint64 max_block_size_bytes = 1;
  184. uint64 max_block_size_txs = 2;
  185. uint64 max_tx_size = 3;
  186. }
  187. //----------------------------------------
  188. // Blockchain Types
  189. message Header {
  190. string chain_id = 1;
  191. uint64 height = 2;
  192. uint64 time = 3;
  193. uint64 num_txs = 4;
  194. BlockID last_block_id = 5;
  195. bytes last_commit_hash = 6;
  196. bytes data_hash = 7;
  197. bytes validators_hash = 8;
  198. bytes app_hash = 9;
  199. }
  200. message BlockID {
  201. bytes hash = 1;
  202. PartSetHeader parts = 2;
  203. }
  204. message PartSetHeader {
  205. uint64 total = 1;
  206. bytes hash = 2;
  207. }
  208. message Validator {
  209. bytes pubKey = 1;
  210. uint64 power = 2;
  211. }
  212. //----------------------------------------
  213. // Service Definition
  214. service TMSPApplication {
  215. rpc Echo(RequestEcho) returns (ResponseEcho) ;
  216. rpc Flush(RequestFlush) returns (ResponseFlush);
  217. rpc Info(RequestInfo) returns (ResponseInfo);
  218. rpc SetOption(RequestSetOption) returns (ResponseSetOption);
  219. rpc AppendTx(RequestAppendTx) returns (ResponseAppendTx);
  220. rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx);
  221. rpc Query(RequestQuery) returns (ResponseQuery);
  222. rpc Commit(RequestCommit) returns (ResponseCommit);
  223. rpc InitChain(RequestInitChain) returns (ResponseInitChain);
  224. rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock);
  225. rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock);
  226. }