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.

149 lines
3.9 KiB

6 years ago
  1. # Tendermint
  2. ## Overview
  3. This is a quick start guide. If you have a vague idea about how Tendermint
  4. works and want to get started right away, continue.
  5. ## Install
  6. ### Quick Install
  7. On a fresh Ubuntu 16.04 machine can be done with [this script](https://git.io/fFfOR), like so:
  8. ```
  9. curl -L https://git.io/fFfOR | bash
  10. source ~/.profile
  11. ```
  12. WARNING: do not run the above on your local machine.
  13. The script is also used to facilitate cluster deployment below.
  14. ### Manual Install
  15. Requires:
  16. - `go` minimum version 1.10
  17. - `$GOPATH` environment variable must be set
  18. - `$GOPATH/bin` must be on your `$PATH` (see https://github.com/tendermint/tendermint/wiki/Setting-GOPATH)
  19. To install Tendermint, run:
  20. ```
  21. go get github.com/tendermint/tendermint
  22. cd $GOPATH/src/github.com/tendermint/tendermint
  23. make get_tools && make get_vendor_deps
  24. make install
  25. ```
  26. Note that `go get` may return an error but it can be ignored.
  27. Confirm installation:
  28. ```
  29. $ tendermint version
  30. 0.23.0-dev
  31. ```
  32. ## Initialization
  33. Running:
  34. ```
  35. tendermint init
  36. ```
  37. will create the required files for a single, local node.
  38. These files are found in `$HOME/.tendermint`:
  39. ```
  40. $ ls $HOME/.tendermint
  41. config.toml data genesis.json priv_validator.json
  42. ```
  43. For a single, local node, no further configuration is required.
  44. Configuring a cluster is covered further below.
  45. ## Local Node
  46. Start tendermint with a simple in-process application:
  47. ```
  48. tendermint node --proxy_app=kvstore
  49. ```
  50. and blocks will start to stream in:
  51. ```
  52. I[01-06|01:45:15.592] Executed block module=state height=1 validTxs=0 invalidTxs=0
  53. I[01-06|01:45:15.624] Committed state module=state height=1 txs=0 appHash=
  54. ```
  55. Check the status with:
  56. ```
  57. curl -s localhost:26657/status
  58. ```
  59. ### Sending Transactions
  60. With the kvstore app running, we can send transactions:
  61. ```
  62. curl -s 'localhost:26657/broadcast_tx_commit?tx="abcd"'
  63. ```
  64. and check that it worked with:
  65. ```
  66. curl -s 'localhost:26657/abci_query?data="abcd"'
  67. ```
  68. We can send transactions with a key and value too:
  69. ```
  70. curl -s 'localhost:26657/broadcast_tx_commit?tx="name=satoshi"'
  71. ```
  72. and query the key:
  73. ```
  74. curl -s 'localhost:26657/abci_query?data="name"'
  75. ```
  76. where the value is returned in hex.
  77. ## Cluster of Nodes
  78. First create four Ubuntu cloud machines. The following was tested on Digital
  79. Ocean Ubuntu 16.04 x64 (3GB/1CPU, 20GB SSD). We'll refer to their respective IP
  80. addresses below as IP1, IP2, IP3, IP4.
  81. Then, `ssh` into each machine, and execute [this script](https://git.io/fFfOR):
  82. ```
  83. curl -L https://git.io/fFfOR | bash
  84. source ~/.profile
  85. ```
  86. This will install `go` and other dependencies, get the Tendermint source code, then compile the `tendermint` binary.
  87. Next, use the `tendermint testnet` command to create four directories of config files (found in `./mytestnet`) and copy each directory to the relevant machine in the cloud, so that each machine has `$HOME/mytestnet/node[0-3]` directory. Then from each machine, run:
  88. ```
  89. tendermint node --home ./mytestnet/node0 --proxy_app=kvstore --p2p.persistent_peers="ID1@IP1:26656,ID2@IP2:26656,ID3@IP3:26656,ID4@IP4:26656"
  90. tendermint node --home ./mytestnet/node1 --proxy_app=kvstore --p2p.persistent_peers="ID1@IP1:26656,ID2@IP2:26656,ID3@IP3:26656,ID4@IP4:26656"
  91. tendermint node --home ./mytestnet/node2 --proxy_app=kvstore --p2p.persistent_peers="ID1@IP1:26656,ID2@IP2:26656,ID3@IP3:26656,ID4@IP4:26656"
  92. tendermint node --home ./mytestnet/node3 --proxy_app=kvstore --p2p.persistent_peers="ID1@IP1:26656,ID2@IP2:26656,ID3@IP3:26656,ID4@IP4:26656"
  93. ```
  94. Note that after the third node is started, blocks will start to stream in
  95. because >2/3 of validators (defined in the `genesis.json`) have come online.
  96. Seeds can also be specified in the `config.toml`. See [this
  97. PR](https://github.com/tendermint/tendermint/pull/792) for more information
  98. about configuration options.
  99. Transactions can then be sent as covered in the single, local node example above.