testnets/README.md

271 lines
9.4 KiB
Markdown
Raw Normal View History

# Connect to a Testnet
2018-04-23 08:48:33 -07:00
This document explains how to connect to the Testnet of a [Cosmos-SDK](https://github.com/cosmos/cosmos-sdk/) based blockchain. It can be used to connect to the latest Testnet for the Cosmos Hub.
2018-04-27 13:53:11 -07:00
## Software Setup (Manual Installation)
2018-04-27 13:53:11 -07:00
2018-05-01 09:13:22 -07:00
Follow these instructions to install the Cosmos-SDK and connect to the latest Testnet. This instructions work for both a local machine and a VM in a cloud server.
2018-04-27 13:53:11 -07:00
2018-05-01 09:13:22 -07:00
If you want to run a non-validator full-node, installing the SDK on a Cloud server is a good option. However, if you are want to become a validator for the Hub's `mainnet` you should look at more complex setups, including [Sentry Node Architecture](https://github.com/cosmos/cosmos/blob/master/VALIDATORS_FAQ.md#how-can-validators-protect-themselves-from-denial-of-service-attacks), to protect your node from DDOS and ensure high-availability (see the [technical requirements](https://github.com/cosmos/cosmos/blob/master/VALIDATORS_FAQ.md#technical-requirements)). You can find more information on validators in our [website](https://cosmos.network/validators), in the [Validator FAQ](https://cosmos.network/resources/validator-faq) and in the [Validator Chat](https://riot.im/app/#/room/#cosmos_validators:matrix.org).
2018-04-27 13:53:11 -07:00
### Install [Go](https://golang.org/)
2018-04-27 13:53:11 -07:00
Install `go` following the [instructions](https://golang.org/doc/install) in the official golang website.
2018-05-29 10:14:54 -07:00
You will require **Go 1.10+** for this tutorial.
#### Set GOPATH
First, you will need to set up your `GOPATH`. Make sure that the location `$HOME` is something like `/Users/<username>`, you can corroborate it by typing `echo $HOME` in your terminal.
2018-05-22 15:02:30 -07:00
Go to `$HOME` with the command `cd $HOME` and open the the hidden file `.bashrc` with a code editor and paste the following lines \(or `.bash_profile` if your're using OS X\).
```
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
```
Save and restart the terminal.
_Note_: If you can't see the hidden file, use the shortcut `Command + Shift + .` in Finder.
### Install [GNU Wget](https://www.gnu.org/software/wget/)
2018-04-23 09:46:14 -07:00
**MacOS**
```
brew install wget
```
**Linux**
```
sudo apt-get install wget
```
Note: You can check other available options for downloading `wget` [here](https://www.gnu.org/software/wget/faq.html#download).
2018-05-29 10:14:54 -07:00
### Install Gaia
Now we can fetch the correct versions of each dependency by running:
```
2018-05-29 10:14:54 -07:00
mkdir -p $GOPATH/src/github.com/cosmos/cosmos-sdk
git clone https://github.com/cosmos/cosmos-sdk.git
2018-06-05 18:18:11 -07:00
git checkout v0.17.5
2018-04-23 09:46:14 -07:00
make get_tools // run $ make update_tools if already installed
make get_vendor_deps
make install
```
This will install the `gaiad` and `gaiacli` binaries. Verify that everything is OK by running:
2018-04-23 09:46:14 -07:00
```
gaiad version
```
You should see:
```
2018-06-05 18:18:11 -07:00
0.17.5-cf46be22
```
And also:
```
2018-04-23 09:46:14 -07:00
gaiacli version
```
You should see:
2018-04-23 09:46:14 -07:00
```
2018-06-05 18:18:11 -07:00
0.17.5-cf46be22
2018-04-23 09:46:14 -07:00
```
## Genesis Setup
2018-04-23 09:46:14 -07:00
2018-05-31 14:19:21 -07:00
### Making your own genesis transaction
Create your own genesis transactions
```
gaiad init gen-tx --name YOUR_NAME
```
Copy the JSON value under `gen_tx_file` into `YOUR_NAME.json` in the appropriate folder on this Github repository.
### Retrieving & combining genesis transactions
Genesis files are the starting point for the full-node to sync up with the network. In order to sync up with the correct version of the Testnet, be sure to choose the genesis file corresponding to the version of the Testnet you want to connect to.
2018-04-28 10:20:34 -07:00
Now that we have completed the basic SDK setup, we can start working on the genesis configuration for the chain we want to connect to.
Get the genesis transactions
2018-04-23 09:46:14 -07:00
```
2018-05-02 12:31:45 -07:00
git clone https://github.com/cosmos/testnets
2018-04-23 09:46:14 -07:00
2018-05-02 12:31:45 -07:00
mkdir -p $HOME/.gaiad/config
2018-05-15 10:30:45 -07:00
cp -a testnets/gaia-5001/. $HOME/.gaiad/config/gentx
gaiad unsafe_reset_all
2018-05-15 10:30:45 -07:00
gaiad init --gen-txs -o --chain-id=gaia-5001
2018-04-23 09:46:14 -07:00
```
Lastly change the `moniker` string in the`config.toml`to identify your node.
2018-04-23 09:46:14 -07:00
```
# A custom human readable name for this node
moniker = "<your_custom_name>"
```
## Run a Full Node
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
Start the full node:
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiad start
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
Check the everything is running smoothly:
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli status
2018-04-23 08:48:33 -07:00
```
## Generate keys
2018-04-23 09:35:03 -07:00
You'll need a private and public key pair \(a.k.a. `sk, pk` respectively\) to be able to receive funds, send txs, bond tx, etc.
2018-04-24 09:46:34 -07:00
To generate your a new key \(default _ed25519_ elliptic curve\):
2018-04-23 08:48:33 -07:00
```
gaiacli keys add <your_key_name>
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
Next, you will have to enter a passphrase for your key twice. Save the _seed_ _phrase_ in a safe place in case you forget the password.
2018-04-23 09:35:03 -07:00
Now if you check your private keys you will see the `<your_key_name>` key among them:
2018-04-23 08:48:33 -07:00
```
gaiacli keys show <your_key_name>
2018-04-23 08:48:33 -07:00
```
2018-04-27 13:53:11 -07:00
You can see all your other available keys by typing:
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli keys list
2018-04-23 08:48:33 -07:00
```
2018-04-28 10:13:03 -07:00
The validator pubkey from your node should be the same as the one printed with the command:
2018-04-27 13:53:11 -07:00
```
gaiad show_validator
```
2018-04-28 10:13:03 -07:00
Finally, save your address and pubkey into a variable to use them afterwards.
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
MYADDR=<your_newly_generated_address>
MYPUBKEY=<your_newly_generated_public_key>
2018-04-23 08:48:33 -07:00
```
2018-04-24 09:46:34 -07:00
**IMPORTANT:** We strongly recommend to **NOT** use the same passphrase for your different keys. The Tendermint team and the Interchain Foundation will not be responsible for the lost of funds.
2018-04-23 08:48:33 -07:00
### Get coins
2018-04-23 09:35:03 -07:00
2018-06-02 03:40:02 -07:00
The best way to get coins at the moment is to ask in Riot chat. We plan to have a reliable faucet in future testnets.
2018-04-23 08:48:33 -07:00
## Send tokens
2018-04-23 08:48:33 -07:00
```
gaiacli send --amount=1000fermion --chain-id=<name_of_testnet_chain> --sequence=1 --name=<key_name> --to=<destination_address>
2018-04-23 09:35:03 -07:00
```
The `--amount` flag defines the corresponding amount of the coin in the format `--amount=<value|coin_name>`
The `--sequence` flag corresponds to the sequence number to sign the tx.
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
Now check the destination account and your own account to check the updated balances \(by default the latest block\):
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli account <destination_address>
gaiacli account <your_address>
2018-04-23 09:35:03 -07:00
```
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
You can also check your balance at a given block by using the `--block` flag:
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
```
gaiacli account <your_address> --block=<block_height>
```
## Run a Validator Node
2018-04-23 08:48:33 -07:00
[Validators](https://cosmos.network/validators) are actors from the network that are responsible from committing new blocks to the blockchain by submitting their votes. In terms of security, validators' stake is slashed in all the zones they belong if they become unavailable, double sign a transaction, or don't cast their votes. We strongly recommend entities intending to run validators in the Cosmos Hub's `mainnet` to check the [technical requirements](https://github.com/cosmos/cosmos/blob/master/VALIDATORS_FAQ.md#technical-requirements) and take the necessary precautions to ensure high-availability, such as setting a Sentry Node architecture. If you have any question about validators, read the [Validator FAQ](https://cosmos.network/resources/validator-faq) and join the [Validator Chat](https://riot.im/app/#/room/#cosmos_validators:matrix.org).
This section covers the instructions necessary to stake tokens to become a testnet validator candidate.
2018-04-28 10:13:03 -07:00
Your `pubkey` can be used to create a new validator candidate by staking some tokens:
2018-04-28 10:13:03 -07:00
You can find your node pubkey by running
```
2018-05-18 20:34:05 -07:00
gaiad show_validator
```
2018-05-18 20:34:05 -07:00
and this returns your public key for the declare-candidate command
2018-04-28 10:13:03 -07:00
```
2018-05-14 03:45:19 -07:00
gaiacli declare-candidacy --amount=500steak --pubkey=<your_node_pubkey> --address-candidate=<your_address> --moniker=satoshi --chain-id=<name_of_the_testnet_chain> --sequence=1 --name=<key_name>
2018-04-28 10:13:03 -07:00
```
You can add more information of the validator candidate such as`--website`, `--keybase-sig `or additional `--details`. If you want to edit the candidate info:
```
gaiacli edit-candidacy --details="To the cosmos !" --website="https://cosmos.network"
```
Finally, you can check all the candidate information by typing:
```
gaiacli candidate --address-candidate=<your_address> --chain-id=<name_of_the_testnet_chain>
2018-04-28 10:13:03 -07:00
```
2018-04-23 09:35:03 -07:00
To check that the validator is active you can find it on the validator set list:
```
2018-04-23 10:23:57 -07:00
gaiacli validatorset
2018-04-23 09:35:03 -07:00
```
2018-04-23 08:48:33 -07:00
2018-04-24 09:46:34 -07:00
**Note:** Remember that to be in the validator set you need to have more total power than the Xnd validator, where X is the assigned size for the validator set \(by default _`X = 100`_\).
2018-04-23 08:48:33 -07:00
2018-04-28 10:13:03 -07:00
## Delegate your tokens
2018-04-23 08:48:33 -07:00
2018-04-28 10:20:34 -07:00
You can delegate \(_i.e._ bind\) **Atoms** to a validator to become a [delegator](https://cosmos.network/resources/delegators) and obtain a part of its fee revenue in **Photons**. For more information about the Cosmos Token Model, refer to our [whitepaper](https://github.com/cosmos/cosmos/raw/master/Cosmos_Token_Model.pdf).
2018-04-28 10:13:03 -07:00
2018-05-14 03:45:19 -07:00
### Bond your tokens
2018-04-28 10:13:03 -07:00
Bond your tokens to a validator candidate with the following command:
2018-04-23 08:48:33 -07:00
```
2018-05-14 03:45:19 -07:00
gaiacli delegate --amount=10steak --address-delegator=<your_address> --address-candidate=<bonded_validator_address> --name=<key_name> --chain-id=<name_of_testnet_chain> --sequence=1
2018-04-23 09:35:03 -07:00
```
2018-06-05 08:23:48 -07:00
When tokens are bonded, they are pooled with all the other bonded tokens in the network. Validators and delegators obtain shares that represent their stake in this pool.
### Unbond
2018-04-28 10:13:03 -07:00
2018-04-23 09:35:03 -07:00
If for any reason the validator misbehaves or you just want to unbond a certain amount of the bonded tokens:
```
gaiacli unbond --address-delegator=<your_address> --address-candidate=<bonded_validator_address> --shares=MAX --name=<key_name> --chain-id=<name_of_testnet_chain> --sequence=1
2018-04-23 09:35:03 -07:00
```
2018-04-28 10:13:03 -07:00
You can unbond a specific amount of`shares`\(eg:`12.1`\) or all of them \(`MAX`\).
You should now see the unbonded tokens reflected in your balance and in your delegator bond:
2018-04-23 09:35:03 -07:00
```
gaiacli account <your_address>
gaiacli delegator-bond --address-delegator=<your_address> --address-candidate=<bonded_validator_address> --chain-id=<name_of_testnet_chain>
```