- Published on: 2022-07-13
- Updated on: 2022-07-15
- Submitted by: Open Shards Alliance
- Rewards: 30 Unlocked NEAR Points (UNP)
This challenge is focused on deploying a node (nearcore), downloading a snapshot, syncing it to the actual state of the network, then activating the node as a validator.
Wallet: https://wallet.shardnet.near.org/
Explorer: https://explorer.shardnet.near.org/
Please see the hardware requirement below:
Hardware | Chunk-Only Producer Specifications |
---|---|
CPU | 8-Core CPU with AVX support |
RAM | >16GB DDR4 (recommended is 20+ GB) |
Storage | 500GB SSD |
Before you start, you may want to confirm that your machine has the right CPU features.
lscpu | grep -P '(?=.*avx )(?=.*sse4.2 )(?=.*cx16 )(?=.*popcnt )' > /dev/null \
&& echo "Supported" \
|| echo "Not supported"
Supported
sudo apt install -y git binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev cmake gcc g++ python3 docker.io protobuf-compiler libssl-dev pkg-config clang llvm cargo
If you have problems with installing python or docker.io on Ubuntu, try this command:
sudo apt install python3
sudo apt install docker-ce
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
You will see the following:
Press 1 and press enter.
source $HOME/.cargo/env
First, clone the nearcore
repository.
git clone https://github.com/near/nearcore
cd nearcore
git fetch
Checkout to the commit needed. Please refer to the commit defined in this file.
git checkout <commit>
In the nearcore
folder run the following commands:
cargo build -p neard --release --features shardnet
The binary path is target/release/neard
. If you are seeing issues, it is possible that cargo command is not found. Compiling nearcore
binary may take a little while.
In order to work properly, the NEAR node requires a working directory and a couple of configuration files. Generate the initial required working directory by running:
./target/release/neard --home ~/.near init --chain-id shardnet --download-genesis
This command will create the directory structure and will generate config.json
, node_key.json
, and genesis.json
on the network you have passed.
-
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 optionalaccount_id
parameter which is required to run a validator node (not covered in this doc). -
data/
- A folder in which a NEAR node will write it's state.
From the generated config.json
, there two parameters to modify:
boot_nodes
: If you had not specify the boot nodes to use during init in Step 3, the generatedconfig.json
shows an empty array, so we will need to replace it with a full one specifying the boot nodes.tracked_shards
: In the generatedconfig.json
, this field is an empty. You will have to replace it to"tracked_shards": [0]
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 start your node simply run the following command:
cd ~/nearcore
./target/release/neard --home ~/.near run
The node is now running you can see log outputs in your console. Your node should be find peers, download headers to 100%, and then download blocks.
A full access key needs to be installed locally to be able to sign transactions via NEAR-CLI.
- You need to run this command:
near login
Note: This command launches a web browser allowing for the authorization of a full access key to be copied locally.
1 – Copy the link in your browser
2 – Grant Access to Near CLI
3 – After Grant, you will see a page like this, go back to console
4 – Enter your wallet and press Enter
- Run the following command:
cat ~/.near/validator_key.json
Note: If a validator_key.json is not present, follow these steps to create one
Create a validator_key.json
- Generate the Key file:
near generate-key <pool_id>
<pool_id> ---> xx.factory.shardnet.near WHERE xx is you pool name
Pool will be created at the next task, now you can give the same name as your wallet name
For example :
wallet name : john.shardnet.near (in future we will call it ) pool name : john.factory.shardnet.near
Please use the same pool name for next task "Mount your Staking Pool"
- Copy the file generated to shardnet folder: Make sure to replace <pool_id> by your pool name
cp ~/.near-credentials/shardnet/YOUR_WALLET.json ~/.near/validator_key.json
- Edit “account_id” => xx.factory.shardnet.near, where xx is your PoolName
- Change
private_key
tosecret_key
Note: The account_id must match the staking pool contract name or you will not be able to sign blocks.\
File content must be in the following pattern:
{
"account_id": "xx.factory.shardnet.near",
"public_key": "ed25519:HeaBJ3xLgvZacQWmEctTeUqyfSU4SDEnEwckWxd92W2G",
"secret_key": "ed25519:****"
}
target/release/neard run
- Setup Systemd Command:
sudo vi /etc/systemd/system/neard.service
Paste:
[Unit]
Description=NEARd Daemon Service
[Service]
Type=simple
User=<USER>
#Group=near
WorkingDirectory=/home/<USER>/.near
ExecStart=/home/<USER>/nearcore/target/release/neard run
Restart=on-failure
RestartSec=30
KillSignal=SIGINT
TimeoutStopSec=45
KillMode=mixed
[Install]
WantedBy=multi-user.target
Note: Change USER to your paths
Command:
sudo systemctl enable neard
Command:
sudo systemctl start neard
If you need to make a change to service because of an error in the file. It has to be reloaded:
sudo systemctl reload neard
Command:
journalctl -n 100 -f -u neard
Make log output in pretty print
Command:
sudo apt install ccze
View Logs with color
Command:
journalctl -n 100 -f -u neard | ccze -A
In order to become a validator and enter the validator set, a minimum set of success criteria must be met.
- The node must be fully synced
- The
validator_key.json
must be in place - The contract must be initialized with the public_key in
validator_key.json
- The account_id must be set to the staking pool contract id
- There must be enough delegations to meet the minimum seat price. See the seat price here.
- A proposal must be submitted by pinging the contract
- Once a proposal is accepted a validator must wait 2-3 epoch to enter the validator set
- Once in the validator set the validator must produce great than 90% of assigned blocks
Check running status of validator node. If “Validator” is showing up, your pool is selected in the current validators list.
Updated 2022-07-13: Creation
Updated 2022-07-13: Creation
Updated 2022-07-18: Snapshot is not required after hardfork
Updated 2022-07-20: Clarified the rewards for solving the challenge