How To Setup your Validator Node (Matic Staking Testnet) Option“2”

charingane
4 min readJan 15, 2020

--

— Method 2 —

Hello Everyone, In this post, I am going to show you how to start with Counter Stake and setting up your validator node in Ubuntu(18.04) step by step using the second method (binaries).
So let’s follow those steps and don’t hesitate to ask questions.

Getting Started:

To participate in the public testnet event, you need to first set up your Full Node, You may set up your node using any one of the following options:
Option 1: Linux Package Installation (Recommended; lightweight, native)
Option 2: Running with Binaries (Relatively complex to setup, but offers advanced customization)
Option 3:
Running with Docker (Easy to set up, but a bit resource intensive)
And in this tutorial, we will use Option 1 so let’s get started.

★ Option 2:

Step 1: Install GO

We need GO because Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It’s a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.
Install go by following the official docs. Remember to set your $GOPATH, $GOBIN, and $PATH environment variables, for example:

mkdir -p $HOME/go/bin
echo "export GOPATH=$HOME/go" >> ~/.bash_profile
source ~/.bash_profile
echo "export GOBIN=$GOPATH/bin" >> ~/.bash_profile
source ~/.bash_profile
echo "export PATH=$PATH:$GOBIN" >> ~/.bash_profile
source ~/.bash_profile
// or use this script:
curl https://gist.githubusercontent.com/vaibhavchellani/cbe0fa947dc0a6557cb9583d081ff8ce/raw/d47b3df14ccffdd7a965e44c39fb5ec235360166/new.sh > install_go.sh
bash install_go.sh
Note: Go version 1.11+ is recommended

Step 2: Install DEP

you can install by running the commands given below

curl https://raw.githubusercontent.com/golang/dep/master/install.sh -o install_dep.shsh install_dep.sh

Step 3: Install RabbitMq

Step 4: Install make

use this command to install make (most of Linux machine already has make)

sudo apt-get install build-essential

Step 5: Install Heimdall

mkdir -p $GOPATH/src/github.com/maticnetwork
cd $GOPATH/src/github.com/maticnetwork
git clone https://github.com/maticnetwork/heimdall
cd heimdall
// For eg: git checkout CS-1001
git checkout <TAG OR BRANCH>
make dep && make install

If you get an error in make install, then it may problem of GO. use this command to fix the issue and do make command again.

export GO111MODULE=auto

make command may take a long time to finish. when it is done you can check to verify if everything is Ok using the help command.

Set up a new node

Step 6: Install Bor

mkdir -p $GOPATH/src/github.com/maticnetwork
cd $GOPATH/src/github.com/maticnetwork
git clone https://github.com/maticnetwork/bor
cd bor
// For eg: git checkout CS-1001
git checkout <TAG OR BRANCH>
make bor

Connecting to console
Just like geth you can connect to bor console to execute various types of queries! From your dataDir run the following command.

$ $GOPATH/src/github.com/maticnetwork/bor/build/bin/bor attach geth.ipc

Step 7: Join public testnet

Get Heimdall genesis config :

git clone https://github.com/maticnetwork/public-testnets
cd public-testnets/<testnet version>

// Example: $ cd public-testnets/CS-1001
echo "export CONFIGPATH=$PWD" >> ~/.bashrc
source ~/.bashrc
$ sudo cp $CONFIGPATH/heimdall-genesis.json /etc/heimdall/config/genesis.json
$ sudo cp $CONFIGPATH/heimdall-config.toml /etc/heimdall/config/heimdall-config.toml

Add your API key in the file /etc/heimdall/config/heimdall-config.toml under the key "eth_RPC_URL". If you don’t have one just create an account in https://infura.io/ and create your project and get API.

See the first article of Option”1” to figure out how to Configure peers for Heimdall.

Run Heimdall
Starting Heimdall is fairly easy, the below command will start heimdall using the genesis file in ~/.heimdalld/config/genesis.json.

heimdalld start

8-Initialize genesis block for Bor

cd bor-config
// Using genesis file of validator bor node
cp ../<testnet version>/bor-genesis.json genesis.json
// initialize Genesis Block
$GOPATH/src/github.com/maticnetwork/bor/build/bin/bor --datadir dataDir init genesis.json

8.1-Configure peers for Bor

o sync blocks on the testnet, you need to add peers. The file static-nodes.json in your relevant public-testnets version folder contains information for all the available seed nodes. Let's copy this file to your datadir so that when you start your nodes you already have peers!

cp static-nodes.json ../bor-config/dataDir/bor/

8.2: Start Bor

bash start.sh

Your bor-node should be syncing now! Checkout logs/bor.log to get to the logs.

If everything’s well, then your logs should look something like this:

9.3: Query data:

To see examples on how to query your full node and get network status, please refer here: https://api.matic.network/staking/cs1001/swagger-ui/

For more Information:
Documentation : https://docs.matic.network/
Telegram : https://t.me/maticnetwork
Blog : https://blog.matic.network/

--

--