Step 2. Set up your validator node (2)

verse2
verse2
Published in
4 min readJul 22, 2022

In Step 2, we will set up a validator node.

First, check if the connected machine has appropriate CPU features.

lscpu | grep -P ‘(?=.*avx )(?=.*sse4.2 )(?=.*cx16 )(?=.*popcnt )’ > /dev/null \
&& echo “Supported” \
|| echo “Not supported”

There should be an Output message, “Supported”.

If you want to check the accurate Memory, type `cat /proc/meminfo` in Terminal.

Now we will install all available patches and updates of Ubuntu.

`sudo apt update && sudo apt upgrade -y`

Then install node.js and npm.

curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install build-essential nodejs
PATH=”$PATH”

Setup NEAR-CLI

We will install NEAR-CLI, a command package related to the NEAR node.

sudo npm install -g near-cli
echo ‘export NEAR_ENV=shardnet’ >> ~/.bashrc
source .bashrc

To confirm whether NEAR-CLI is installed correctly, insert the following commands.

  • near validators current: a command to see the active validator list
  • near validators next: ​​shows validators whose proposal was accepted one epoch ago, and that will enter the validator set in the next epoch.

Now, we will install supported packages.

Insert the following commands step by step.

sudo apt install -y git binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev cmake gcc g++ python docker.io protobuf-compiler libssl-dev pkg-config clang llvm cargo

sudo apt install python3-pip

USER_BASE_BIN=$(python3 -m site — user-base)/bin
export PATH=”$USER_BASE_BIN:$PATH”

sudo apt install clang build-essential make

curl — proto ‘=https’ — tlsv1.2 -sSf https://sh.rustup.rs | sh

When you install rust, please select installation options 1.

Set environment variable as follows.

source $HOME/.cargo/env

Clone nearcore repository in Github.

git clone https://github.com/near/nearcore
cd nearcore
git fetch origin — tags

Checkout commit that that is necessary for setting up a node.

git checkout <commit>

To check commit number, please refer to the [URL](https://github.com/near/stakewars-iii/blob/main/challenges/commit.md)

Compile Nearcore binary by inserting the following commands. It takes a few minutes.

cargo build -p neard — release — features shardnet

Now, create initial working directory.

./target/release/neard — home ~/.near init — chain-id shardnet — download-genesis

You will see `.near` folder in /ubuntu and the following files are created.

  • config.json : Configuration parameters which are responsive for how the node will work. The config.json contains needed information for a node to run on the network, how to communicate with peers, and how to reach consensus. Although some options are configurable. In general validators have opted to use the default config.json provided
  • genesis.json : A file with all the data the network started with at genesis. This contains initial accounts, contracts, access keys, and other records which represents the initial state of the blockchain. The genesis.json file is a snapshot of the network state at a point in time. In contacts accounts, balances, active validators, and other information about the network.
  • node_key.json : A file which contains a public and private key for the node. Also includes an optional account_id parameter which is required to run a validator node (not covered in this doc).

Edit config.json as follows.

rm ~/.near/config.json
wget -O ~/.near/config.json https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/shardnet/config.json

To increase block sync speed, download latest snapshot shared on Github.

sudo apt-get install awscli -y
pip3 install awscli — upgrade
cd ~/.near
aws s3 — no-sign-request cp s3://build.openshards.io/stakewars/shardnet/data.tar.gz .
tar -xzvf data.tar.gz

If you have downloaded before shardnet hardfork, please download again from https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/shardnet/genesis.json, and replace the existing genesis.json.

Now it is time to run a node.

Please insert the following commands.

cd nearcore
./target/release/neard — home ~/.near run

When block download is finished, a node setup is completed.

Congratulations! You completed the node setup.
Let’s get into Step 3.
https://medium.com/verse2/step-4-monitoring-node-status-3-e95cb7f58324

This article is <The Stake Wars III set up : Step 2. Set up your validator node> provided by verse2. If you would like to read the entire series, please see the list below. We recommend you read the articles sequentially.

Step 1. Create your shardnet wallet & Set up a server
Step 2. Set up your validator node
Step 3. Activate your node & Deploy a new staking pool contract
Step 4. Monitoring node status

verse2 is specialized in developing DeFi services and serious Crypto Investor at the same time. The team has in-depth knowledge and experience in the DeFi sector by developing and operating various protocols.

verse2 [Homepage | Twitter | Medium]

--

--

verse2
verse2
Editor for

Build, incubate, invest — Making all possible in the crypto. / verse2.io