Running a node

Running a node and setting up staking.

Intro

This will teach you how to set up a node that syncs with the official TestNet. You can take a look at the core code found here: https://github.com/nearprotocol/nearcore

If you want to run a node, and then become a validator, read below and then follow these instructions:

Setup

By default we use Docker to run the client (with auto-updating via watchtower to upgrade the node to the new versions automatically).

Follow next instructions to install Docker on your machine:

The following instructions will only work once you're running Docker on your machine.

NOTE: We don't recommend this unless you're contributing to nearcore or you know what you're trying to do, but you can run a node without docker by adding the --local flag to the start testnet script found below. See how to do this under Compile TestNet without Docker.

Running official TestNet node with Docker

To run locally, clone the nearcore repo.

git clone https://github.com/nearprotocol/nearcore.git

cd into it...

cd nearcore

and then run ./scripts/start_testnet.py

On MacOS

./scripts/start_testnet.py

On Ubuntu

sudo ./scripts/start_testnet.py

You will then be prompted for an Account ID. You can leave this empty if you would just like to run a node. Validators should use the account ID of the account you want to stake with:

Enter your account ID (leave empty if not going to be a validator):

A node will then start in the background inside the docker. To check the logs inside the docker, run docker logs --follow nearcore.

Legend: # 7153 | BlockHeight V/1 | 'V' (validator) or '—' (regular node) / Total Validators 0/0/40 | connected peers / up to date peers / max peers

If you're interested in becoming a validator, take a look at:

Compile TestNet without Docker

Alternatively, you can build and run validator on this machine without docker by using the --local flag. This will install Rust and compile the binary.

For Mac OS, make sure you have developer tools installed (like git) and then use brew to install extra tools:

brew install cmake protobuf

For Linux install next dependencies:

sudo apt update
sudo apt install -y git binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev cmake gcc g++ python docker.io protobuf-compiler

Then run the script:

git clone https://github.com/nearprotocol/nearcore.git
cd nearcore

Finally: On MacOS

./scripts/start_testnet.py --local

On Ubuntu

sudo ./scripts/start_testnet.py --local

Running official TestNet on GCP

Create new instance, with at least:

  • 2 vCPU and 3.75 GB of RAM.

  • Select Ubuntu 18.04 LTS or later.

  • Allocate 100GB of persistent storage.

Add firewall rules to allow traffic to 24567 port from all IPs (0.0.0.0/0)

SSH into the machine (there is "SSH" button in the console or use gcloud ssh command).

Run:

sudo apt update
sudo apt install -y git binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev cmake gcc g++ python docker.io protobuf-compiler

Now run commands from Running TestNet Node with Docker.