From c69192157765eed8924ac479db18a1cb5599f46b Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:58:33 +0100 Subject: [PATCH 01/23] Added Guide --- docs/validator/guide.md | 440 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 440 insertions(+) create mode 100644 docs/validator/guide.md diff --git a/docs/validator/guide.md b/docs/validator/guide.md new file mode 100644 index 0000000..5535ef1 --- /dev/null +++ b/docs/validator/guide.md @@ -0,0 +1,440 @@ + +## Run a Node on Linux + +### Recommended Hardware Specifications + +CPU x86_64 (Intel, AMD) processor with at least 8 physical cores +CPU Features: CMPXCHG16B, POPCNT, SSE4.1, SSE4.2, AVX, SHA-NI +RAM: 16GB DDR4 +Storage: 2TB NVMe SSD +1Gb networkbandwidth. +Distribution: Ubuntu 22.04 + + +### Node installation + +#### Get Build and latest update +```sh +sudo apt update && sudo apt upgrade -y && 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 awscli tmux jq ccze rclone +``` + +#### Install Rust + +For Rust, we use standard installation, just press "Enter" when asked for the setup. +```sh +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && source $HOME/.cargo/env +``` + +#### Install NEAR CLI and NEAR-Validator + +``` +curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh && +curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near-cli-rs/near-validator-cli-rs/releases/latest/download/near-validator-installer.sh | sh && +source $HOME/.cargo/env +``` + +#### Clone Nearcore repo + +First get lastest version available : +``` +Nearcore_Version=$(curl -s https://api.github.com/repos/near/nearcore/releases/latest | jq -r .tag_name) +``` + +Clone the nearcore repo, choose the latest stable branch for mainnet and build the nearcore from source +``` +cd ~ && git clone https://github.com/near/nearcore && cd nearcore/ && git checkout $Nearcore_Version +make release +echo 'export NEAR_ENV=mainnet' >> ~/.bashrc +source ~/.bashrc +``` + +During the building time, let's make a wallet. + +We recommand to use a partner wallet like Meteor, MyNearWallet or SenderWallet. + +https://app.mynearwallet.com/ + +https://wallet.meteorwallet.app/ + +![](file:///C:/Users/ddealmeida/Downloads/wallet_creation.png) + +Add at least 31 NEAR to this wallet. +30 Near will be used for the wallet creation +1 Near will be use for the fees of transactions + +/!\ This 30 Near can't be recovered if you decided to stop your validator. + + +When this wallet is created and build is done, follow this step: + +#### Wallet Authorization + +A full access key needs to be installed locally to be able transactions via NEAR-CLI. +``` +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 +![](file:///C:/Users/ddealmeida/Downloads/login.png) + +2 – Grant Access to Near CLI, fill your validator address and press Enter + + +3 - Choose “Store the access key in my keychain” from the CLI command. + +If you got error, you can retry near login with “Store the access key in my legacy keychain (compatible with the old near CLI)” + + +#### Initialize & Start the Node + +Time to think about your validator name. + +Your validator node will finish with a poolv1.near +Example, i want to have a validator pool named "panda", i will set panda.poolv1.near +Or i want to have a name "validator_near", my full poolname will be validator_near.poolv1.near + + +Reminder: + + – your pool name, for example panda + – xxx.poolv1.near, where xxx is your pool_id like panda.poolv1.near + or accountId – xxx.near where xxx your account name, for example validator_near.near + +``` +cd ~/nearcore && target/release/neard init --chain-id="mainnet" --account-id= +``` + +Set your , example: xxx.poolv1.near, where xxx is your pool_id + + + +validator_key.json generated after the above command in ~/.near/ folder must be something like this: + + + +The account_id must match the staking pool contract id or you will not be able to sign/verify blocks. + + +Tips before launching the node, if you want to reduce the size used by the data folder. +You can run this command : + +This will reduce the number of epoch store from 5 (default) to 3, without any issue for your node. +``` +jq '.gc_num_epochs_to_keep = 3' ~/.near/config.json > ~/.near/config.json.tmp && mv ~/.near/config.json.tmp ~/.near/config.json +``` + + +#### Neard Service + +Let's setup Systemd so the node will always run with the system + +``` +sudo bash -c 'cat > /etc/systemd/system/neard.service << EOF +[Unit] +Description=NEARd Daemon Service + +[Service] +Type=simple +User=root +WorkingDirectory=/root/.near +ExecStart=/root/nearcore/target/release/neard run +Restart=on-failure +RestartSec=30 +KillSignal=SIGINT +TimeoutStopSec=45 +KillMode=mixed + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable neard' + +``` + + +#### Syncing Data +##### Using NEAR Peer-to-peers state sync + +NEAR has decentralized state sync, a torrent like protocol for nodes to sync data with each others without relies on snapshot providers, to sync with p2p state sync, you would need to get the latest boot nodes list from the NEAR network and update to config.json file and then start the neard service, here is the command: + +``` +curl -s -X POST https://rpc.mainnet.near.org -H "Content-Type: application/json" -d '{ + "jsonrpc": "2.0", + "method": "network_info", + "params": [], + "id": "dontcare" + }' | \ +jq --arg newBootNodes "$(curl -s -X POST https://rpc.mainnet.near.org -H "Content-Type: application/json" -d '{ + "jsonrpc": "2.0", + "method": "network_info", + "params": [], + "id": "dontcare" + }' | jq -r '.result.active_peers as $list1 | .result.known_producers as $list2 | + $list1[] as $active_peer | $list2[] | + select(.peer_id == $active_peer.id) | + "\(.peer_id)@\($active_peer.addr)"' | paste -sd "," -)" \ + '.network.boot_nodes = $newBootNodes' ~/.near/config.json > ~/.near/config.tmp && mv ~/.near/config.json ~/.near/config.json.backup && mv ~/.near/config.tmp ~/.near/config.json +``` +after that, just restart the node ( sudo systemctl restart neard) and you will see something like this: + +p2pstate-sync + +Wait for sometime (maybe 10 hours) and you are done, follow the next step to become an active validator! + + + +##### Sync data with snapshot: + +To sync data faster, we can download the snapshot of recent NEAR epochs instead of waiting for node sync with other peers, this process will take a few hours, the expected data size will be around 580GB. + +Run this to download snapshot and start the node (huge thanks FastNEAR for maintaining this): + +``` +curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/fastnear/static/refs/heads/main/down_rclone.sh | DATA_PATH=~/.near/data CHAIN_ID=mainnet RPC_TYPE=fast-rpc bash && sudo systemctl restart neard +``` +The command will sync data and restart the neard! + +If you need to make a change to service in the config.json file, the node also need to be reloaded: + +``` +sudo systemctl restart neard +``` + +Watch logs: +``` +journalctl -n 100 -f -u neard | ccze -A +``` + +Image + +Check the running status of the validator node. If you see something like the image above, it means the node is fully synced, and you are ready to become an active validator! + +#### Becoming an active Validator +In order to become a validator and enter the validator set to help secure the network and earn rewards, 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 or just run this command +``` +near-validator validators network-config mainnet next + ``` +- 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 or your node will be kick out + +Check the running status of the validator node. If “Validator” is showing up, your pool is selected in the current validators list. + +##### Deploy your staking pool contract +NEAR uses a staking pool factory with a whitelisted staking contract to ensure delegators’ funds are safe. In order to run a validator on NEAR, a staking pool must be deployed to a NEAR account and integrated into a NEAR validator node. Delegators must use a UI or the command line to stake to the pool. A staking pool is a smart contract that is deployed to a NEAR account. + +Note: STAKING POOL CONTRACT WONT HAVE WRITE ACCESS TO ALL SUB ACCOUNTS FUNDS OR DATA, this also applies for any sub accounts on NEAR, that means your staking balance is SAFU! + +##### Deploy a Staking Pool Contract + +Calls the staking pool factory, creates a new staking pool with the specified name, and deploys it to the indicated accountId. + +``` +near contract call-function as-transaction poolv1.near create_staking_pool json-args '{"staking_pool_id": "", "owner_id": "", "stake_public_key": "", "reward_fee_fraction": {"numerator": 5, "denominator": 100}}' prepaid-gas '100.0 Tgas' attached-deposit '30 NEAR' sign-as network-config mainnet sign-with-keychain +``` +From the example above, you need to replace: + +**pool_id**: Staking pool name example “panda” +**owner_id**: The NEAR account that will manage the staking pool. Usually your main NEAR account. +**public_key**: The public key in your validator_key.json file. +**5**: The fee the pool will charge (e.g. in this case 5 over 100 is 5% of fees), usually validators take 5% fee, if you set the fee so high, no one will stake to your node 😉 +**accountId**: The NEAR account deploying the staking pool. +Be sure to have at least 30 NEAR available, it is the minimum required for storage. + +Final command will look something like this: +``` +near contract call-function as-transaction poolv1.near create_staking_pool json-args '{"staking_pool_id": "panda", "owner_id": "validator_near.near", "stake_public_key": "ed25519:xxx", "reward_fee_fraction": {"numerator": 5, "denominator": 100}}' prepaid-gas '100.0 Tgas' attached-deposit '30 NEAR' sign-as validator_near.near network-config mainnet sign-with-keychain +``` + +To change the pool parameters, such as changing the amount of commission charged to 1% in the example below, use this command: +``` +near contract call-function as-transaction update_reward_fee_fraction json-args '{"reward_fee_fraction": {"numerator": 1, "denominator": 100}}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain +``` +Note: full_pool_id: .poolv1.near , it’s panda.poolv1.near in this case + +You will see something like this: + +img +If there is a “True” at the End. Your pool is created. + +Congrats! You have now configure your Staking pool up and running 🚀🚀🚀🚀 + +#### Manage your staking pool contract +Few useful commands you should know: + +Retrieve the owner ID of the staking pool +``` +near contract call-function as-read-only get_owner_id json-args {} network-config mainnet now +``` +Issue this command to retrieve the public key the network has for your validator +``` +near contract call-function as-read-only get_staking_key json-args {} network-config mainnet now +``` + + +If the public key does not match you can update the staking key like this (replace the pubkey below with the key in your validator.json file) +``` +near contract call-function as-transaction update_staking_key json-args '{"stake_public_key": ""}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain +``` +Working with Staking Pools +NOTE: Your validator must be fully synced before issuing a proposal or depositing funds. + +#### Proposals and Pings +In order to get a validator seat you must first submit a proposal with an appropriate amount of stake. Proposals are sent for epoch +2. Meaning if you send a proposal now, if approved, you would get the seat in 3 epochs. You should submit a proposal every epoch to ensure your seat. To send a proposal we use the ping command. A proposal is also sent if a stake or unstake command is sent to the staking pool contract. + +To note, a ping also updates the staking balances for your delegators. A ping should be issued each epoch to keep reported rewards current on the pool contract. You could set up a ping using a cron job with a ping script here. + +Ping are done by Metapool too, you don't need anymore to use a script ping but you can. You need at least 1 ping to be visible for the first time. + + +Replace and before execution: + +``` +mkdir -p /home/root/scripts /home/root/logs && sudo bash -c 'cat > /home/root/scripts/ping.sh << EOF +#!/bin/sh +# Ping call to renew Proposal added to crontab +export NEAR_ENV=mainnet +export LOGS=/home/root/logs +export POOLID= +export ACCOUNTID= +echo "---" >> \$LOGS/near_ping.log +date >> \$LOGS/near_ping.log +near contract call-function as-transaction \$POOLID ping json-args '\''{"stake_public_key": ""}'\'' prepaid-gas '\''100.0 Tgas'\'' attached-deposit '\''0 NEAR'\'' sign-as \$ACCOUNTID network-config mainnet sign-with-keychain >> \$LOGS/near_ping.log +EOF +chmod +x /home/root/scripts/ping.sh && (crontab -l 2>/dev/null; echo "0 */8 * * * sh /home/root/scripts/ping.sh") | crontab -' +``` +This will ping you node every 8h + +List crontab to see it is running: +``` +crontab -l +``` + +Review your logs +``` +cat $HOME/logs/near_ping.log +``` + +Now you only need to have enough token staked to start earning Rewards. + + +#### Network optimizations +To optimize the network settings for better validator performance, execute the following commands: + +``` +MaxExpectedPathBDP=8388608 && \ +sudo sysctl -w net.core.rmem_max=$MaxExpectedPathBDP && \ +sudo sysctl -w net.core.wmem_max=$MaxExpectedPathBDP && \ +sudo sysctl -w net.ipv4.tcp_rmem="4096 87380 $MaxExpectedPathBDP" && \ +sudo sysctl -w net.ipv4.tcp_wmem="4096 16384 $MaxExpectedPathBDP" && \ +sudo sysctl -w net.ipv4.tcp_slow_start_after_idle=0 && \ +sudo bash -c "cat > /etc/sysctl.d/local.conf" < with your pool address, for example: panda.poolv1.near +Replace with your authenticated wallet address, validator_near.near for this case +near contract call-function as-transaction pool-details.near update_field json-args '{"pool_id": "", "name": "name", "value": "PandaPool"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain +near contract call-function as-transaction pool-details.near update_field json-args '{"pool_id": "", "name": "description", "value": "PandaPool Description"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain +View your validator infos from CLI: + +near contract call-function as-read-only pool-details.near get_fields_by_pool json-args '{"pool_id":""}' network-config mainnet now + + +View validator infos on NEARScope or NEARBlocks: + +The info will show like this: (source: NearScope) +Pasted image 20240929194648.png + +#### How to update new node version +When there is a new node version, you will get a notification on the Telegram Validator group, run this command to update the node. + +[CODE_RED_] where is either MAINNET or TESTNET. This represents the most dire and urgent situation. Usually it means that the network has stalled or crashed and we need validators to take immediate actions to bring the network up. Alternatively it could mean that we discovered some highly critical security vulnerabilities and a patch is needed as soon as possible. If it is about mainnet, we expect that validators will react immediately to such alerts, ideally within 30 minutes. + +[CODE_YELLOW_] where is either MAINNET or TESTNET. This represents a less urgent announcement. Usually it means the release of a protocol change or a fix of a moderate security issue. In such cases, validators are not expected to take immediate actions but are still expected to react within days. + +[CODE_GREEN_] where is either MAINNET or TESTNET. This usually means some general announcement that is more informational or doesn’t require actions within a short period of time. It could be an announcement of a release that improves performance or a fix some minor issues. + + +``` +cd ~/nearcore && git fetch && export NEAR_RELEASE_VERSION= && git checkout $NEAR_RELEASE_VERSION && make release && sudo systemctl stop neard && sudo systemctl start neard +``` +Replace with the correct nearcore release version. + +#### Monitor the node performance +Take a look at : https://github.com/LavenderFive/near_prometheus_exporter and https://github.com/LavenderFive/near-monitoring + +#### Monitor the node (Telegram BOT)): +Take a look here: https://t.me/nearvalidatorwatcherbot + +#### How to withdraw your rewards +Logged on a wallet with the wallet you created few steps before, unstake (take 3epoch) and withdraw. + +#### Useful commands +Get active epoch data like : list of active validators and the current seat price, their current performance: near-validator validators network-config mainnet now +Next epoch validators list: near-validator validators network-config mainnet next +View validator staked balance: near-validator staking view-stake network-config mainnet now + +#### Troubleshoot + +##### No peers +If you don't have any peers, run this script: +``` +neard `curl -X POST https://rpc.mainnet.near.org \ -H "Content-Type: application/json" \ + -d '{ + "jsonrpc": "2.0", + "method": "network_info", + "params": [], + "id": "dontcare" + }' | \ +jq '.result.active_peers as $list1 | .result.known_producers as $list2 | +$list1[] as $active_peer | $list2[] | +select(.peer_id == $active_peer.id) | +"\(.peer_id)@\($active_peer.addr)"' |\ +awk 'NR>2 {print ","} length($0) {print p} {p=$0}' ORS="" | sed 's/"//g'` +```` + +##### Warn message + +Warn message can be ignored. You don't really need to worry about it. + +##### Always kicked + +Make sure the config file have store.load_mem_tries_for_tracked_shards with true value + +#### Usefull links: +NEAR Chain Status Twitter: https://x.com/NEARChainStatus + +https://near-staking.com/ +https://nearblocks.io/node-explorer +https://nearscope.net/ + +#### Support: +Telegram: https://t.me/near_validators +Discord: https://discord.gg/nearprotocol From 39c6d25be619a0fc7c1837193e283daf47a6ecd4 Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:59:48 +0100 Subject: [PATCH 02/23] Update guide.md --- docs/validator/guide.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 5535ef1..dadfac5 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -4,13 +4,19 @@ ### Recommended Hardware Specifications CPU x86_64 (Intel, AMD) processor with at least 8 physical cores + CPU Features: CMPXCHG16B, POPCNT, SSE4.1, SSE4.2, AVX, SHA-NI + RAM: 16GB DDR4 + Storage: 2TB NVMe SSD -1Gb networkbandwidth. + +1Gb network bandwidth. + Distribution: Ubuntu 22.04 + ### Node installation #### Get Build and latest update From cd224af996c8de0cc24d8353ee3b0175297bc087 Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Tue, 4 Feb 2025 14:12:56 +0100 Subject: [PATCH 03/23] Update guide.md --- docs/validator/guide.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index dadfac5..bbc1e8d 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -131,6 +131,10 @@ This will reduce the number of epoch store from 5 (default) to 3, without any is jq '.gc_num_epochs_to_keep = 3' ~/.near/config.json > ~/.near/config.json.tmp && mv ~/.near/config.json.tmp ~/.near/config.json ``` +Update config.json to activate the validator config +``` +sed -i 's/"tracked_shards": \[\s*0\s*\]/"tracked_shards": []/' ~/.near/config.json +``` #### Neard Service From d1b1e5b8a634ee39f0b849f4ee861278ad2f4824 Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Thu, 6 Feb 2025 00:35:50 +0100 Subject: [PATCH 04/23] Update guide.md --- docs/validator/guide.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index bbc1e8d..8d36918 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -187,9 +187,7 @@ jq --arg newBootNodes "$(curl -s -X POST https://rpc.mainnet.near.org -H "Conten "\(.peer_id)@\($active_peer.addr)"' | paste -sd "," -)" \ '.network.boot_nodes = $newBootNodes' ~/.near/config.json > ~/.near/config.tmp && mv ~/.near/config.json ~/.near/config.json.backup && mv ~/.near/config.tmp ~/.near/config.json ``` -after that, just restart the node ( sudo systemctl restart neard) and you will see something like this: - -p2pstate-sync +after that, just restart the node ( sudo systemctl restart neard). Wait for sometime (maybe 10 hours) and you are done, follow the next step to become an active validator! @@ -217,7 +215,6 @@ Watch logs: journalctl -n 100 -f -u neard | ccze -A ``` -Image Check the running status of the validator node. If you see something like the image above, it means the node is fully synced, and you are ready to become an active validator! @@ -270,9 +267,6 @@ near contract call-function as-transaction update_reward_fee_frac ``` Note: full_pool_id: .poolv1.near , it’s panda.poolv1.near in this case -You will see something like this: - -img If there is a “True” at the End. Your pool is created. Congrats! You have now configure your Staking pool up and running 🚀🚀🚀🚀 @@ -428,7 +422,15 @@ $list1[] as $active_peer | $list2[] | select(.peer_id == $active_peer.id) | "\(.peer_id)@\($active_peer.addr)"' |\ awk 'NR>2 {print ","} length($0) {print p} {p=$0}' ORS="" | sed 's/"//g'` -```` +```` + +##### How to get Metrics from my node + +You can check metrics with : +``` +curl -s http://localhost:3030/metrics +``` +Content/Type: application/json ##### Warn message @@ -436,7 +438,7 @@ Warn message can be ignored. You don't really need to worry about it. ##### Always kicked -Make sure the config file have store.load_mem_tries_for_tracked_shards with true value +Make sure the config file have store.load_mem_tries_for_tracked_shards with true value #### Usefull links: NEAR Chain Status Twitter: https://x.com/NEARChainStatus From 50b785133e4b470e5897342d889b3a58e7fa6055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Chuda=C5=9B?= Date: Mon, 10 Feb 2025 18:06:12 +0000 Subject: [PATCH 05/23] doc --- docs/validator/guide.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 8d36918..7dec95a 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -165,9 +165,31 @@ systemctl enable neard' #### Syncing Data + +There are two ways to synchronize the node state with the network: +* [Decentralized state sync](#using-near-peer-to-peers-state-sync) +* [Using a snapshot](#sync-data-with-snapshot) (a centralized solution) + +Before decentralized state sync happens, the node first needs to download block headers. This phase can be much faster thanks to the Epoch Sync, where only a small subset of block headers is required for a node to start state sync. +Epoch Sync is enabled by default and requires boot nodes to be specified in the config file. Setting boot nodes is described below for decentralized state sync, so there is nothing more you need to do if you want to use Epoch Sync. + +You can tweak Epoch Sync behavior through the `config.json` file. The default values are: +``` + "epoch_sync": { + "disable_epoch_sync_for_bootstrapping": false, + "ignore_epoch_sync_network_requests": false, + "epoch_sync_horizon": 216000, + "timeout_for_epoch_sync": { + "secs": 60, + "nanos": 0 + } + }, +``` + ##### Using NEAR Peer-to-peers state sync -NEAR has decentralized state sync, a torrent like protocol for nodes to sync data with each others without relies on snapshot providers, to sync with p2p state sync, you would need to get the latest boot nodes list from the NEAR network and update to config.json file and then start the neard service, here is the command: +NEAR has decentralized state sync, a torrent like protocol for nodes to sync data with each others without relies on snapshot providers. +To sync with p2p state sync, you would need to get the latest boot nodes list from the NEAR network and update to `config.json` file and then start the neard service, here is the command: ``` curl -s -X POST https://rpc.mainnet.near.org -H "Content-Type: application/json" -d '{ @@ -187,11 +209,11 @@ jq --arg newBootNodes "$(curl -s -X POST https://rpc.mainnet.near.org -H "Conten "\(.peer_id)@\($active_peer.addr)"' | paste -sd "," -)" \ '.network.boot_nodes = $newBootNodes' ~/.near/config.json > ~/.near/config.tmp && mv ~/.near/config.json ~/.near/config.json.backup && mv ~/.near/config.tmp ~/.near/config.json ``` -after that, just restart the node ( sudo systemctl restart neard). +after that, just restart the node (sudo systemctl restart neard). Wait for sometime (maybe 10 hours) and you are done, follow the next step to become an active validator! - + ##### Sync data with snapshot: From d8eb9c7598fd097830febefd0cb146e3cc37ed8e Mon Sep 17 00:00:00 2001 From: walnut-the-cat <122475853+walnut-the-cat@users.noreply.github.com> Date: Mon, 10 Feb 2025 11:37:05 -0800 Subject: [PATCH 06/23] Update guide.md --- docs/validator/guide.md | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 8d36918..1d81071 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -3,19 +3,7 @@ ### Recommended Hardware Specifications -CPU x86_64 (Intel, AMD) processor with at least 8 physical cores - -CPU Features: CMPXCHG16B, POPCNT, SSE4.1, SSE4.2, AVX, SHA-NI - -RAM: 16GB DDR4 - -Storage: 2TB NVMe SSD - -1Gb network bandwidth. - -Distribution: Ubuntu 22.04 - - +Please refer to [Hardware Requirements for Validator Node](/validator/hardware-validator). ### Node installation From 21f66b185c1a8c77e8fda2344127356b225f5a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Chuda=C5=9B?= Date: Tue, 11 Feb 2025 15:20:25 +0000 Subject: [PATCH 07/23] separate things --- docs/validator/guide.md | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 7dec95a..6bc687c 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -166,14 +166,24 @@ systemctl enable neard' #### Syncing Data -There are two ways to synchronize the node state with the network: -* [Decentralized state sync](#using-near-peer-to-peers-state-sync) -* [Using a snapshot](#sync-data-with-snapshot) (a centralized solution) - -Before decentralized state sync happens, the node first needs to download block headers. This phase can be much faster thanks to the Epoch Sync, where only a small subset of block headers is required for a node to start state sync. -Epoch Sync is enabled by default and requires boot nodes to be specified in the config file. Setting boot nodes is described below for decentralized state sync, so there is nothing more you need to do if you want to use Epoch Sync. - -You can tweak Epoch Sync behavior through the `config.json` file. The default values are: +Sync is a three-step process: +1. **Syncing past block headers** - this can be achieved in two ways: +- [Epoch Sync](#epoch-sync) - recommended, decentralized approach. +- [Using a snapshot](#sync-data-with-snapshot) - a centralized solution. +- If neither option is used, the node will fall back to Header Sync, which can be extremely slow. +2. **Syncing state** (to the beginning of a recent epoch) - this can be achieved in two ways: +- [Decentralized state sync](#using-near-peer-to-peers-state-sync) - recommended. +- Centralized state sync - the default route. +3. **Syncing blocks** (catch up with the chain from the synced state). +- The node will request blocks from peers. + +##### Epoch Sync +Epoch Sync allows a node to sync from genesis without relying on a snapshot. +Unlike Header Sync, it does not require downloading all past block headers but only a small subset of them. +Epoch Sync is enabled by default and requires boot nodes to be specified in the config file. +Instructions for setting boot nodes are provided below for decentralized state sync, so no additional configuration is needed to use Epoch Sync. + +You can adjust Epoch Sync behavior through the `config.json` file. The default values are as follows: ``` "epoch_sync": { "disable_epoch_sync_for_bootstrapping": false, @@ -217,7 +227,7 @@ Wait for sometime (maybe 10 hours) and you are done, follow the next step to bec ##### Sync data with snapshot: -To sync data faster, we can download the snapshot of recent NEAR epochs instead of waiting for node sync with other peers, this process will take a few hours, the expected data size will be around 580GB. +To sync data fast, we can download the snapshot of recent NEAR epochs instead of waiting for node sync with other peers, this process will take a few hours, the expected data size will be around 580GB. Run this to download snapshot and start the node (huge thanks FastNEAR for maintaining this): @@ -416,7 +426,7 @@ Replace with the correct nearcore release version. #### Monitor the node performance Take a look at : https://github.com/LavenderFive/near_prometheus_exporter and https://github.com/LavenderFive/near-monitoring -#### Monitor the node (Telegram BOT)): +#### Monitor the node (Telegram BOT): Take a look here: https://t.me/nearvalidatorwatcherbot #### How to withdraw your rewards From 09d1805f4625ea8d3f11b8c89d3b526209d6c2ed Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Wed, 12 Feb 2025 09:43:35 +0100 Subject: [PATCH 08/23] Update guide.md --- docs/validator/guide.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 8d36918..78b4e31 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -423,6 +423,19 @@ select(.peer_id == $active_peer.id) | "\(.peer_id)@\($active_peer.addr)"' |\ awk 'NR>2 {print ","} length($0) {print p} {p=$0}' ORS="" | sed 's/"//g'` ```` +##### Weird error on running command +First check that you are using the correct NEAR-CLI +``` +near --version +``` + +MUST return near-cli-rs 0.XX.X + +If return X.X.XX + +It seems that NEAR CLI JS is still overshadowing the Rust one. + +You can use npx near-cli-rs instead of near to make is explicit call to the Rust CLI, or uninstall near-cli: npm remove near-cli ##### How to get Metrics from my node From 24d017a3196c34a0c40c18b4ef84416932f42554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Chuda=C5=9B?= Date: Thu, 13 Feb 2025 21:45:42 +0000 Subject: [PATCH 09/23] rework --- docs/validator/guide.md | 52 +++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 6bc687c..d6ebdd2 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -166,40 +166,21 @@ systemctl enable neard' #### Syncing Data -Sync is a three-step process: -1. **Syncing past block headers** - this can be achieved in two ways: -- [Epoch Sync](#epoch-sync) - recommended, decentralized approach. -- [Using a snapshot](#sync-data-with-snapshot) - a centralized solution. -- If neither option is used, the node will fall back to Header Sync, which can be extremely slow. -2. **Syncing state** (to the beginning of a recent epoch) - this can be achieved in two ways: -- [Decentralized state sync](#using-near-peer-to-peers-state-sync) - recommended. -- Centralized state sync - the default route. -3. **Syncing blocks** (catch up with the chain from the synced state). -- The node will request blocks from peers. +Syncing consists of two main steps: +1. **Syncing headers** - achieved in one of three ways: +- [Epoch Sync](#epoch-sync): the recommended, decentralized approach. This solution results in the smallest database size, as the node will only contain compacted block headers. +- [Using a snapshot](#sync-data-with-snapshot): a centralized solution. +- Fallback: If neither option is used, the node defaults to Header Sync, which can be extremely slow. +2. **Syncing blocks** - this involves downloading the blockchain state at the start of the latest epoch and then processing remaining blocks to fully sync with the chain. State sync, the process of downloading the state, can be done in two ways: +- Decentralized state sync: the default method, which pulls data directly from peers. +- [Centralized state sync](#state-sync-from-external-storage): uses cloud-based storage as a fallback when configured in `config.json`. -##### Epoch Sync -Epoch Sync allows a node to sync from genesis without relying on a snapshot. -Unlike Header Sync, it does not require downloading all past block headers but only a small subset of them. -Epoch Sync is enabled by default and requires boot nodes to be specified in the config file. -Instructions for setting boot nodes are provided below for decentralized state sync, so no additional configuration is needed to use Epoch Sync. - -You can adjust Epoch Sync behavior through the `config.json` file. The default values are as follows: -``` - "epoch_sync": { - "disable_epoch_sync_for_bootstrapping": false, - "ignore_epoch_sync_network_requests": false, - "epoch_sync_horizon": 216000, - "timeout_for_epoch_sync": { - "secs": 60, - "nanos": 0 - } - }, -``` -##### Using NEAR Peer-to-peers state sync +##### Epoch Sync -NEAR has decentralized state sync, a torrent like protocol for nodes to sync data with each others without relies on snapshot providers. -To sync with p2p state sync, you would need to get the latest boot nodes list from the NEAR network and update to `config.json` file and then start the neard service, here is the command: +Epoch Sync enables a node to sync from genesis without relying on snapshots. +Unlike Header Sync, it requires downloading only a small subset of past block headers rather than all of them. +To sync using Epoch Sync, update the `config.json` file with the latest boot nodes list from the NEAR network and then start the `neard` service, here is the command: ``` curl -s -X POST https://rpc.mainnet.near.org -H "Content-Type: application/json" -d '{ @@ -221,11 +202,11 @@ jq --arg newBootNodes "$(curl -s -X POST https://rpc.mainnet.near.org -H "Conten ``` after that, just restart the node (sudo systemctl restart neard). -Wait for sometime (maybe 10 hours) and you are done, follow the next step to become an active validator! +Wait for approximately 3 hours and you are done, follow the next step to become an active validator! -##### Sync data with snapshot: +##### Sync data with snapshot To sync data fast, we can download the snapshot of recent NEAR epochs instead of waiting for node sync with other peers, this process will take a few hours, the expected data size will be around 580GB. @@ -250,6 +231,11 @@ journalctl -n 100 -f -u neard | ccze -A Check the running status of the validator node. If you see something like the image above, it means the node is fully synced, and you are ready to become an active validator! +##### State sync from external storage + +To configure your node to sync from external storage, follow the [link](https://github.com/near/nearcore/blob/master/docs/misc/state_sync_from_external_storage.md). + + #### Becoming an active Validator In order to become a validator and enter the validator set to help secure the network and earn rewards, a minimum set of success criteria must be met: From ab39bf27497fc167f8730a29c857533b724f8dec Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Fri, 14 Feb 2025 14:39:24 +0100 Subject: [PATCH 10/23] Update guide.md Add How to get notify --- docs/validator/guide.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 78b4e31..6360548 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -376,6 +376,14 @@ View validator infos on NEARScope or NEARBlocks: The info will show like this: (source: NearScope) Pasted image 20240929194648.png +#### How to know when update node version + +You can use: +Discord: https://discord.gg/nearprotocol +Telegram: https://t.me/near_validators +X: https://x.com/NEARChainStatus (Only Mainnet) +Email : https://near.us14.list-manage.com/subscribe?u=faedf5dec8739fb92e05b4131&id=befd133f18 + #### How to update new node version When there is a new node version, you will get a notification on the Telegram Validator group, run this command to update the node. From cbdb1633382575612dd80bbe3fa66d5f92d8d6bc Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Fri, 14 Feb 2025 14:50:29 +0100 Subject: [PATCH 11/23] Update guide.md --- docs/validator/guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 6360548..9b13e72 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -245,7 +245,7 @@ Note: STAKING POOL CONTRACT WONT HAVE WRITE ACCESS TO ALL SUB ACCOUNTS FUNDS OR Calls the staking pool factory, creates a new staking pool with the specified name, and deploys it to the indicated accountId. ``` -near contract call-function as-transaction poolv1.near create_staking_pool json-args '{"staking_pool_id": "", "owner_id": "", "stake_public_key": "", "reward_fee_fraction": {"numerator": 5, "denominator": 100}}' prepaid-gas '100.0 Tgas' attached-deposit '30 NEAR' sign-as network-config mainnet sign-with-keychain +near contract call-function as-transaction poolv1.near create_staking_pool json-args '{"staking_pool_id": "", "owner_id": "", "stake_public_key": "", "reward_fee_fraction": {"numerator": 5, "denominator": 100}}' prepaid-gas '300.0 Tgas' attached-deposit '30 NEAR' sign-as network-config mainnet sign-with-keychain ``` From the example above, you need to replace: @@ -258,7 +258,7 @@ Be sure to have at least 30 NEAR available, it is the minimum required for stora Final command will look something like this: ``` -near contract call-function as-transaction poolv1.near create_staking_pool json-args '{"staking_pool_id": "panda", "owner_id": "validator_near.near", "stake_public_key": "ed25519:xxx", "reward_fee_fraction": {"numerator": 5, "denominator": 100}}' prepaid-gas '100.0 Tgas' attached-deposit '30 NEAR' sign-as validator_near.near network-config mainnet sign-with-keychain +near contract call-function as-transaction poolv1.near create_staking_pool json-args '{"staking_pool_id": "panda", "owner_id": "validator_near.near", "stake_public_key": "ed25519:xxx", "reward_fee_fraction": {"numerator": 5, "denominator": 100}}' prepaid-gas '300.0 Tgas' attached-deposit '30 NEAR' sign-as validator_near.near network-config mainnet sign-with-keychain ``` To change the pool parameters, such as changing the amount of commission charged to 1% in the example below, use this command: From dba24115f23be3cef02af316a123b3c3d41d9868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Chuda=C5=9B?= Date: Thu, 20 Feb 2025 14:23:11 +0000 Subject: [PATCH 12/23] nit --- docs/validator/guide.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index d6ebdd2..4ac6d71 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -234,6 +234,7 @@ Check the running status of the validator node. If you see something like the im ##### State sync from external storage To configure your node to sync from external storage, follow the [link](https://github.com/near/nearcore/blob/master/docs/misc/state_sync_from_external_storage.md). +The new state sync bucket is `fast-state-parts` and it is maintained by FastNEAR. #### Becoming an active Validator From e898e6f48e681edd574eedbc80eff7d3f7aab167 Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Fri, 21 Feb 2025 11:04:45 +0100 Subject: [PATCH 13/23] Update guide.md Add Config.json link for Mainnet - Validator --- docs/validator/guide.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 5f18ed5..a2ce605 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -463,6 +463,12 @@ Content/Type: application/json ##### Warn message Warn message can be ignored. You don't really need to worry about it. + + +##### Get Latest Config.json + +Config.json can be find : + ```https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/mainnet/validator/config.json ``` ##### Always kicked From 0cb094f87f7b2f398ada18243038daa6ed0e10ee Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:32:38 +0100 Subject: [PATCH 14/23] Update guide.md Review from Adam --- docs/validator/guide.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index a2ce605..02be31c 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -44,7 +44,7 @@ source ~/.bashrc During the building time, let's make a wallet. -We recommand to use a partner wallet like Meteor, MyNearWallet or SenderWallet. +We recommend to use a partner wallet like Meteor, MyNearWallet or SenderWallet. https://app.mynearwallet.com/ @@ -63,7 +63,7 @@ When this wallet is created and build is done, follow this step: #### Wallet Authorization -A full access key needs to be installed locally to be able transactions via NEAR-CLI. +A full access key needs to be installed locally to be able to send transactions via NEAR-CLI. ``` near login ``` @@ -371,8 +371,11 @@ Change validator name and description: Replace with your pool address, for example: panda.poolv1.near Replace with your authenticated wallet address, validator_near.near for this case -near contract call-function as-transaction pool-details.near update_field json-args '{"pool_id": "", "name": "name", "value": "PandaPool"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain -near contract call-function as-transaction pool-details.near update_field json-args '{"pool_id": "", "name": "description", "value": "PandaPool Description"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain + +```near contract call-function as-transaction pool-details.near update_field json-args '{"pool_id": "", "name": "name", "value": "PandaPool"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain``` + +```near contract call-function as-transaction pool-details.near update_field json-args '{"pool_id": "", "name": "description", "value": "PandaPool Description"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain``` + View your validator infos from CLI: near contract call-function as-read-only pool-details.near get_fields_by_pool json-args '{"pool_id":""}' network-config mainnet now From 14a178b30473d2220f8e3d4042efb605afea82ab Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:34:36 +0100 Subject: [PATCH 15/23] Update guide.md Update images --- docs/validator/guide.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 02be31c..23fee36 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -50,8 +50,8 @@ https://app.mynearwallet.com/ https://wallet.meteorwallet.app/ -![](file:///C:/Users/ddealmeida/Downloads/wallet_creation.png) - +![wallet_creation](https://github.com/user-attachments/assets/da2685a4-11c5-455f-a5eb-9fff4d28c934) + Add at least 31 NEAR to this wallet. 30 Near will be used for the wallet creation 1 Near will be use for the fees of transactions @@ -71,7 +71,8 @@ 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 -![](file:///C:/Users/ddealmeida/Downloads/login.png) +![login](https://github.com/user-attachments/assets/a4c14115-91d2-4a74-a2b8-781e76ada20b) + 2 – Grant Access to Near CLI, fill your validator address and press Enter From f0d1c1230abcb5717e24bf154d76ce30040345ac Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:37:41 +0100 Subject: [PATCH 16/23] Update guide.md Review from Adam --- docs/validator/guide.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 23fee36..314fbc9 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -391,8 +391,11 @@ Pasted image 20240929194648.png You can use: Discord: https://discord.gg/nearprotocol + Telegram: https://t.me/near_validators + X: https://x.com/NEARChainStatus (Only Mainnet) + Email : https://near.us14.list-manage.com/subscribe?u=faedf5dec8739fb92e05b4131&id=befd133f18 #### How to update new node version @@ -478,7 +481,7 @@ Config.json can be find : Make sure the config file have store.load_mem_tries_for_tracked_shards with true value -#### Usefull links: +#### Useful links: NEAR Chain Status Twitter: https://x.com/NEARChainStatus https://near-staking.com/ From 86784d3cff94e7a254ca6a126a17ec76c097257d Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:38:20 +0100 Subject: [PATCH 17/23] Update guide.md --- docs/validator/guide.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 314fbc9..79a8fc1 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -485,7 +485,9 @@ Make sure the config file have store.load_mem_tries_for_tracked_shards with true NEAR Chain Status Twitter: https://x.com/NEARChainStatus https://near-staking.com/ + https://nearblocks.io/node-explorer + https://nearscope.net/ #### Support: From aca7bf5718cdb0ebbf80f1c6b3bc76ed2739316e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Chuda=C5=9B?= Date: Wed, 26 Feb 2025 19:54:31 +0000 Subject: [PATCH 18/23] fmt --- docs/validator/guide.md | 373 +++++++++++++++++++++------------------- 1 file changed, 198 insertions(+), 175 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 79a8fc1..fcc917f 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -1,4 +1,3 @@ - ## Run a Node on Linux ### Recommended Hardware Specifications @@ -7,35 +6,39 @@ Please refer to [Hardware Requirements for Validator Node](/validator/hardware-v ### Node installation -#### Get Build and latest update -```sh +#### Get Build and latest update + +```sh sudo apt update && sudo apt upgrade -y && 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 awscli tmux jq ccze rclone ``` #### Install Rust - + For Rust, we use standard installation, just press "Enter" when asked for the setup. -```sh + +```sh curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && source $HOME/.cargo/env ``` -#### Install NEAR CLI and NEAR-Validator +#### Install NEAR CLI and NEAR-Validator -``` +```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh && -curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near-cli-rs/near-validator-cli-rs/releases/latest/download/near-validator-installer.sh | sh && -source $HOME/.cargo/env +curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near-cli-rs/near-validator-cli-rs/releases/latest/download/near-validator-installer.sh | sh && +source $HOME/.cargo/env ``` -#### Clone Nearcore repo +#### Clone Nearcore repo -First get lastest version available : -``` +First get latest version available: + +```sh Nearcore_Version=$(curl -s https://api.github.com/repos/near/nearcore/releases/latest | jq -r .tag_name) ``` -Clone the nearcore repo, choose the latest stable branch for mainnet and build the nearcore from source -``` +Clone the nearcore repo, choose the latest stable branch for mainnet and build the nearcore from source: + +```sh cd ~ && git clone https://github.com/near/nearcore && cd nearcore/ && git checkout $Nearcore_Version make release echo 'export NEAR_ENV=mainnet' >> ~/.bashrc @@ -44,92 +47,82 @@ source ~/.bashrc During the building time, let's make a wallet. -We recommend to use a partner wallet like Meteor, MyNearWallet or SenderWallet. +We recommend to use a partner wallet like Meteor, MyNearWallet or SenderWallet. -https://app.mynearwallet.com/ - -https://wallet.meteorwallet.app/ +- [MyNearWallet](https://app.mynearwallet.com/) +- [MeteorWallet](https://wallet.meteorwallet.app/) ![wallet_creation](https://github.com/user-attachments/assets/da2685a4-11c5-455f-a5eb-9fff4d28c934) -Add at least 31 NEAR to this wallet. -30 Near will be used for the wallet creation -1 Near will be use for the fees of transactions - -/!\ This 30 Near can't be recovered if you decided to stop your validator. - +Add at least **31 NEAR** to this wallet: +- **30 NEAR** will be used for wallet creation +- **1 NEAR** will be used for transaction fees -When this wallet is created and build is done, follow this step: - -#### Wallet Authorization +⚠️ This **30 NEAR** can't be recovered if you decide to stop your validator. -A full access key needs to be installed locally to be able to send transactions via NEAR-CLI. -``` -near login -``` -``Note: This command launches a web browser allowing for the authorization of a full access key to be copied locally.`` +#### Wallet Authorization -1 – Copy the link in your browser -![login](https://github.com/user-attachments/assets/a4c14115-91d2-4a74-a2b8-781e76ada20b) +A full access key needs to be installed locally to be able to send transactions via NEAR-CLI. +```sh +near login +``` -2 – Grant Access to Near CLI, fill your validator address and press Enter +**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. + + ![login](https://github.com/user-attachments/assets/a4c14115-91d2-4a74-a2b8-781e76ada20b) -3 - Choose “Store the access key in my keychain” from the CLI command. - -If you got error, you can retry near login with “Store the access key in my legacy keychain (compatible with the old near CLI)” +2. Grant Access to Near CLI, fill your validator address and press **Enter**. +3. Choose **"Store the access key in my keychain"** from the CLI command. +If you get an error, you can retry `near login` with **"Store the access key in my legacy keychain (compatible with the old near CLI)"**. -#### Initialize & Start the Node - -Time to think about your validator name. - -Your validator node will finish with a poolv1.near -Example, i want to have a validator pool named "panda", i will set panda.poolv1.near -Or i want to have a name "validator_near", my full poolname will be validator_near.poolv1.near +### Initialize & Start the Node +Time to think about your validator name. -Reminder: +Your validator node will finish with a `poolv1.near`. +For example: +- If you want to have a validator pool named "panda", set `panda.poolv1.near`. +- If you want to have a name "validator_near", your full pool name will be `validator_near.poolv1.near`. - – your pool name, for example panda - – xxx.poolv1.near, where xxx is your pool_id like panda.poolv1.near - or accountId – xxx.near where xxx your account name, for example validator_near.near +#### Reminder: +- `` – your pool name, for example `panda`. +- `` – `xxx.poolv1.near`, where `xxx` is your pool_id like `panda.poolv1.near`. +- `` or `accountId` – `xxx.near`, where `xxx` is your account name, for example `validator_near.near`. -``` +```sh cd ~/nearcore && target/release/neard init --chain-id="mainnet" --account-id= ``` -Set your , example: xxx.poolv1.near, where xxx is your pool_id - - - -validator_key.json generated after the above command in ~/.near/ folder must be something like this: +Set your ``, example: `xxx.poolv1.near`, where `xxx` is your pool_id. +`validator_key.json` generated after the above command in `~/.near/` folder must be something like this: +The `account_id` must match the staking pool contract ID, or you will not be able to sign/verify blocks. -The account_id must match the staking pool contract id or you will not be able to sign/verify blocks. +#### Tips before launching the node +If you want to reduce the size used by the data folder, you can run this command: - -Tips before launching the node, if you want to reduce the size used by the data folder. -You can run this command : - -This will reduce the number of epoch store from 5 (default) to 3, without any issue for your node. -``` +This will reduce the number of epoch stores from **5 (default) to 3**, without any issue for your node. +```sh jq '.gc_num_epochs_to_keep = 3' ~/.near/config.json > ~/.near/config.json.tmp && mv ~/.near/config.json.tmp ~/.near/config.json ``` -Update config.json to activate the validator config -``` +#### Update `config.json` to activate the validator config +```sh sed -i 's/"tracked_shards": \[\s*0\s*\]/"tracked_shards": []/' ~/.near/config.json ``` + #### Neard Service Let's setup Systemd so the node will always run with the system -``` +```sh sudo bash -c 'cat > /etc/systemd/system/neard.service << EOF [Unit] Description=NEARd Daemon Service @@ -149,20 +142,21 @@ KillMode=mixed WantedBy=multi-user.target EOF systemctl enable neard' - ``` - #### Syncing Data Syncing consists of two main steps: -1. **Syncing headers** - achieved in one of three ways: -- [Epoch Sync](#epoch-sync): the recommended, decentralized approach. This solution results in the smallest database size, as the node will only contain compacted block headers. -- [Using a snapshot](#sync-data-with-snapshot): a centralized solution. -- Fallback: If neither option is used, the node defaults to Header Sync, which can be extremely slow. -2. **Syncing blocks** - this involves downloading the blockchain state at the start of the latest epoch and then processing remaining blocks to fully sync with the chain. State sync, the process of downloading the state, can be done in two ways: -- Decentralized state sync: the default method, which pulls data directly from peers. -- [Centralized state sync](#state-sync-from-external-storage): uses cloud-based storage as a fallback when configured in `config.json`. + +1. **Syncing headers** – achieved in one of three ways: + - **[Epoch Sync](#epoch-sync)**: the recommended, decentralized approach. This solution results in the smallest database size, as the node will only contain compacted block headers. + - **[Using a snapshot](#sync-data-with-snapshot)**: a centralized solution. + - **Fallback**: If neither option is used, the node defaults to Header Sync, which can be extremely slow. + +2. **Syncing blocks** – involves downloading the blockchain state at the start of the latest epoch and then processing the remaining blocks to fully sync with the chain. State sync, the process of downloading the state, can be done in two ways: + - **Decentralized state sync**: the default method, which pulls data directly from peers. + - **[Centralized state sync](#state-sync-from-external-storage)**: uses cloud-based storage as a fallback when configured in `config.json`. + ##### Epoch Sync @@ -234,30 +228,30 @@ In order to become a validator and enter the validator set to help secure the ne - 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 or just run this command -``` +```sh near-validator validators network-config mainnet next - ``` +``` - 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 or your node will be kick out -Check the running status of the validator node. If “Validator” is showing up, your pool is selected in the current validators list. +Check the running status of the validator node. If "Validator" is showing up, your pool is selected in the current validators list. ##### Deploy your staking pool contract NEAR uses a staking pool factory with a whitelisted staking contract to ensure delegators’ funds are safe. In order to run a validator on NEAR, a staking pool must be deployed to a NEAR account and integrated into a NEAR validator node. Delegators must use a UI or the command line to stake to the pool. A staking pool is a smart contract that is deployed to a NEAR account. -Note: STAKING POOL CONTRACT WONT HAVE WRITE ACCESS TO ALL SUB ACCOUNTS FUNDS OR DATA, this also applies for any sub accounts on NEAR, that means your staking balance is SAFU! +Note: STAKING POOL CONTRACT WON'T HAVE WRITE ACCESS TO ALL SUB ACCOUNTS FUNDS OR DATA, this also applies for any sub accounts on NEAR, that means your staking balance is SAFE! ##### Deploy a Staking Pool Contract Calls the staking pool factory, creates a new staking pool with the specified name, and deploys it to the indicated accountId. -``` +```sh near contract call-function as-transaction poolv1.near create_staking_pool json-args '{"staking_pool_id": "", "owner_id": "", "stake_public_key": "", "reward_fee_fraction": {"numerator": 5, "denominator": 100}}' prepaid-gas '300.0 Tgas' attached-deposit '30 NEAR' sign-as network-config mainnet sign-with-keychain ``` From the example above, you need to replace: -**pool_id**: Staking pool name example “panda” +**pool_id**: Staking pool name example "panda" **owner_id**: The NEAR account that will manage the staking pool. Usually your main NEAR account. **public_key**: The public key in your validator_key.json file. **5**: The fee the pool will charge (e.g. in this case 5 over 100 is 5% of fees), usually validators take 5% fee, if you set the fee so high, no one will stake to your node 😉 @@ -265,38 +259,41 @@ From the example above, you need to replace: Be sure to have at least 30 NEAR available, it is the minimum required for storage. Final command will look something like this: -``` +```sh near contract call-function as-transaction poolv1.near create_staking_pool json-args '{"staking_pool_id": "panda", "owner_id": "validator_near.near", "stake_public_key": "ed25519:xxx", "reward_fee_fraction": {"numerator": 5, "denominator": 100}}' prepaid-gas '300.0 Tgas' attached-deposit '30 NEAR' sign-as validator_near.near network-config mainnet sign-with-keychain ``` To change the pool parameters, such as changing the amount of commission charged to 1% in the example below, use this command: -``` +```sh near contract call-function as-transaction update_reward_fee_fraction json-args '{"reward_fee_fraction": {"numerator": 1, "denominator": 100}}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain ``` -Note: full_pool_id: .poolv1.near , it’s panda.poolv1.near in this case +Note: full_pool_id: `.poolv1.near` , it’s `panda.poolv1.near` in this case. -If there is a “True” at the End. Your pool is created. +If there is a "True" at the End. Your pool is created. Congrats! You have now configure your Staking pool up and running 🚀🚀🚀🚀 + #### Manage your staking pool contract + Few useful commands you should know: Retrieve the owner ID of the staking pool -``` +```sh near contract call-function as-read-only get_owner_id json-args {} network-config mainnet now ``` Issue this command to retrieve the public key the network has for your validator -``` +```sh near contract call-function as-read-only get_staking_key json-args {} network-config mainnet now ``` - If the public key does not match you can update the staking key like this (replace the pubkey below with the key in your validator.json file) -``` +```sh near contract call-function as-transaction update_staking_key json-args '{"stake_public_key": ""}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain ``` + Working with Staking Pools + NOTE: Your validator must be fully synced before issuing a proposal or depositing funds. #### Proposals and Pings @@ -306,10 +303,9 @@ To note, a ping also updates the staking balances for your delegators. A ping sh Ping are done by Metapool too, you don't need anymore to use a script ping but you can. You need at least 1 ping to be visible for the first time. +Replace `` and `` before execution: -Replace and before execution: - -``` +```sh mkdir -p /home/root/scripts /home/root/logs && sudo bash -c 'cat > /home/root/scripts/ping.sh << EOF #!/bin/sh # Ping call to renew Proposal added to crontab @@ -322,26 +318,26 @@ date >> \$LOGS/near_ping.log near contract call-function as-transaction \$POOLID ping json-args '\''{"stake_public_key": ""}'\'' prepaid-gas '\''100.0 Tgas'\'' attached-deposit '\''0 NEAR'\'' sign-as \$ACCOUNTID network-config mainnet sign-with-keychain >> \$LOGS/near_ping.log EOF chmod +x /home/root/scripts/ping.sh && (crontab -l 2>/dev/null; echo "0 */8 * * * sh /home/root/scripts/ping.sh") | crontab -' -``` +``` + This will ping you node every 8h List crontab to see it is running: -``` +```sh crontab -l ``` Review your logs -``` +```sh cat $HOME/logs/near_ping.log ``` Now you only need to have enough token staked to start earning Rewards. - #### Network optimizations To optimize the network settings for better validator performance, execute the following commands: -``` +```sh MaxExpectedPathBDP=8388608 && \ sudo sysctl -w net.core.rmem_max=$MaxExpectedPathBDP && \ sudo sysctl -w net.core.wmem_max=$MaxExpectedPathBDP && \ @@ -359,78 +355,107 @@ EOL sudo sysctl --system ``` -#### How to have Logo, description, contact details on Nearscope - Near Staking -Adding pool information helps delegators and also helps with outreach for upgrades and other important announcements: https://github.com/zavodil/near-pool-details. - -The available fields to add are: https://github.com/zavodil/near-pool-details/blob/master/FIELDS.md. +### How to have Logo, Description, Contact Details on Nearscope - Near Staking -The identifying information that validators need to provide are: name, description, url, telegram, twitter… +Adding pool information helps delegators and also helps with outreach for upgrades and other important announcements: [Near Pool Details](https://github.com/zavodil/near-pool-details). -Example commands: +The available fields to add are: [Fields Documentation](https://github.com/zavodil/near-pool-details/blob/master/FIELDS.md). -Change validator name and description: +The identifying information that validators need to provide includes: +- Name +- Description +- URL +- Telegram +- Twitter -Replace with your pool address, for example: panda.poolv1.near -Replace with your authenticated wallet address, validator_near.near for this case +#### Example Commands -```near contract call-function as-transaction pool-details.near update_field json-args '{"pool_id": "", "name": "name", "value": "PandaPool"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain``` +**Change validator name and description:** +Replace `` with your pool address, e.g., `panda.poolv1.near`. +Replace `` with your authenticated wallet address, e.g., `validator_near.near`. -```near contract call-function as-transaction pool-details.near update_field json-args '{"pool_id": "", "name": "description", "value": "PandaPool Description"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain``` +``` +near contract call-function as-transaction pool-details.near update_field json-args '{"pool_id": "", "name": "name", "value": "PandaPool"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain +``` -View your validator infos from CLI: +``` +near contract call-function as-transaction pool-details.near update_field json-args '{"pool_id": "", "name": "description", "value": "PandaPool Description"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config mainnet sign-with-keychain +``` +**View your validator info from CLI:** +``` near contract call-function as-read-only pool-details.near get_fields_by_pool json-args '{"pool_id":""}' network-config mainnet now - +``` -View validator infos on NEARScope or NEARBlocks: +**View validator info on NearScope or NearBlocks:** +The info will appear as shown on NearScope. -The info will show like this: (source: NearScope) -Pasted image 20240929194648.png +--- -#### How to know when update node version +### How to Know When to Update Node Version -You can use: -Discord: https://discord.gg/nearprotocol +You can get update notifications from: +- **Discord:** [NEAR Protocol Discord](https://discord.gg/nearprotocol) +- **Telegram:** [NEAR Validators Group](https://t.me/near_validators) +- **Twitter (X):** [NEAR Chain Status](https://x.com/NEARChainStatus) *(Only for Mainnet)* +- **Email Subscription:** [NEAR Update Notifications](https://near.us14.list-manage.com/subscribe?u=faedf5dec8739fb92e05b4131&id=befd133f18) -Telegram: https://t.me/near_validators +--- -X: https://x.com/NEARChainStatus (Only Mainnet) +### How to Update Node Version -Email : https://near.us14.list-manage.com/subscribe?u=faedf5dec8739fb92e05b4131&id=befd133f18 +When there is a new node version, you will receive a notification on the Telegram Validator group. Run the following command to update your node: -#### How to update new node version -When there is a new node version, you will get a notification on the Telegram Validator group, run this command to update the node. - -[CODE_RED_] where is either MAINNET or TESTNET. This represents the most dire and urgent situation. Usually it means that the network has stalled or crashed and we need validators to take immediate actions to bring the network up. Alternatively it could mean that we discovered some highly critical security vulnerabilities and a patch is needed as soon as possible. If it is about mainnet, we expect that validators will react immediately to such alerts, ideally within 30 minutes. +``` +cd ~/nearcore && git fetch && export NEAR_RELEASE_VERSION= && git checkout $NEAR_RELEASE_VERSION && make release && sudo systemctl stop neard && sudo systemctl start neard +``` + +Replace `` with the correct NEAR core release version. + +**Update Priority Codes:** +- **CODE_RED_** – where `` is either `MAINNET` or `TESTNET`. This represents the most dire and urgent situation. Usually it means that the network has stalled or crashed and we need validators to take immediate actions to bring the network up. Alternatively it could mean that we discovered some highly critical security vulnerabilities and a patch is needed as soon as possible. If it is about mainnet, we expect that validators will react **immediately** to such alerts, ideally within 30 minutes. +- **CODE_YELLOW_** – where `` is either `MAINNET` or `TESTNET`. This represents a less urgent announcement. Usually it means the release of a protocol change or a fix of a moderate security issue. In such cases, validators are not expected to take immediate actions but are still expected to **react within days**. +- **CODE_GREEN_** – where `` is either `MAINNET` or `TESTNET`. This usually means some general announcement that is more informational or doesn<80><99>t require actions within a short period of time. It could be an announcement of a release that improves performance or a fix some minor issues. + +--- + +### Monitor the Node Performance +- **Monitoring Tools:** + - [NEAR Prometheus Exporter](https://github.com/LavenderFive/near_prometheus_exporter) + - [NEAR Monitoring](https://github.com/LavenderFive/near-monitoring) +- **Telegram BOT Monitoring:** [Near Validator Watcher Bot](https://t.me/nearvalidatorwatcherbot) + +--- + +### How to Withdraw Your Rewards -[CODE_YELLOW_] where is either MAINNET or TESTNET. This represents a less urgent announcement. Usually it means the release of a protocol change or a fix of a moderate security issue. In such cases, validators are not expected to take immediate actions but are still expected to react within days. +Log in to your wallet you created few steps before, unstake (takes 3 epochs), and withdraw. -[CODE_GREEN_] where is either MAINNET or TESTNET. This usually means some general announcement that is more informational or doesn’t require actions within a short period of time. It could be an announcement of a release that improves performance or a fix some minor issues. +--- +### Useful Commands +**Get active epoch data (list of active validators, seat price, and performance):** ``` -cd ~/nearcore && git fetch && export NEAR_RELEASE_VERSION= && git checkout $NEAR_RELEASE_VERSION && make release && sudo systemctl stop neard && sudo systemctl start neard +near-validator validators network-config mainnet now ``` -Replace with the correct nearcore release version. -#### Monitor the node performance -Take a look at : https://github.com/LavenderFive/near_prometheus_exporter and https://github.com/LavenderFive/near-monitoring +**Next epoch validators list:** +``` +near-validator validators network-config mainnet next +``` -#### Monitor the node (Telegram BOT): -Take a look here: https://t.me/nearvalidatorwatcherbot +**View validator staked balance:** +``` +near-validator staking view-stake network-config mainnet now +``` -#### How to withdraw your rewards -Logged on a wallet with the wallet you created few steps before, unstake (take 3epoch) and withdraw. +--- -#### Useful commands -Get active epoch data like : list of active validators and the current seat price, their current performance: near-validator validators network-config mainnet now -Next epoch validators list: near-validator validators network-config mainnet next -View validator staked balance: near-validator staking view-stake network-config mainnet now - -#### Troubleshoot - -##### No peers -If you don't have any peers, run this script: +### Troubleshooting + +#### No Peers +If you have no peers, run this script: ``` neard `curl -X POST https://rpc.mainnet.near.org \ -H "Content-Type: application/json" \ -d '{ @@ -445,51 +470,49 @@ select(.peer_id == $active_peer.id) | "\(.peer_id)@\($active_peer.addr)"' |\ awk 'NR>2 {print ","} length($0) {print p} {p=$0}' ORS="" | sed 's/"//g'` ```` -##### Weird error on running command -First check that you are using the correct NEAR-CLI + +#### Weird Error When Running a Command + +First, check that you are using the correct NEAR-CLI: ``` near --version ``` +**Expected Output:** `near-cli-rs 0.XX.X` -MUST return near-cli-rs 0.XX.X - -If return X.X.XX - -It seems that NEAR CLI JS is still overshadowing the Rust one. +If it returns `X.X.XX`, the NEAR CLI JS version is overshadowing the Rust version. You can either: +- Use `npx near-cli-rs` instead of `near`. +- Uninstall `near-cli` with: `npm remove near-cli`. -You can use npx near-cli-rs instead of near to make is explicit call to the Rust CLI, or uninstall near-cli: npm remove near-cli - -##### How to get Metrics from my node - -You can check metrics with : +#### How to Get Metrics from My Node +Check metrics with: ``` curl -s http://localhost:3030/metrics -``` -Content/Type: application/json - -##### Warn message - -Warn message can be ignored. You don't really need to worry about it. +``` +**Content Type:** `application/json` +#### Warning Messages +Warning messages can be ignored unless they indicate critical issues. -##### Get Latest Config.json +#### Get Latest Config.json +Find the latest `config.json` here: +``` +https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/mainnet/validator/config.json +``` -Config.json can be find : - ```https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/mainnet/validator/config.json ``` - -##### Always kicked - -Make sure the config file have store.load_mem_tries_for_tracked_shards with true value +#### Always Kicked Issue +Ensure your config file has `store.load_mem_tries_for_tracked_shards` set to `true`. -#### Useful links: -NEAR Chain Status Twitter: https://x.com/NEARChainStatus +--- -https://near-staking.com/ +### Useful Links +- **NEAR Chain Status Twitter:** [@NEARChainStatus](https://x.com/NEARChainStatus) +- **NEAR Staking:** [Near Staking Website](https://near-staking.com/) +- **NEARBlocks Node Explorer:** [NearBlocks](https://nearblocks.io/node-explorer) +- **NearScope:** [NearScope](https://nearscope.net/) -https://nearblocks.io/node-explorer +--- + +### Support +- **Telegram:** [NEAR Validators](https://t.me/near_validators) +- **Discord:** [NEAR Protocol Discord](https://discord.gg/nearprotocol) -https://nearscope.net/ - -#### Support: -Telegram: https://t.me/near_validators -Discord: https://discord.gg/nearprotocol From 3ad0621036f471a56fd8320eaf2b1ac08df68957 Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Fri, 14 Mar 2025 08:51:32 +0100 Subject: [PATCH 19/23] Apply suggestions from code review Co-authored-by: Razvan Barbascu --- docs/validator/guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index fcc917f..53531cc 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -407,7 +407,7 @@ You can get update notifications from: When there is a new node version, you will receive a notification on the Telegram Validator group. Run the following command to update your node: ``` -cd ~/nearcore && git fetch && export NEAR_RELEASE_VERSION= && git checkout $NEAR_RELEASE_VERSION && make release && sudo systemctl stop neard && sudo systemctl start neard +cd ~/nearcore && git fetch && export NEAR_RELEASE_VERSION= && git checkout tags/$NEAR_RELEASE_VERSION && make release && sudo systemctl stop neard && sudo systemctl start neard ``` Replace `` with the correct NEAR core release version. From 7044babe8f5682aab7ea706c3abec1c366e7bd23 Mon Sep 17 00:00:00 2001 From: David <52310650+DDeAlmeida@users.noreply.github.com> Date: Thu, 27 Mar 2025 16:06:14 +0100 Subject: [PATCH 20/23] Update due to suggestion --- docs/validator/guide.md | 70 +++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 53531cc..8ec619b 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -94,9 +94,17 @@ For example: - `` – `xxx.poolv1.near`, where `xxx` is your pool_id like `panda.poolv1.near`. - `` or `accountId` – `xxx.near`, where `xxx` is your account name, for example `validator_near.near`. -```sh -cd ~/nearcore && target/release/neard init --chain-id="mainnet" --account-id= -``` +# You can use any RPC provider for this command. +```BOOT_NODES=$(curl -s -X POST https://rpc.mainnet.near.org -H "Content-Type: application/json" -d '{ + "jsonrpc": "2.0", + "method": "network_info", + "params": [], + "id": "dontcare" + }' | jq -r '.result.active_peers as $list1 | .result.known_producers as $list2 | + $list1[] as $active_peer | $list2[] | + select(.peer_id == $active_peer.id) | + "\(.peer_id)@\($active_peer.addr)"' | paste -sd "," -) +cd ~/nearcore && target/release/neard init --chain-id="mainnet" --account-id= --download-genesis --download-config validator --boot-nodes $BOOT_NODES ``` Set your ``, example: `xxx.poolv1.near`, where `xxx` is your pool_id. @@ -112,12 +120,27 @@ This will reduce the number of epoch stores from **5 (default) to 3**, without a jq '.gc_num_epochs_to_keep = 3' ~/.near/config.json > ~/.near/config.json.tmp && mv ~/.near/config.json.tmp ~/.near/config.json ``` -#### Update `config.json` to activate the validator config +#### Network optimizations +To optimize the network settings for better validator performance, execute the following commands: + ```sh -sed -i 's/"tracked_shards": \[\s*0\s*\]/"tracked_shards": []/' ~/.near/config.json +MaxExpectedPathBDP=8388608 && \ +sudo sysctl -w net.core.rmem_max=$MaxExpectedPathBDP && \ +sudo sysctl -w net.core.wmem_max=$MaxExpectedPathBDP && \ +sudo sysctl -w net.ipv4.tcp_rmem="4096 87380 $MaxExpectedPathBDP" && \ +sudo sysctl -w net.ipv4.tcp_wmem="4096 16384 $MaxExpectedPathBDP" && \ +sudo sysctl -w net.ipv4.tcp_slow_start_after_idle=0 && \ +sudo bash -c "cat > /etc/sysctl.d/local.conf" < ~/.near/config.tmp && mv ~/.near/config.json ~/.near/config.json.backup && mv ~/.near/config.tmp ~/.near/config.json + "\(.peer_id)@\($active_peer.addr)"' | paste -sd "," -) +jq --arg newBootNodes $BOOT_NODES '.network.boot_nodes = $newBootNodes' ~/.near/config.json > ~/.near/config.tmp && mv ~/.near/config.json ~/.near/config.json.backup && mv ~/.near/config.tmp ~/.near/config.json ``` after that, just restart the node (sudo systemctl restart neard). @@ -334,27 +351,6 @@ cat $HOME/logs/near_ping.log Now you only need to have enough token staked to start earning Rewards. -#### Network optimizations -To optimize the network settings for better validator performance, execute the following commands: - -```sh -MaxExpectedPathBDP=8388608 && \ -sudo sysctl -w net.core.rmem_max=$MaxExpectedPathBDP && \ -sudo sysctl -w net.core.wmem_max=$MaxExpectedPathBDP && \ -sudo sysctl -w net.ipv4.tcp_rmem="4096 87380 $MaxExpectedPathBDP" && \ -sudo sysctl -w net.ipv4.tcp_wmem="4096 16384 $MaxExpectedPathBDP" && \ -sudo sysctl -w net.ipv4.tcp_slow_start_after_idle=0 && \ -sudo bash -c "cat > /etc/sysctl.d/local.conf" < Date: Wed, 2 Apr 2025 22:46:30 +0100 Subject: [PATCH 21/23] Fix comment. --- docs/validator/guide.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 8ec619b..fa1bf50 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -94,8 +94,9 @@ For example: - `` – `xxx.poolv1.near`, where `xxx` is your pool_id like `panda.poolv1.near`. - `` or `accountId` – `xxx.near`, where `xxx` is your account name, for example `validator_near.near`. +```sh # You can use any RPC provider for this command. -```BOOT_NODES=$(curl -s -X POST https://rpc.mainnet.near.org -H "Content-Type: application/json" -d '{ +BOOT_NODES=$(curl -s -X POST https://rpc.mainnet.near.org -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "method": "network_info", "params": [], From bcf3f7720fcce0709dddb392efcb30ed37aada94 Mon Sep 17 00:00:00 2001 From: Razvan Barbascu Date: Wed, 2 Apr 2025 22:47:15 +0100 Subject: [PATCH 22/23] FIx script --- docs/validator/guide.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index fa1bf50..52f3920 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -454,18 +454,16 @@ near-validator staking view-stake network-config mainnet now #### No Peers If you have no peers, run this script: ``` -neard `curl -X POST https://rpc.mainnet.near.org \ -H "Content-Type: application/json" \ - -d '{ +BOOT_NODES=$(curl -s -X POST https://rpc.mainnet.near.org -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "method": "network_info", "params": [], "id": "dontcare" - }' | \ -jq '.result.active_peers as $list1 | .result.known_producers as $list2 | -$list1[] as $active_peer | $list2[] | -select(.peer_id == $active_peer.id) | -"\(.peer_id)@\($active_peer.addr)"' |\ -awk 'NR>2 {print ","} length($0) {print p} {p=$0}' ORS="" | sed 's/"//g'` + }' | jq -r '.result.active_peers as $list1 | .result.known_producers as $list2 | + $list1[] as $active_peer | $list2[] | + select(.peer_id == $active_peer.id) | + "\(.peer_id)@\($active_peer.addr)"' | paste -sd "," -) +jq --arg newBootNodes $BOOT_NODES '.network.boot_nodes = $newBootNodes' ~/.near/config.json > ~/.near/config.tmp && mv ~/.near/config.json ~/.near/config.json.backup && mv ~/.near/config.tmp ~/.near/config.json ```` #### Weird Error When Running a Command From 26f8f7f16f2c7db763be0894384543ae6928cb7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Chuda=C5=9B?= Date: Thu, 3 Apr 2025 10:29:26 +0000 Subject: [PATCH 23/23] build fix --- docs/validator/guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/validator/guide.md b/docs/validator/guide.md index 52f3920..70c6762 100644 --- a/docs/validator/guide.md +++ b/docs/validator/guide.md @@ -412,7 +412,7 @@ Replace `` with the correct NEAR core release version. **Update Priority Codes:** - **CODE_RED_** – where `` is either `MAINNET` or `TESTNET`. This represents the most dire and urgent situation. Usually it means that the network has stalled or crashed and we need validators to take immediate actions to bring the network up. Alternatively it could mean that we discovered some highly critical security vulnerabilities and a patch is needed as soon as possible. If it is about mainnet, we expect that validators will react **immediately** to such alerts, ideally within 30 minutes. - **CODE_YELLOW_** – where `` is either `MAINNET` or `TESTNET`. This represents a less urgent announcement. Usually it means the release of a protocol change or a fix of a moderate security issue. In such cases, validators are not expected to take immediate actions but are still expected to **react within days**. -- **CODE_GREEN_** – where `` is either `MAINNET` or `TESTNET`. This usually means some general announcement that is more informational or doesn<80><99>t require actions within a short period of time. It could be an announcement of a release that improves performance or a fix some minor issues. +- **CODE_GREEN_** – where `` is either `MAINNET` or `TESTNET`. This usually means some general announcement that is more informational or doesn't require actions within a short period of time. It could be an announcement of a release that improves performance or a fix some minor issues. ---