mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-03 11:45:18 +00:00
lint: add markdown linter (#5254)
This commit is contained in:
@@ -14,7 +14,7 @@ Make sure you [have Go installed](https://golang.org/doc/install).
|
||||
|
||||
Next, install the `abci-cli` tool and example applications:
|
||||
|
||||
```
|
||||
```sh
|
||||
mkdir -p $GOPATH/src/github.com/tendermint
|
||||
cd $GOPATH/src/github.com/tendermint
|
||||
git clone https://github.com/tendermint/tendermint.git
|
||||
@@ -25,7 +25,7 @@ make install_abci
|
||||
|
||||
Now run `abci-cli` to see the list of commands:
|
||||
|
||||
```
|
||||
```sh
|
||||
Usage:
|
||||
abci-cli [command]
|
||||
|
||||
@@ -69,7 +69,7 @@ Its code can be found
|
||||
[here](https://github.com/tendermint/tendermint/blob/master/abci/cmd/abci-cli/abci-cli.go)
|
||||
and looks like:
|
||||
|
||||
```
|
||||
```go
|
||||
func cmdKVStore(cmd *cobra.Command, args []string) error {
|
||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
|
||||
|
||||
@@ -105,27 +105,27 @@ func cmdKVStore(cmd *cobra.Command, args []string) error {
|
||||
|
||||
Start by running:
|
||||
|
||||
```
|
||||
```sh
|
||||
abci-cli kvstore
|
||||
```
|
||||
|
||||
And in another terminal, run
|
||||
|
||||
```
|
||||
```sh
|
||||
abci-cli echo hello
|
||||
abci-cli info
|
||||
```
|
||||
|
||||
You'll see something like:
|
||||
|
||||
```
|
||||
```sh
|
||||
-> data: hello
|
||||
-> data.hex: 68656C6C6F
|
||||
```
|
||||
|
||||
and:
|
||||
|
||||
```
|
||||
```sh
|
||||
-> data: {"size":0}
|
||||
-> data.hex: 7B2273697A65223A307D
|
||||
```
|
||||
@@ -162,7 +162,7 @@ speaking ABCI messages to your application.
|
||||
|
||||
Try running these commands:
|
||||
|
||||
```
|
||||
```sh
|
||||
> echo hello
|
||||
-> code: OK
|
||||
-> data: hello
|
||||
@@ -226,7 +226,7 @@ Like the kvstore app, its code can be found
|
||||
[here](https://github.com/tendermint/tendermint/blob/master/abci/cmd/abci-cli/abci-cli.go)
|
||||
and looks like:
|
||||
|
||||
```
|
||||
```sh
|
||||
func cmdCounter(cmd *cobra.Command, args []string) error {
|
||||
|
||||
app := counter.NewCounterApplication(flagSerial)
|
||||
@@ -280,13 +280,13 @@ whose integer is greater than the last committed one.
|
||||
Let's kill the console and the kvstore application, and start the
|
||||
counter app:
|
||||
|
||||
```
|
||||
```sh
|
||||
abci-cli counter
|
||||
```
|
||||
|
||||
In another window, start the `abci-cli console`:
|
||||
|
||||
```
|
||||
```sh
|
||||
> set_option serial on
|
||||
-> code: OK
|
||||
-> log: OK (SetOption doesn't return anything.)
|
||||
@@ -332,7 +332,7 @@ example directory](https://github.com/tendermint/tendermint/tree/master/abci/exa
|
||||
|
||||
To run the Node.js version, fist download & install [the Javascript ABCI server](https://github.com/tendermint/js-abci):
|
||||
|
||||
```
|
||||
```sh
|
||||
git clone https://github.com/tendermint/js-abci.git
|
||||
cd js-abci
|
||||
npm install abci
|
||||
|
||||
@@ -9,7 +9,7 @@ Tendermint blockchain application.
|
||||
|
||||
The following diagram provides a superb example:
|
||||
|
||||

|
||||

|
||||
|
||||
We distinguish here between two forms of "application". The first is the
|
||||
end-user application, like a desktop-based wallet app that a user downloads,
|
||||
|
||||
@@ -26,25 +26,25 @@ committed in hash-linked blocks.
|
||||
The ABCI design has a few distinct components:
|
||||
|
||||
- message protocol
|
||||
- pairs of request and response messages
|
||||
- consensus makes requests, application responds
|
||||
- defined using protobuf
|
||||
- pairs of request and response messages
|
||||
- consensus makes requests, application responds
|
||||
- defined using protobuf
|
||||
- server/client
|
||||
- consensus engine runs the client
|
||||
- application runs the server
|
||||
- two implementations:
|
||||
- async raw bytes
|
||||
- grpc
|
||||
- consensus engine runs the client
|
||||
- application runs the server
|
||||
- two implementations:
|
||||
- async raw bytes
|
||||
- grpc
|
||||
- blockchain protocol
|
||||
- abci is connection oriented
|
||||
- Tendermint Core maintains three connections:
|
||||
- [mempool connection](#mempool-connection): for checking if
|
||||
- abci is connection oriented
|
||||
- Tendermint Core maintains three connections:
|
||||
- [mempool connection](#mempool-connection): for checking if
|
||||
transactions should be relayed before they are committed;
|
||||
only uses `CheckTx`
|
||||
- [consensus connection](#consensus-connection): for executing
|
||||
- [consensus connection](#consensus-connection): for executing
|
||||
transactions that have been committed. Message sequence is
|
||||
-for every block -`BeginBlock, [DeliverTx, ...], EndBlock, Commit`
|
||||
- [query connection](#query-connection): for querying the
|
||||
- [query connection](#query-connection): for querying the
|
||||
application state; only uses Query and Info
|
||||
|
||||
The mempool and consensus logic act as clients, and each maintains an
|
||||
@@ -104,7 +104,7 @@ mempool state (this behaviour can be turned off with
|
||||
|
||||
In go:
|
||||
|
||||
```
|
||||
```go
|
||||
func (app *KVStoreApplication) CheckTx(req types.RequestCheckTx) types.ResponseCheckTx {
|
||||
return types.ResponseCheckTx{Code: code.CodeTypeOK, GasWanted: 1}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func (app *KVStoreApplication) CheckTx(req types.RequestCheckTx) types.ResponseC
|
||||
|
||||
In Java:
|
||||
|
||||
```
|
||||
```java
|
||||
ResponseCheckTx requestCheckTx(RequestCheckTx req) {
|
||||
byte[] transaction = req.getTx().toByteArray();
|
||||
|
||||
@@ -170,7 +170,7 @@ merkle root of the data returned by the DeliverTx requests, or both.
|
||||
|
||||
In go:
|
||||
|
||||
```
|
||||
```go
|
||||
// tx is either "key=value" or just arbitrary bytes
|
||||
func (app *KVStoreApplication) DeliverTx(req types.RequestDeliverTx) types.ResponseDeliverTx {
|
||||
var key, value []byte
|
||||
@@ -200,7 +200,7 @@ func (app *KVStoreApplication) DeliverTx(req types.RequestDeliverTx) types.Respo
|
||||
|
||||
In Java:
|
||||
|
||||
```
|
||||
```java
|
||||
/**
|
||||
* Using Protobuf types from the protoc compiler, we always start with a byte[]
|
||||
*/
|
||||
@@ -241,7 +241,7 @@ job of the [Handshake](#handshake).
|
||||
|
||||
In go:
|
||||
|
||||
```
|
||||
```go
|
||||
func (app *KVStoreApplication) Commit() types.ResponseCommit {
|
||||
// Using a memdb - just return the big endian size of the db
|
||||
appHash := make([]byte, 8)
|
||||
@@ -255,7 +255,7 @@ func (app *KVStoreApplication) Commit() types.ResponseCommit {
|
||||
|
||||
In Java:
|
||||
|
||||
```
|
||||
```java
|
||||
ResponseCommit requestCommit(RequestCommit requestCommit) {
|
||||
|
||||
// update the internal app-state
|
||||
@@ -278,7 +278,7 @@ pick up from when it restarts. See information on the Handshake, below.
|
||||
|
||||
In go:
|
||||
|
||||
```
|
||||
```go
|
||||
// Track the block hash and header information
|
||||
func (app *PersistentKVStoreApplication) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock {
|
||||
// reset valset changes
|
||||
@@ -289,7 +289,7 @@ func (app *PersistentKVStoreApplication) BeginBlock(req types.RequestBeginBlock)
|
||||
|
||||
In Java:
|
||||
|
||||
```
|
||||
```java
|
||||
/*
|
||||
* all types come from protobuf definition
|
||||
*/
|
||||
@@ -321,7 +321,7 @@ for details on how it tracks validators.
|
||||
|
||||
In go:
|
||||
|
||||
```
|
||||
```go
|
||||
// Update the validator set
|
||||
func (app *PersistentKVStoreApplication) EndBlock(req types.RequestEndBlock) types.ResponseEndBlock {
|
||||
return types.ResponseEndBlock{ValidatorUpdates: app.ValUpdates}
|
||||
@@ -330,7 +330,7 @@ func (app *PersistentKVStoreApplication) EndBlock(req types.RequestEndBlock) typ
|
||||
|
||||
In Java:
|
||||
|
||||
```
|
||||
```java
|
||||
/*
|
||||
* Assume that one validator changes. The new validator has a power of 10
|
||||
*/
|
||||
@@ -367,7 +367,7 @@ Note: these query formats are subject to change!
|
||||
|
||||
In go:
|
||||
|
||||
```
|
||||
```go
|
||||
func (app *KVStoreApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery) {
|
||||
if reqQuery.Prove {
|
||||
value := app.state.db.Get(prefixKey(reqQuery.Data))
|
||||
@@ -396,7 +396,7 @@ func (app *KVStoreApplication) Query(reqQuery types.RequestQuery) (resQuery type
|
||||
|
||||
In Java:
|
||||
|
||||
```
|
||||
```java
|
||||
ResponseQuery requestQuery(RequestQuery req) {
|
||||
final boolean isProveQuery = req.getProve();
|
||||
final ResponseQuery.Builder responseBuilder = ResponseQuery.newBuilder();
|
||||
@@ -444,7 +444,7 @@ all blocks.
|
||||
|
||||
In go:
|
||||
|
||||
```
|
||||
```go
|
||||
func (app *KVStoreApplication) Info(req types.RequestInfo) (resInfo types.ResponseInfo) {
|
||||
return types.ResponseInfo{
|
||||
Data: fmt.Sprintf("{\"size\":%v}", app.state.Size),
|
||||
@@ -456,7 +456,7 @@ func (app *KVStoreApplication) Info(req types.RequestInfo) (resInfo types.Respon
|
||||
|
||||
In Java:
|
||||
|
||||
```
|
||||
```java
|
||||
ResponseInfo requestInfo(RequestInfo req) {
|
||||
final byte[] lastAppHash = getLastAppHash();
|
||||
final long lastHeight = getLastHeight();
|
||||
@@ -472,7 +472,7 @@ consensus params.
|
||||
|
||||
In go:
|
||||
|
||||
```
|
||||
```go
|
||||
// Save the validators in the merkle tree
|
||||
func (app *PersistentKVStoreApplication) InitChain(req types.RequestInitChain) types.ResponseInitChain {
|
||||
for _, v := range req.Validators {
|
||||
@@ -487,7 +487,7 @@ func (app *PersistentKVStoreApplication) InitChain(req types.RequestInitChain) t
|
||||
|
||||
In Java:
|
||||
|
||||
```
|
||||
```java
|
||||
/*
|
||||
* all types come from protobuf definition
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,7 @@ echo export GO111MODULE=on >> ~/.bash_profile
|
||||
|
||||
Then run
|
||||
|
||||
```
|
||||
```sh
|
||||
go get github.com/tendermint/tendermint
|
||||
cd $GOPATH/src/github.com/tendermint/tendermint
|
||||
make tools
|
||||
@@ -55,7 +55,7 @@ full transaction bytes are stored as the key and the value.
|
||||
|
||||
Let's start a kvstore application.
|
||||
|
||||
```
|
||||
```sh
|
||||
abci-cli kvstore
|
||||
```
|
||||
|
||||
@@ -64,7 +64,7 @@ Tendermint binary installed. If not, follow the steps from
|
||||
[here](../introduction/install.md). If you have never run Tendermint
|
||||
before, use:
|
||||
|
||||
```
|
||||
```sh
|
||||
tendermint init
|
||||
tendermint node
|
||||
```
|
||||
@@ -77,7 +77,7 @@ details, see [the guide on using Tendermint](../tendermint-core/using-tendermint
|
||||
You should see Tendermint making blocks! We can get the status of our
|
||||
Tendermint node as follows:
|
||||
|
||||
```
|
||||
```sh
|
||||
curl -s localhost:26657/status
|
||||
```
|
||||
|
||||
@@ -86,7 +86,7 @@ tool like [jq](https://stedolan.github.io/jq/) or `json_pp`.
|
||||
|
||||
Now let's send some transactions to the kvstore.
|
||||
|
||||
```
|
||||
```sh
|
||||
curl -s 'localhost:26657/broadcast_tx_commit?tx="abcd"'
|
||||
```
|
||||
|
||||
@@ -96,7 +96,7 @@ transaction with bytes `abcd`, so `abcd` will be stored as both the key
|
||||
and the value in the Merkle tree. The response should look something
|
||||
like:
|
||||
|
||||
```
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": "",
|
||||
@@ -123,13 +123,13 @@ like:
|
||||
We can confirm that our transaction worked and the value got stored by
|
||||
querying the app:
|
||||
|
||||
```
|
||||
```sh
|
||||
curl -s 'localhost:26657/abci_query?data="abcd"'
|
||||
```
|
||||
|
||||
The result should look like:
|
||||
|
||||
```
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": "",
|
||||
@@ -153,14 +153,14 @@ human-readable](https://github.com/tendermint/tendermint/issues/1794).
|
||||
|
||||
Now let's try setting a different key and value:
|
||||
|
||||
```
|
||||
```sh
|
||||
curl -s 'localhost:26657/broadcast_tx_commit?tx="name=satoshi"'
|
||||
```
|
||||
|
||||
Now if we query for `name`, we should get `satoshi`, or `c2F0b3NoaQ==`
|
||||
in base64:
|
||||
|
||||
```
|
||||
```sh
|
||||
curl -s 'localhost:26657/abci_query?data="name"'
|
||||
```
|
||||
|
||||
@@ -196,13 +196,13 @@ Let's kill the previous instance of `tendermint` and the `kvstore`
|
||||
application, and start the counter app. We can enable `serial=on` with a
|
||||
flag:
|
||||
|
||||
```
|
||||
```sh
|
||||
abci-cli counter --serial
|
||||
```
|
||||
|
||||
In another window, reset then start Tendermint:
|
||||
|
||||
```
|
||||
```sh
|
||||
tendermint unsafe_reset_all
|
||||
tendermint node
|
||||
```
|
||||
@@ -211,14 +211,14 @@ Once again, you can see the blocks streaming by. Let's send some
|
||||
transactions. Since we have set `serial=on`, the first transaction must
|
||||
be the number `0`:
|
||||
|
||||
```
|
||||
```sh
|
||||
curl localhost:26657/broadcast_tx_commit?tx=0x00
|
||||
```
|
||||
|
||||
Note the empty (hence successful) response. The next transaction must be
|
||||
the number `1`. If instead, we try to send a `5`, we get an error:
|
||||
|
||||
```
|
||||
```json
|
||||
> curl localhost:26657/broadcast_tx_commit?tx=0x05
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
@@ -237,7 +237,7 @@ the number `1`. If instead, we try to send a `5`, we get an error:
|
||||
|
||||
But if we send a `1`, it works again:
|
||||
|
||||
```
|
||||
```json
|
||||
> curl localhost:26657/broadcast_tx_commit?tx=0x01
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
@@ -263,7 +263,7 @@ to [install node](https://nodejs.org/en/download/).
|
||||
You'll also need to fetch the relevant repository, from
|
||||
[here](https://github.com/tendermint/js-abci), then install it:
|
||||
|
||||
```
|
||||
```sh
|
||||
git clone https://github.com/tendermint/js-abci.git
|
||||
cd js-abci
|
||||
npm install abci
|
||||
@@ -271,13 +271,13 @@ npm install abci
|
||||
|
||||
Kill the previous `counter` and `tendermint` processes. Now run the app:
|
||||
|
||||
```
|
||||
```sh
|
||||
node example/counter.js
|
||||
```
|
||||
|
||||
In another window, reset and start `tendermint`:
|
||||
|
||||
```
|
||||
```sh
|
||||
tendermint unsafe_reset_all
|
||||
tendermint node
|
||||
```
|
||||
@@ -286,7 +286,7 @@ Once again, you should see blocks streaming by - but now, our
|
||||
application is written in Javascript! Try sending some transactions, and
|
||||
like before - the results should be the same:
|
||||
|
||||
```
|
||||
```sh
|
||||
# ok
|
||||
curl localhost:26657/broadcast_tx_commit?tx=0x00
|
||||
# invalid nonce
|
||||
|
||||
@@ -15,7 +15,7 @@ type, only the key-value pairs defined in `EndBlock` are used.
|
||||
Each event contains a type and a list of attributes, which are key-value pairs
|
||||
denoting something about what happened during the method's execution. For more
|
||||
details on `Events`, see the
|
||||
[ABCI]https://github.com/tendermint/spec/blob/master/spec/abci/abci.md#events)
|
||||
[ABCI](https://github.com/tendermint/spec/blob/master/spec/abci/abci.md#events)
|
||||
documentation.
|
||||
|
||||
An Event has a composite key associated with it. A `compositeKey` is
|
||||
|
||||
@@ -13,14 +13,14 @@ for third-party applications (for analysis) or for inspecting state.
|
||||
To connect to a node via websocket from the CLI, you can use a tool such as
|
||||
[wscat](https://github.com/websockets/wscat) and run:
|
||||
|
||||
```
|
||||
```sh
|
||||
wscat ws://127.0.0.1:26657/websocket
|
||||
```
|
||||
|
||||
You can subscribe to any of the events above by calling the `subscribe` RPC
|
||||
method via Websocket along with a valid query.
|
||||
|
||||
```
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "subscribe",
|
||||
@@ -38,7 +38,7 @@ You can also use tags, given you had included them into DeliverTx
|
||||
response, to query transaction results. See [Indexing
|
||||
transactions](./indexing-transactions.md) for details.
|
||||
|
||||
### ValidatorSetUpdates
|
||||
## ValidatorSetUpdates
|
||||
|
||||
When validator set changes, ValidatorSetUpdates event is published. The
|
||||
event carries a list of pubkey/power pairs. The list is the same
|
||||
@@ -48,7 +48,7 @@ the ABCI spec).
|
||||
|
||||
Response:
|
||||
|
||||
```
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 0,
|
||||
|
||||
Reference in New Issue
Block a user