0g-chain/docs/setup.md

111 lines
3.8 KiB
Markdown
Raw Normal View History

2018-09-18 21:05:47 +00:00
2018-09-18 23:14:46 +00:00
# Installation and Setup
#### Who this guide is for
2018-09-18 23:27:26 +00:00
The code currently consists of a full node daemon (`kvd`) and it's command line interface (`kvcli`).
2018-09-18 23:14:46 +00:00
2018-10-03 22:07:26 +00:00
Full nodes are fairly resource intensive and are designed to be run continuously on servers, primarily by people validating the network. While it is possible to run locally it is not recommended except for development purposes. In the future light clients will enable secure transactions for clients.
2018-09-18 23:14:46 +00:00
A **full node** syncs with the blockchain and processes transactions. A **validator** is a full node that has declared itself to be a "validator" on chain. This obligates it to participate in consensus by proposing and signing blocks and maintaining uptime. By not following the protocol, the validator's stake will be slashed.
2018-09-18 23:27:26 +00:00
Use these instructions to set up a full node, and to optionally declare yourself as a validator.
2018-09-18 23:14:46 +00:00
2018-09-18 21:05:47 +00:00
## Install
Requirements: go installed and set up (version 1.10+).
2018-10-03 22:07:26 +00:00
>If installing from a new Ubuntu server (16.04 or 18.04), here's how to setup go.
>
> sudo apt update
> sudo apt upgrade -y
> sudo apt install git gcc make wget -y
> wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
> sudo tar -xvf go1.10.3.linux-amd64.tar.gz
> sudo mv go /usr/local
>
> cat >> ~/.profile <<EOF
> export GOROOT=/usr/local/go
> export GOPATH=\$HOME/go
> export PATH=\$GOPATH/bin:\$GOROOT/bin:\$PATH
> EOF
>
> source ~/.profile
2018-09-18 21:05:47 +00:00
1. Get the code.
mkdir -p $GOPATH/src/github.com/kava-labs
cd $GOPATH/src/github.com/kava-labs
git clone https://github.com/kava-labs/kava
cd kava
2. Install the dependencies.
mkdir $GOPATH/bin
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
2018-09-18 23:14:46 +00:00
dep ensure -vendor-only
2018-09-18 21:05:47 +00:00
2018-10-03 22:07:26 +00:00
3. Install the code.
2018-09-18 21:05:47 +00:00
go install ./cmd/kvd
go install ./cmd/kvcli
## Run a Full Node
2018-10-02 23:31:03 +00:00
kvd init --name <your-name>
2018-09-18 21:05:47 +00:00
2018-10-02 23:31:03 +00:00
Enter a new password for your validator key. This will generate generic config and private keys in `$HOME/.kvd` and `$HOME/.kvcli`.
2018-09-18 21:05:47 +00:00
> Note: Make sure `GOBIN` is set and added to your path if you want to be able to run installed go programs from any folder.
2018-10-02 23:31:03 +00:00
Setup the correct config for the current testnet
2018-09-18 21:05:47 +00:00
2018-10-03 21:01:42 +00:00
kvd init-testnet --name <your-name> --chain-id kava-test-3
2018-09-18 21:05:47 +00:00
Start your full node
kvd start
2018-10-08 13:47:28 +00:00
> Note: It might take a while to fully sync. Check the latest block height [here](http://kava-test-3.node.connector.kava.io:17127/abci_info).
2018-10-03 22:07:26 +00:00
### Running in the Background
It's often more convenient to start `kvd` in the background and capture output to a log file.
2018-09-18 21:05:47 +00:00
kvd start &> kvd.log &
2018-10-03 22:07:26 +00:00
To see the output of the log.
2018-09-18 21:05:47 +00:00
tail -f kvd.log
2018-10-03 22:07:26 +00:00
2018-09-18 21:05:47 +00:00
2018-09-18 23:14:46 +00:00
## Become a Validator
2018-10-03 22:07:26 +00:00
Join the [validator chat](https://riot.im/app/#/room/#kava-validators:matrix.org).
2018-09-18 21:05:47 +00:00
2018-10-03 22:07:26 +00:00
Follow the setup for a full node above.
2018-09-18 21:05:47 +00:00
2018-10-03 22:07:26 +00:00
Get your address with `kvcli keys list` and your validator pubkey with `kvd tendermint show_validator`.
2018-09-18 21:05:47 +00:00
2018-10-03 22:07:26 +00:00
Get some testnet coins from [the faucet](http://kava-test-3.faucet.connector.kava.io).
2018-09-18 21:05:47 +00:00
2018-10-03 22:07:26 +00:00
Then, with your full node running in the background or separate window, run:
2018-09-18 21:05:47 +00:00
kvcli stake create-validator \
--amount 900KVA \
--pubkey <you validator pubkey from above> \
--moniker "<your name>" \
--from <your name> \
--gas 1000000
2018-10-03 22:07:26 +00:00
> Note You'll need to type in your password you set earlier.
2018-09-18 21:05:47 +00:00
Now your full node should be participating in consensus and validating blocks!
Running a validator requires that you keep validating blocks. If you stop, your stake will be slashed.
In order to stop validating, first remove yourself as validator, then you can stop your node.
kvcli stake unbond begin \
--address-validator <your address> \
--shares-percent 1 \
--from <your name> \
--gas 1000000