diff --git a/testnet/README.md b/testnet/README.md new file mode 100644 index 00000000..e8015e9b --- /dev/null +++ b/testnet/README.md @@ -0,0 +1,7 @@ +# Testnet + +## Setup local chibaclonk multi node testnet in local enviorment + +```shell +$ bash multinode_testnet.sh +``` \ No newline at end of file diff --git a/testnet/full_node.md b/testnet/full_node.md new file mode 100644 index 00000000..7da55ce4 --- /dev/null +++ b/testnet/full_node.md @@ -0,0 +1,201 @@ +# Instructions to Run Full Node + +Hardware +--- + +#### Supported + +- **Operating System (OS):** Ubuntu 20.04 +- **CPU:** 1 core +- **RAM:** 2GB +- **Storage:** 25GB SSD + +#### Recommended + +- **Operating System (OS):** Ubuntu 20.04 +- **CPU:** 2 core +- **RAM:** 4GB +- **Storage:** 50GB SSD + +# A) Setup + +## 1) Install Golang (go) + +1.1) Remove any existing installation of `go` + +``` +sudo rm -rf /usr/local/go +``` + +1.2) Install latest/required Go version (installing `go1.17.2`) + +``` +curl https://golang.org/dl/go1.17.2.linux-amd64.tar.gz +sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.17.2.linux-amd64.tar.gz +``` + +1.3) Update env variables to include `go` + +``` +cat <<'EOF' >>$HOME/.profile +export GOROOT=/usr/local/go +export GOPATH=$HOME/go +export GO111MODULE=on +export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin +EOF + +source $HOME/.profile +``` + +1.4) Check the version of go installed + +``` +go version +``` + +### 2) Install required software packages + +``` +sudo apt-get install git curl build-essential make jq -y +``` + +### 3) Install `chibaclonkd` + +``` +git clone https://github.com/vulcanize/chiba-clonk.git +cd chiba-clonk +git fetch --all +git checkout main +make install +``` + +### 4) Verify your installation + +``` +chibaclonkd version --long +``` + +On running the above command, you should see a similar response like this. Make sure that the *version* and *commit +hash* are accurate + +``` +name: chibaclonkd +server_name: chibaclonkd +``` + +### 5) Initialize Node + +**Not required if you have already initialized before** + +``` +chibaclonkd init --chain-id chibaclonk_81337-1 +``` + +On running the above command, node will be initialized with default configuration. (config files will be saved in node's +default home directory (~/.chibaclonkd/config) + +NOTE: Backup node and validator keys . You will need to use these keys at a later point in time. + +--- + +# B) Starting Node + +## 1) Download Final Genesis + +Use `curl` to download the genesis file +**Replace your **genesis** file with published genesis file** + +```shell +curl http://167.172.173.94:26657/genesis | jq .result.genesis > ~/.chibaclonkd/config/genesis.json +``` + +Verify sha256 hash of genesis file with the below command + +``` +jq -S -c -M '' ~/.chibaclonkd/config/genesis.json | shasum -a 256 +``` + +genesis sha256 hash should be + +``` +4e5b68b5652a608c44c33e669c84ac179d9c0e301f958b5448f037a53c5cbb4e +``` + +## 2) Update Peers & Seeds in config.toml + +``` +peers="5ad2e6c35f2c84ff3ee31d89a95b34d92cb6afb1@157.230.101.237:26656,defc95b08547b6ef254723ad9621967a7e819020@161.35.223.44:26656" +sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" ~/.chibaclonkd/config/config.toml +``` + +## 3) Start the Full Node + +#### 3.1) Start node as `systemctl` service + +3.1.1) Create the service file + +``` +sudo tee /etc/systemd/system/chibaclonkd.service > /dev/null <>$HOME/.profile +export GOROOT=/usr/local/go +export GOPATH=$HOME/go +export GO111MODULE=on +export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin +EOF + +source $HOME/.profile +``` + +1.4) Check the version of go installed + +``` +go version +``` + +### 2) Install required software packages + +``` +sudo apt-get update && sudo apt-get install git curl build-essential make jq -y +``` + +### 3) Install `chibaclonk` + +``` +git clone https://github.com/vulcanize/chiba-clonk.git +cd chiba-clonk +git fetch --all +git checkout main +make install +``` + +### 4) Verify your installation + +``` +chibaclonkd version --long +``` + +On running the above command, you should see a similar response like this. Make sure that the *version* and *commit +hash* are accurate + +``` +name: chibaclonk +server_name: chibaclonkd +``` + +### 5) Initialize Node + +**Not required if you have already initialized before** + +``` +chibaclonkd init --chain-id chibaclonk_81337-1 +``` + +On running the above command, node will be initialized with default configuration. (config files will be saved in node's +default home directory (~/.chibaclonkd/config) + +NOTE: Backup node and validator keys. You will need to use these keys at a later point in time. + +--- + +## 6) Create Account keys + +if you have participated in previous testnet and have mnemonic phrase, use below command to recover your account + +``` +chibaclonkd keys add --recover +``` + +to create new account + +``` +chibaclonkd keys add +``` + +NOTE: Save `mnemonic` and related account details (public key). You will need to use the need mnemonic/private key to +recover accounts at a later point in time. + +## 7) Add Genesis Account + +``` +chibaclonkd add-genesis-account 4500000000000000agnt --keyring-backend os +``` + +## 8) Create Your `gentx` + +``` +chibaclonkd gentx 4500000000000000agnt \ + --pubkey=$(chibaclonkd tendermint show-validator) \ + --chain-id="chibaclonk_81337-1" \ + --moniker="my-moniker" \ + --website="https://yourweb.site" \ + --details="description of my validator" \ + --commission-rate="0.10" \ + --commission-max-rate="0.20" \ + --commission-max-change-rate="0.01" \ + --min-self-delegation="1" +``` + +Note: + +- `` and `chain-id` are required. other flags are optional +- Don't change amount value while creating your gentx +- Genesis transaction file will be saved in `~/.chibaclonkd/config/gentx` folder + +## 9) Submit Your gentx + +Submit your `gentx` file to the [testnets]() in the format of +`-gentx.json` + +NOTE: (Do NOT use space in the file name) + +To submit the gentx file, follow the below process: + +- Fork the [testnets]() repository +- Upload your gentx file in `chibaclonk_81337-1/config/gentxs` folder +- Submit Pull Request to [testnets]() with name `ADD gentx` + +--- + +**Execute below instructions only after publishing of final genesis file** + +genesis file will be published to [testnets/chibaclonk_9000-1]() + +# B) Starting the validator + +TBU + +## 3) Start the Node + +#### 3.1) Start node as `systemctl` service + +3.1.1) Create the service file Note: this step is not required if you did setup before + +``` +sudo tee /etc/systemd/system/chibaclonkd.service > /dev/null </dev/null +} + +if command_exists go; then + echo "Golang is already installed" +else + echo "Installing golang dependencies" + wget https://golang.org/dl/go1.17.2.linux-amd64.tar.gz + rm -rf /usr/local/go && tar -C /usr/local -xzf go1.17.2.linux-amd64.tar.gz + + echo "Updating the profile" + export GOPATH=$HOME/go + export GOROOT=/usr/local/go + export GOBIN=$GOPATH/bin + export PATH=$PATH:/usr/local/go/bin:$GOBIN + + echo "" >>~/.profile + echo 'export GOPATH=$HOME/go' >>~/.profile + echo 'export GOROOT=/usr/local/go' >>~/.profile + echo 'export GOBIN=$GOPATH/bin' >>~/.profile + echo 'export PATH=$PATH:/usr/local/go/bin:$GOBIN' >>~/.profile + + source ~/.profile + mkdir -p "$GOBIN" + mkdir -p $GOPATH/src/github.com + go version +fi + +# chain env variables +export DAEMON_HOME=~/.testchibaclonk +export CHAINID=chibaclonk_9000-1 +export DENOM=agnt +export GH_URL=https://github.com/vulcanize/chiba-clonk.git +export CHAIN_VERSION=main +export DAEMON=chibaclonkd + +display_usage() { + printf "** Please check the exported values:: **\n Daemon : $DAEMON\n Denom : $DENOM\n ChainID : $CHAINID\n DaemonHome : $DAEMON_HOME\n \n Github URL : $GH_URL\n Chain Version : $CHAIN_VERSION\n" + exit 1 +} + +if [ -z $DAEMON ] || [ -z $DENOM ] || [ -z $CHAINID ] || [ -z $DAEMON_HOME ] || [ -z $GH_URL ] || [ -z $CHAIN_VERSION ]; then + display_usage +fi + +echo "--------- Install $DAEMON ---------" +git clone -b $CHAIN_VERSION --single-branch $GH_URL && cd $(basename $_ .git) +git fetch && git checkout $CHAIN_VERSION +make install + +cd $HOME + +# check version +$DAEMON version --long + +#echo "----------Create test keys-----------" + +export DAEMON_HOME_1=$DAEMON_HOME-1 +export DAEMON_HOME_2=$DAEMON_HOME-2 +export DAEMON_HOME_3=$DAEMON_HOME-3 +export DAEMON_HOME_4=$DAEMON_HOME-4 + +printf "DAEMON_HOME_1=$DAEMON_HOME_1\nDAEMON_HOME_2=$DAEMON_HOME_2\nDAEMON_HOME_3=$DAEMON_HOME_3\nDAEMON_HOME_4=$DAEMON_HOME_4\n" + +rm -rf $DAEMON_HOME* + +echo "-----Create daemon home directories if not exist------" + +mkdir -p "$DAEMON_HOME_1" +mkdir -p "$DAEMON_HOME_2" +mkdir -p "$DAEMON_HOME_3" +mkdir -p "$DAEMON_HOME_4" + +echo "--------Start initializing the chain ($CHAINID)---------" + +$DAEMON init --chain-id $CHAINID $DAEMON_HOME_1 --home $DAEMON_HOME_1 --keyring-backend test +$DAEMON init --chain-id $CHAINID $DAEMON_HOME_2 --home $DAEMON_HOME_2 --keyring-backend test +$DAEMON init --chain-id $CHAINID $DAEMON_HOME_3 --home $DAEMON_HOME_3 --keyring-backend test +$DAEMON init --chain-id $CHAINID $DAEMON_HOME_4 --home $DAEMON_HOME_4 --keyring-backend test + +echo "---------Creating four keys-------------" + +$DAEMON keys add validator1 --home $DAEMON_HOME_1 --keyring-backend test +$DAEMON keys add validator2 --home $DAEMON_HOME_2 --keyring-backend test +$DAEMON keys add validator3 --home $DAEMON_HOME_3 --keyring-backend test +$DAEMON keys add validator4 --home $DAEMON_HOME_4 --keyring-backend test + +echo "----------Genesis creation---------" + +$DAEMON --home $DAEMON_HOME_1 add-genesis-account validator1 1000000000000$DENOM --keyring-backend test +$DAEMON --home $DAEMON_HOME_2 add-genesis-account validator2 1000000000000$DENOM --keyring-backend test +$DAEMON --home $DAEMON_HOME_3 add-genesis-account validator3 1000000000000$DENOM --keyring-backend test +$DAEMON --home $DAEMON_HOME_4 add-genesis-account validator4 1000000000000$DENOM --keyring-backend test +$DAEMON --home $DAEMON_HOME_1 add-genesis-account $($DAEMON keys show validator2 -a --home $DAEMON_HOME_2 --keyring-backend test) 1000000000000$DENOM +$DAEMON --home $DAEMON_HOME_1 add-genesis-account $($DAEMON keys show validator3 -a --home $DAEMON_HOME_3 --keyring-backend test) 1000000000000$DENOM +$DAEMON --home $DAEMON_HOME_1 add-genesis-account $($DAEMON keys show validator4 -a --home $DAEMON_HOME_4 --keyring-backend test) 1000000000000$DENOM + +echo "--------Gentx--------" + +$DAEMON gentx validator1 90000000000$DENOM --chain-id $CHAINID --keyring-backend test --home $DAEMON_HOME_1 +$DAEMON gentx validator2 90000000000$DENOM --chain-id $CHAINID --keyring-backend test --home $DAEMON_HOME_2 +$DAEMON gentx validator3 90000000000$DENOM --chain-id $CHAINID --keyring-backend test --home $DAEMON_HOME_3 +$DAEMON gentx validator4 90000000000$DENOM --chain-id $CHAINID --keyring-backend test --home $DAEMON_HOME_4 + +echo "---------Copy all the genesis to $DAEMON_HOME_1----------" + +cp $DAEMON_HOME_2/config/gentx/*.json $DAEMON_HOME_1/config/gentx/ +cp $DAEMON_HOME_3/config/gentx/*.json $DAEMON_HOME_1/config/gentx/ +cp $DAEMON_HOME_4/config/gentx/*.json $DAEMON_HOME_1/config/gentx/ + +echo "----------collect-gentxs------------" + +$DAEMON collect-gentxs --home $DAEMON_HOME_1 + +echo "---------Updating $DAEMON_HOME_1 genesis.json ------------" + +sed -i "s/172800000000000/600000000000/g" $DAEMON_HOME_1/config/genesis.json +sed -i "s/172800s/600s/g" $DAEMON_HOME_1/config/genesis.json +sed -i "s/stake/$DENOM/g" $DAEMON_HOME_1/config/genesis.json + +echo "---------Distribute genesis.json of $DAEMON_HOME_1 to remaining nodes-------" + +cp $DAEMON_HOME_1/config/genesis.json $DAEMON_HOME_2/config/ +cp $DAEMON_HOME_1/config/genesis.json $DAEMON_HOME_3/config/ +cp $DAEMON_HOME_1/config/genesis.json $DAEMON_HOME_4/config/ + +echo "---------Getting public IP address-----------" + +IP="127.0.0.1" +echo "Public IP address: ${IP}" + +echo "----------Update node-id of $DAEMON_HOME_1 in remaining nodes---------" +nodeID=$("${DAEMON}" tendermint show-node-id --home $DAEMON_HOME_1) +echo $nodeID +PERSISTENT_PEERS="$nodeID@$IP:16656" +echo "PERSISTENT_PEERS : $PERSISTENT_PEERS" + +echo "----------Updating $DAEMON_HOME_1 chain config-----------" + +sed -i 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:16657#g' $DAEMON_HOME_1/config/config.toml +sed -i 's#tcp://0.0.0.0:26656#tcp://0.0.0.0:16656#g' $DAEMON_HOME_1/config/config.toml +sed -i '/persistent_peers =/c\persistent_peers = "'""'"' $DAEMON_HOME_1/config/config.toml +sed -i '/max_num_inbound_peers =/c\max_num_inbound_peers = 140' $DAEMON_HOME_1/config/config.toml +sed -i '/max_num_outbound_peers =/c\max_num_outbound_peers = 110' $DAEMON_HOME_1/config/config.toml +sed -i '/pprof_laddr =/c\# pprof_laddr = "localhost:6060"' $DAEMON_HOME_1/config/config.toml +sed -i '/allow_duplicate_ip =/c\allow_duplicate_ip = true' $DAEMON_HOME_1/config/config.toml + +sed -i 's#0.0.0.0:9090#0.0.0.0:1090#g' $DAEMON_HOME_1/config/app.toml +sed -i 's#0.0.0.0:9091#0.0.0.0:1091#g' $DAEMON_HOME_1/config/app.toml + +sed -i 's#0.0.0.0:8545#0.0.0.0:1545#g' $DAEMON_HOME_1/config/app.toml +sed -i 's#0.0.0.0:8546#0.0.0.0:1546#g' $DAEMON_HOME_1/config/app.toml + +echo "----------Updating $DAEMON_HOME_2 chain config-----------" + +sed -i 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $DAEMON_HOME_2/config/config.toml +sed -i 's#tcp://0.0.0.0:26656#tcp://0.0.0.0:26656#g' $DAEMON_HOME_2/config/config.toml +sed -i '/persistent_peers =/c\persistent_peers = "'"$PERSISTENT_PEERS"'"' $DAEMON_HOME_2/config/config.toml +sed -i '/max_num_inbound_peers =/c\max_num_inbound_peers = 140' $DAEMON_HOME_2/config/config.toml +sed -i '/max_num_outbound_peers =/c\max_num_outbound_peers = 110' $DAEMON_HOME_2/config/config.toml +sed -i '/pprof_laddr =/c\# pprof_laddr = "localhost:6060"' $DAEMON_HOME_2/config/config.toml +sed -i '/allow_duplicate_ip =/c\allow_duplicate_ip = true' $DAEMON_HOME_2/config/config.toml + +sed -i 's#0.0.0.0:9090#0.0.0.0:2090#g' $DAEMON_HOME_2/config/app.toml +sed -i 's#0.0.0.0:9091#0.0.0.0:2091#g' $DAEMON_HOME_2/config/app.toml + +sed -i 's#0.0.0.0:8545#0.0.0.0:2545#g' $DAEMON_HOME_2/config/app.toml +sed -i 's#0.0.0.0:8546#0.0.0.0:2546#g' $DAEMON_HOME_2/config/app.toml + +echo "----------Updating $DAEMON_HOME_3 chain config------------" + +sed -i 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:36657#g' $DAEMON_HOME_3/config/config.toml +sed -i 's#tcp://0.0.0.0:26656#tcp://0.0.0.0:36656#g' $DAEMON_HOME_3/config/config.toml +sed -i '/persistent_peers =/c\persistent_peers = "'"$PERSISTENT_PEERS"'"' $DAEMON_HOME_3/config/config.toml +sed -i '/max_num_inbound_peers =/c\max_num_inbound_peers = 140' $DAEMON_HOME_3/config/config.toml +sed -i '/max_num_outbound_peers =/c\max_num_outbound_peers = 110' $DAEMON_HOME_3/config/config.toml +sed -i '/pprof_laddr =/c\# pprof_laddr = "localhost:6060"' $DAEMON_HOME_3/config/config.toml +sed -i '/allow_duplicate_ip =/c\allow_duplicate_ip = true' $DAEMON_HOME_3/config/config.toml + +sed -i 's#0.0.0.0:9090#0.0.0.0:3090#g' $DAEMON_HOME_3/config/app.toml +sed -i 's#0.0.0.0:9091#0.0.0.0:3091#g' $DAEMON_HOME_3/config/app.toml + +sed -i 's#0.0.0.0:8545#0.0.0.0:3545#g' $DAEMON_HOME_3/config/app.toml +sed -i 's#0.0.0.0:8546#0.0.0.0:3546#g' $DAEMON_HOME_3/config/app.toml + +echo "----------Updating $DAEMON_HOME_4 chain config------------" + +sed -i 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:46657#g' $DAEMON_HOME_4/config/config.toml +sed -i 's#tcp://0.0.0.0:26656#tcp://0.0.0.0:46656#g' $DAEMON_HOME_4/config/config.toml +sed -i '/persistent_peers =/c\persistent_peers = "'"$PERSISTENT_PEERS"'"' $DAEMON_HOME_4/config/config.toml +sed -i '/max_num_inbound_peers =/c\max_num_inbound_peers = 140' $DAEMON_HOME_4/config/config.toml +sed -i '/max_num_outbound_peers =/c\max_num_outbound_peers = 110' $DAEMON_HOME_4/config/config.toml +sed -i '/pprof_laddr =/c\# pprof_laddr = "localhost:6060"' $DAEMON_HOME_4/config/config.toml +sed -i '/allow_duplicate_ip =/c\allow_duplicate_ip = true' $DAEMON_HOME_4/config/config.toml + +sed -i 's#0.0.0.0:9090#0.0.0.0:4090#g' $DAEMON_HOME_4/config/app.toml +sed -i 's#0.0.0.0:9091#0.0.0.0:4091#g' $DAEMON_HOME_4/config/app.toml + +sed -i 's#0.0.0.0:8545#0.0.0.0:4545#g' $DAEMON_HOME_4/config/app.toml +sed -i 's#0.0.0.0:8546#0.0.0.0:4546#g' $DAEMON_HOME_4/config/app.toml + +echo "starting the chains" + +nohup $(which $DAEMON) start --gql-playground --gql-server --home $DAEMON_HOME_1 >$DAEMON_HOME_1.log & +sleep 5s +echo "Checking $DAEMON_HOME_1 chain status" +$DAEMON status --node tcp://localhost:16657 + +nohup $(which $DAEMON) start --gql-playground --gql-server --home $DAEMON_HOME_2 >$DAEMON_HOME_2.log & +sleep 5s +echo "Checking $DAEMON_HOME_2 chain status" +$DAEMON status --node tcp://localhost:26657 + +nohup $(which $DAEMON) start --gql-playground --gql-server --home $DAEMON_HOME_3 >$DAEMON_HOME_3.log & +sleep 5s +echo "Checking $DAEMON_HOME_3 chain status" +$DAEMON status --node tcp://localhost:36657 + +nohup $(which $DAEMON) start --gql-playground --gql-server --home $DAEMON_HOME_4 >$DAEMON_HOME_4.log & +sleep 5s +echo "Checking $DAEMON_HOME_4 chain status" +$DAEMON status --node tcp://localhost:46657 \ No newline at end of file diff --git a/testnet/validator_node.md b/testnet/validator_node.md new file mode 100644 index 00000000..18554f2d --- /dev/null +++ b/testnet/validator_node.md @@ -0,0 +1,56 @@ +### Create Validator Post Genesis + +1. Run Full Node +2. Create Account and Get test tokens +3. Create Validator + +### 1.Run Full Node + +- Check "[Run Full Node](full-node.md)" section to Run a Full Node + +### 2. Create Account & Get test tokens + +``` +chibaclonkd keys add --keyring-backend test +``` + +NOTE: Save `mnemonic` and related account details (public key). You will need to use the need mnemonic/private key to +recover accounts at a later point in time. + +##### Get Test tokens from faucet + +- Open this link : http://167.172.173.94:1314/ and paste your account +- 1 gnt = 10^18 agnt +- Each Transaction you will get 500gnt +- Total Tokens 5000gnt for account + +### 3.Create Validator + +- ##### Check full node sync status + + `chibaclonkd status 2>&1 | jq -r ".SyncInfo"` + + `catching_up: false` means node is completely synced +- ##### Create validator + +`Note:` Only execute below transaction after complete sync of your full node + +Please replace `key_name` with your key name and `moniker` also + +``` +chibaclonkd tx staking create-validator \ + --amount=4500000000000000000000agnt \ + --pubkey=$(chibaclonkd tendermint show-validator) \ + --moniker="my-moniker" \ + --website="https://myweb.site" \ + --details="description of your validator" \ + --chain-id="chibaclonk_81337-1" \ + --commission-rate="0.10" \ + --commission-max-rate="0.20" \ + --commission-max-change-rate="0.01" \ + --min-self-delegation="1" \ + --gas="auto" \ + --gas-adjustment="1.2" \ + --gas-prices="0.025agnt" \ + --from= +``` \ No newline at end of file