Near | Stake Wars III
Content
Challenge 001
â €Create a wallet.
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
â €Switch to the special commit
git switch -c 8448ad1ebf27731a43397686103aa5277e7f2fcf
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 moniker in the system as a variable
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) -n near_moniker
cat $HOME/.near/validator_key.json
⠀Create it (replace POOL_NAME
to pool name)
near generate-key "${near_moniker}.factory.shardnet.near"
echo $HOME/.near-credentials/shardnet/
⠀Copy the file generated to shardnet folder
cp "$HOME/.near-credentials/shardnet/${near_moniker}.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
near call factory.shardnet.near create_staking_pool '{"staking_pool_id": "'${near_moniker}'", "owner_id": "'${near_moniker}'.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_moniker}.shardnet.near" \ --amount 30 --gas 300000000000000
near call "${near_moniker}.factory.shardnet.near" deposit_and_stake --accountId "${near_moniker}.shardnet.near" --gas 300000000000000 \ --amount 500
Pinging
sudo apt install cron -y
â €Create Cron task to pinging
mkdir -p /etc/cron.hourly/; \ sudo tee <<EOF >/dev/null /etc/cron.hourly/near_ping #!/bin/bash near call "${near_moniker}.factory.shardnet.near" ping '{}' --accountId "${near_moniker}.shardnet.near" --gas 300000000000000 EOF
Challenge 004
Challenge 005
Challenge 006
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
â €Switch to the special commit
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
â €Switch to the special commit
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