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.

131 lines
4.6 KiB

9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
8 years ago
8 years ago
  1. # Tendermint Socket Protocol (TMSP)
  2. [![CircleCI](https://circleci.com/gh/tendermint/tmsp.svg?style=svg)](https://circleci.com/gh/tendermint/tmsp)
  3. Blockchains are a system for creating shared multi-master application state.
  4. **TMSP** is a socket protocol enabling a blockchain consensus engine, running in one process,
  5. to manage a blockchain application state, running in another.
  6. For more information on TMSP, motivations, and tutorials, please visit [our blog post](http://tendermint.com/posts/tendermint-socket-protocol/).
  7. Other implementations:
  8. * [cpp-tmsp](https://github.com/mdyring/cpp-tmsp) by Martin Dyring-Andersen
  9. * [js-tmsp](https://github.com/tendermint/js-tmsp)
  10. ## Message format
  11. Since this is a streaming protocol, all messages are encoded with a length-prefix followed by the message encoded in Protobuf3. Protobuf3 doesn't have an official length-prefix standard, so we use our own. The first byte represents the length of the big-endian encoded length.
  12. For example, if the Protobuf3 encoded TMSP message is `0xDEADBEEF` (4 bytes), the length-prefixed message is `0x0104DEADBEEF`. If the Protobuf3 encoded TMSP message is 65535 bytes long, the length-prefixed message would be like `0x02FFFF...`.
  13. ## Message types
  14. TMSP requests/responses are simple Protobuf messages. Check out the [schema file](https://github.com/tendermint/tmsp/blob/master/types/types.proto).
  15. #### AppendTx
  16. * __Arguments__:
  17. * `Data ([]byte)`: The request transaction bytes
  18. * __Returns__:
  19. * `Code (uint32)`: Response code
  20. * `Data ([]byte)`: Result bytes, if any
  21. * `Log (string)`: Debug or error message
  22. * __Usage__:<br/>
  23. Append and run a transaction. If the transaction is valid, returns CodeType.OK
  24. #### CheckTx
  25. * __Arguments__:
  26. * `Data ([]byte)`: The request transaction bytes
  27. * __Returns__:
  28. * `Code (uint32)`: Response code
  29. * `Data ([]byte)`: Result bytes, if any
  30. * `Log (string)`: Debug or error message
  31. * __Usage__:<br/>
  32. Validate a transaction. This message should not mutate the state.
  33. Transactions are first run through CheckTx before broadcast to peers in the mempool layer.
  34. You can make CheckTx semi-stateful and clear the state upon `Commit` or `BeginBlock`,
  35. to allow for dependent sequences of transactions in the same block.
  36. #### Commit
  37. * __Returns__:
  38. * `Data ([]byte)`: The Merkle root hash
  39. * `Log (string)`: Debug or error message
  40. * __Usage__:<br/>
  41. Return a Merkle root hash of the application state.
  42. #### Query
  43. * __Arguments__:
  44. * `Data ([]byte)`: The query request bytes
  45. * __Returns__:
  46. * `Code (uint32)`: Response code
  47. * `Data ([]byte)`: The query response bytes
  48. * `Log (string)`: Debug or error message
  49. #### Flush
  50. * __Usage__:<br/>
  51. Flush the response queue. Applications that implement `types.Application` need not implement this message -- it's handled by the project.
  52. #### Info
  53. * __Returns__:
  54. * `Data ([]byte)`: The info bytes
  55. * __Usage__:<br/>
  56. Return information about the application state. Application specific.
  57. #### SetOption
  58. * __Arguments__:
  59. * `Key (string)`: Key to set
  60. * `Value (string)`: Value to set for key
  61. * __Returns__:
  62. * `Log (string)`: Debug or error message
  63. * __Usage__:<br/>
  64. Set application options. E.g. Key="mode", Value="mempool" for a mempool connection, or Key="mode", Value="consensus" for a consensus connection.
  65. Other options are application specific.
  66. #### InitChain
  67. * __Arguments__:
  68. * `Validators ([]Validator)`: Initial genesis validators
  69. * __Usage__:<br/>
  70. Called once upon genesis
  71. #### BeginBlock
  72. * __Arguments__:
  73. * `Height (uint64)`: The block height that is starting
  74. * __Usage__:<br/>
  75. Signals the beginning of a new block. Called prior to any AppendTxs.
  76. #### EndBlock
  77. * __Arguments__:
  78. * `Height (uint64)`: The block height that ended
  79. * __Returns__:
  80. * `Validators ([]Validator)`: Changed validators with new voting powers (0 to remove)
  81. * __Usage__:<br/>
  82. Signals the end of a block. Called prior to each Commit after all transactions
  83. ## Changelog
  84. ##### Mar 26h, 2016
  85. * Introduce BeginBlock
  86. ##### Mar 6th, 2016
  87. * Added InitChain, EndBlock
  88. ##### Feb 14th, 2016
  89. * s/GetHash/Commit/g
  90. * Document Protobuf request/response fields
  91. ##### Jan 23th, 2016
  92. * Added CheckTx/Query TMSP message types
  93. * Added Result/Log fields to AppendTx/CheckTx/SetOption
  94. * Removed Listener messages
  95. * Removed Code from ResponseSetOption and ResponseGetHash
  96. * Made examples BigEndian
  97. ##### Jan 12th, 2016
  98. * Added "RetCodeBadNonce = 0x06" return code
  99. ##### Jan 8th, 2016
  100. * Tendermint/TMSP now comes to consensus on the order first before AppendTx.