tendermint/README.md

121 lines
4.5 KiB
Markdown
Raw Normal View History

2015-12-03 15:47:20 -08:00
# Tendermint Socket Protocol (TMSP)
2015-11-02 07:39:53 -08:00
Blockchains are a system for creating shared multi-master application state.
**TMSP** is a socket protocol enabling a blockchain consensus engine, running in one process,
to manage a blockchain application state, running in another.
2015-11-02 07:39:53 -08:00
For more information on TMSP, motivations, and tutorials, please visit [our blog post](http://tendermint.com/posts/tendermint-socket-protocol/).
2015-11-02 07:39:53 -08:00
## Message types
2016-02-14 12:51:49 -08:00
TMSP requests/responses are simple Protobuf messages. Check out the [schema file](https://github.com/tendermint/tmsp/blob/master/types/types.proto).
2015-11-02 07:39:53 -08:00
#### AppendTx
* __Arguments__:
2016-02-14 12:51:49 -08:00
* `Data ([]byte)`: The request transaction bytes
2015-11-02 07:39:53 -08:00
* __Returns__:
* `Code (uint32)`: Response code
2016-02-14 12:51:49 -08:00
* `Data ([]byte)`: Result bytes, if any
* `Log (string)`: Debug or error message
2015-11-02 07:39:53 -08:00
* __Usage__:<br/>
2016-02-14 12:51:49 -08:00
Append and run a transaction. If the transaction is valid, returns CodeType.OK
2015-11-02 07:39:53 -08:00
#### CheckTx
* __Arguments__:
2016-02-14 12:51:49 -08:00
* `Data ([]byte)`: The request transaction bytes
2015-11-02 07:39:53 -08:00
* __Returns__:
* `Code (uint32)`: Response code
2016-02-14 12:51:49 -08:00
* `Data ([]byte)`: Result bytes, if any
* `Log (string)`: Debug or error message
2015-11-02 07:39:53 -08:00
* __Usage__:<br/>
Validate a transaction. This message should not mutate the state.
2016-02-14 12:51:49 -08:00
Transactions are first run through CheckTx before broadcast to peers in the mempool layer.
You can make CheckTx semi-stateful and clear the state upon `Commit`, to ensure that all txs in the blockchain are valid.
2015-11-02 07:39:53 -08:00
2016-02-14 12:51:49 -08:00
#### Commit
2015-11-02 07:39:53 -08:00
* __Returns__:
2016-02-14 12:51:49 -08:00
* `Data ([]byte)`: The Merkle root hash
* `Log (string)`: Debug or error message
2015-11-02 07:39:53 -08:00
* __Usage__:<br/>
2016-02-14 12:51:49 -08:00
Return a Merkle root hash of the application state.
#### Query
* __Arguments__:
* `Data ([]byte)`: The query request bytes
* __Returns__:
* `Code (uint32)`: Response code
2016-02-14 12:51:49 -08:00
* `Data ([]byte)`: The query response bytes
* `Log (string)`: Debug or error message
2015-11-02 07:39:53 -08:00
#### Flush
* __Usage__:<br/>
Flush the response queue. Applications that implement `types.Application` need not implement this message -- it's handled by the project.
#### Info
* __Returns__:
2016-02-14 12:51:49 -08:00
* `Data ([]byte)`: The info bytes
* __Usage__:<br/>
2016-02-14 12:51:49 -08:00
Return information about the application state. Application specific.
2015-11-27 10:14:46 -08:00
#### SetOption
* __Arguments__:
2016-02-14 12:51:49 -08:00
* `Key (string)`: Key to set
* `Value (string)`: Value to set for key
2015-11-27 10:14:46 -08:00
* __Returns__:
2016-02-14 12:51:49 -08:00
* `Log (string)`: Debug or error message
2015-11-27 10:14:46 -08:00
* __Usage__:<br/>
Set application options. E.g. Key="mode", Value="mempool" for a mempool connection, or Key="mode", Value="consensus" for a consensus connection.
Other options are application specific.
#### InitChain
2016-02-28 18:53:24 -08:00
* __Arguments__:
* `Validators ([]Validator)`: Initial genesis validators
* __Usage__:<br/>
Called once upon genesis
2016-02-28 18:53:24 -08:00
#### BeginBlock
* __Arguments__:
* `Height (uint64)`: Block number
* __Usage__:<br/>
Signals the beginning of a block
#### EndBlock
2016-02-28 18:53:24 -08:00
* __Returns__:
* `Validators ([]Validator)`: Changed validators with new voting powers (0 to remove)
* __Usage__:<br/>
Signals the end of a block. Called prior to each Commit after all transactions
2016-02-28 18:53:24 -08:00
## Changelog
2016-02-28 18:53:24 -08:00
### Feb 28th, 2016
* Added InitChain, BeginBlock, EndBlock
2016-02-28 18:53:24 -08:00
2016-02-14 12:51:49 -08:00
### Feb 14th, 2016
* s/GetHash/Commit/g
* Document Protobuf request/response fields
2016-01-23 20:49:15 -08:00
### Jan 23th, 2016
* Added CheckTx/Query TMSP message types
* Added Result/Log fields to AppendTx/CheckTx/SetOption
2016-01-23 20:49:15 -08:00
* Removed Listener messages
* Removed Code from ResponseSetOption and ResponseGetHash
* Made examples BigEndian
2016-01-23 20:49:15 -08:00
### Jan 12th, 2016
* Added "RetCodeBadNonce = 0x06" return code
### Jan 8th, 2016
Tendermint/TMSP now comes to consensus on the order first before AppendTx.
This means that we no longer need the Commit/Rollback TMSP messages.
Instead, theres a “CheckTx” message for mempool to check the validity of a message.
One consequence is that txs in blocks now may include invalid txs that are ignored.
In the future, we can include a bitarray or merkle structure in the block so anyone can see which txs were valid.
To prevent spam, applications can implement their “CheckTx” messages to deduct some balance, so at least spam txs will cost something. This isnt any more work that what we already needed to do, so its not any worse.
You can see the new changes in the tendermint/tendermint “order_first” branch, and tendermint/tmsp “order_first” branch. If you your TMSP apps to me I can help with the transition.
Please take a look at how the examples in TMSP changed, e.g. how AppContext was removed, CheckTx was added, how the TMSP msg bytes changed, and how commit/rollback messages were removed.