Near | Stake Wars III
⠀Participate in Stake Wars III and join NEAR’s mission to bring «Chunk-Only Producers» to Mainnet.
Content
Server requirements
⠀Minimal (VPS/VDS/DS):
4 CPU, 8 GB RAM, 500 GB SSD, Ubuntu 20.04
- Hetzner — DS AX41 (€40.5)
- Mevspace — AMD® Ryzen™ 5 3600 (€51.5)
- Contabo — VPS L (€15)
Challenge 001
⠀Create a wallet.
⠀Enter you username and click the button.
⠀Choose the mnemonic phrase, click the button, save it in a safe place and pass the memory verification.
Challenge 002
Start a node
⠀Check if your server has the right CPU features
lscpu | grep -P '(?=.*avx )(?=.*sse4.2 )(?=.*cx16 )(?=.*popcnt )' > /dev/null \ && echo "Supported" \ || echo "Not supported"
sudo apt update && sudo apt upgrade -y
⠀Install the required packages
sudo apt install wget jq bc build-essential -y
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/installers/rust.sh)
git clone https://github.com/near/nearcore
cd $HOME/nearcore
git checkout `wget -qO- https://raw.githubusercontent.com/near/stakewars-iii/main/commit.md`
git branch
cargo build -p neard --release --features shardnet
⠀Move binary to the folder with all binaries
mv $HOME/nearcore/target/release/neard /usr/bin/
cd
neard --home $HOME/.near init --chain-id shardnet --download-genesis
echo $HOME/.near/node_key.json
wget -O $HOME/.near/config.json https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/shardnet/config.json
sed -i -e 's%"archive": false%"archive": true%' $HOME/.near/config.json
printf "[Unit] Description=Near node After=network-online.target [Service] User=$USER ExecStart=`which neard` --home $HOME/.near run Restart=on-failure RestartSec=3 LimitNOFILE=65535 [Install] WantedBy=multi-user.target" > /etc/systemd/system/neard.service
sudo systemctl daemon-reload sudo systemctl enable neard sudo systemctl restart neard
⠀Add a command to view a log of the node in the system as a variable
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) -n near_log -v "sudo journalctl -fn 100 -u neard" -a
Becoming a Validator
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/installers/nodejs.sh)
sudo apt install npm -y
sudo npm install -g near-cli
⠀Insert variable with network name
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) \ -n NEAR_ENV -v "shardnet"
near login
⠀Go to the link through the browser on your PC
⠀Enter an address of the connected account.
⠀Add a wallet Account ID in the system as a variable
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) -n near_account_id
cat $HOME/.near/validator_key.json
near generate-key "${near_account_id}.factory.shardnet.near"
echo $HOME/.near-credentials/shardnet/
⠀Copy the file generated to shardnet folder
cp "$HOME/.near-credentials/shardnet/${near_account_id}.shardnet.near.json" \ $HOME/.near/validator_key.json
sed -i -e "s%.shardnet.near%.factory.shardnet.near%; s%private_key%secret_key%" \ $HOME/.near/validator_key.json
systemctl restart neard
Challenge 003
Staking pool
⠀Add a wallet Pool ID in the system as a variable
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) -n near_pool_id
near call factory.shardnet.near create_staking_pool '{"staking_pool_id": "'${near_pool_id}'", "owner_id": "'${near_account_id}'.shardnet.near", "stake_public_key": "'"`jq -r '.public_key' "/root/.near/validator_key.json"`"'", "reward_fee_fraction": {"numerator": 5, "denominator": 100}, "code_hash":"DD428g9eqLL8fWUxv8QSpVFzyHi1Qd16P8ephYCTmMSZ"}' --accountId "${near_account_id}.shardnet.near" \ --amount 30 --gas 300000000000000
near call "${near_pool_id}.factory.shardnet.near" deposit_and_stake --accountId "${near_account_id}.shardnet.near" --gas 300000000000000 \ --amount 500
Pinging
⠀You should ping each epoch with the command below to keep reported rewards current
near call "${near_pool_id}.factory.shardnet.near" ping '{}' --accountId "${near_account_id}.shardnet.near" \ --gas 300000000000000
Challenge 004
⠀Add a command to view the information about the node in the system as a variable
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) -n near_node_info -v ". <(wget -qO- https://raw.githubusercontent.com/SecorD0/Near/main/node_info.sh) 2> /dev/null" -a
⠀Enter command to view the information
near_node_info
Updating
cd $HOME/nearcore
⠀Create a branch with the source repository
git remote add upstream https://github.com/near/nearcore
⠀Update the local branch to the current branch
git fetch upstream
git checkout `wget -qO- https://raw.githubusercontent.com/near/stakewars-iii/main/commit.md`
git branch
cargo build -p neard --release --features shardnet
cd
cp $HOME/.near/config.json $HOME/.near/config.json.back
⠀Make backup of the previous binary
mv /usr/bin/neard $HOME
sudo systemctl stop neard
⠀Move binary to the folder with all binaries
mv $HOME/nearcore/target/release/neard /usr/bin/
sudo systemctl restart neard
⠀View the log to make sure the node is running
near_log
Hardforks
27.07.22
⠀Insert hardfork commit as a variable
commit="0d7f272afabc00f4a076b1c89a70ffc62466efe9"
⠀Follow the steps in the «Actions» subsection.
21.07.22
⠀Insert hardfork commit as a variable
commit="0f81dca95a55f975b6e54fe6f311a71792e21698"
⠀Follow the steps in the «Actions» subsection.
Actions
cd $HOME/nearcore
⠀Create a branch with the source repository
git remote add upstream https://github.com/near/nearcore
⠀Update the local branch to the current branch
git fetch upstream
git checkout $commit
git branch
cargo build -p neard --release --features shardnet
⠀Make backup of the previous binary
mv /usr/bin/neard $HOME
sudo systemctl stop neard
⠀Move binary to the folder with all binaries
mv $HOME/nearcore/target/release/neard /usr/bin/
rm -rf $HOME/.near/{data,genesis.json}
wget -O $HOME/.near/genesis.json https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/shardnet/genesis.json
wget -O $HOME/.near/config.json https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/shardnet/config.json
sed -i -e 's%"archive": false%"archive": true%' $HOME/.near/config.json
sudo systemctl restart neard
⠀View the log to make sure the node is running
near_log
Useful commands
near_log sudo journalctl -fn 100 -u neard
⠀To view the information about the node
near_node_info
⠀To view validators in the current epoch
near validators current near validators current | grep "$near_pool_id"
⠀To view validators in the next epoch
near validators next near validators next | grep "$near_pool_id"
near call "${near_pool_id}.factory.shardnet.near" ping '{}' --accountId "${near_account_id}.shardnet.near" \ --gas 300000000000000
systemctl restart neard
Useful links
Event website | GitHub binary | GitHub challenges
1package
Telegram (RU) | Chat (RU) | Discord (RU) | Twitter | Learning | Admitix
Acknowledgments
1package team — writing the article