How to install and run an ETH 2.0 Validator Node — Simply Staking

Jacques Vella Critien
Simply Staking
Published in
8 min readAug 31, 2021

In this tutorial, we’ll be going through the steps to set up, install and run an ETH 2.0 validator node on the Pyrmont testnet. Note that the process of deploying a validator node on Prater (testnet) and mainnet is similar.

Requirements

To run an ETH 2.0 node one needs:

  • Validator client — Responsible for producing new blocks and attestations in the beacon chain and shard chains.
  • Beacon chain client — Responsible for managing the state of the beacon chain, validator shuffling, and more.
  • Eth1 node — Supplies incoming validator deposits from the eth1 chain to the beacon chain client.

In this case, our Eth1 node will be connected to the Goerli network. Moreover, in this tutorial, the validator client, beacon chain client, and Eth1 node will all be set up on the same machine.

Machine Requirements:

  • Operating system: 64-bit Linux (i.e. Ubuntu 20.04 LTS Server or Desktop)
  • Processor: Quad core CPU, Intel Core i7–4770 or AMD FX-8310 or better
  • Memory: 16GB RAM or more
  • Storage: 2TB SSD or more
  • ETH balance: Goerli ETH and some ETH for deposit transaction fees
  • Wallet: Metamask installed

Ports required:

  • Prysm uses port 13000 tcp and port 12000 udp
  • Port 30303 tcp/udp for eth1 node

Steps

Now, we will be going through the necessary steps to set up the validator node.

Step 1: Obtaining testnet ETH

One needs 32ETH per validator and hence, we need to obtain some testnet ETH for Goerli account on Metamask.

To do this, you have two options:
1) Use the faucet at https://faucet.goerli.mudit.blog/
2) Join the discord server at https://discord.gg/hfgjQDr. However, this requires a process that will be explained when we get to depositing the 32ETH

Step 2: Setting up a user so that we do not use the root user

The commands in the script below create a new user named validator so that we run our commands through this user instead of using the root user, to mitigate any possible security vulnerabilities.
Note: The commands below should be run as root

#create user
sudo useradd -m -s /bin/bash validator
#disable login
passwd -l validator
#add user to sudo group
sudo usermod -aG sudo validator
#use the user
su validator

Step 3: Downloading eth2deposit-cli to generate key pairs

This step involves downloading eth2deposit-cli to generate key pairs used to create a deposit through the launchpad website.

Note: For this tutorial, we are using a pre-built binary whose checksum and binary can be obtained from this releases page.

#download the pre-built binary
cd $HOME
wget https://github.com/ethereum/eth2.0-deposit-cli/releases/download/v1.2.0/eth2deposit-cli-256ea21-linux-amd64.tar.gz
#perform a checksum
echo "825035b6d6c06c0c85a38f78e8bf3e9df93dfd16bf7b72753b6888ae8c4cb30a *eth2deposit-cli-256ea21-linux-amd64.tar.gz" | shasum -a 256 --check

After performing the checksum, ensure that the following output is visible

eth2deposit-cli-256ea21-linux-amd64.tar.gz: OK

Once the checksum is complete, the binary is extracted

#extract the binary
tar -xvf eth2deposit-cli-256ea21-linux-amd64.tar.gz
mv eth2deposit-cli-256ea21-linux-amd64 eth2deposit-cli
rm eth2deposit-cli-256ea21-linux-amd64.tar.gz
cd eth2deposit-cli

Step 4: Generating key pairs

This step involves generating two sets of key pairs which are then used to create a deposit through the launchpad website.

#create a new mnemonic (change the chain according to your need) ./deposit new-mnemonic --chain pyrmont

The last command will prompt for a KEYSTORE password which should be kept safely together with the generated mnemonic.
Moreover, it will generate files inside a folder named validator_keys in $HOME/eth2deposit-cli. Once again, these should be backed up and kept safe.

Step 5: Signing up to be a validator by depositing ETH through Launchpad

To be an ETH 2.0 validator, one has to make a deposit through the launchpad’s website.

Below is a list of launchpad links according to the different networks available:

According to what you chose in step 1, follow the respective option below:

A) If you used the authenticated faucet, follow Step 5A
B) If you joined the discord server, follow Step 5B

Step 5A: Depositing after using the authenticated faucet

A) Upload your deposit_data-#########.json (found in the validator_keys directory) to the launchpad website

Upload your deposit_data-#########.json file

B) Connect to the launchpad with your Metamask wallet, review and accept terms.

Connect your wallet

C) Confirm the transaction(s). There’s one deposit transaction of 32 ETH for each validator.

Step 5B: Depositing after using the Discord server’s faucet

If you joined the Discord Server, follow this video

Step 6: Checking the status of the application

After following one of the options above, you can monitor your validator’s application process by going on this link
https://pyrmont.beaconcha.in/validator/0x<pubkey>. (Pyrmont can be changed to Prater or mainnet)

When the application is still pending it will look like the below

Pending application

When the application is ready, the output should look like this

Active validator

Step 7: Setting up an ETH 1 node

In order to set up an ETH 2 node, you need a connection to an Ethereum 1.0 node. In this tutorial, Geth will be used to do so.
The following commands can be used to set up the node

#install from repository
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update -y
sudo apt-get install ethereum -y
#write a service file
cat > $HOME/eth1.service << EOF
[Unit]
Description = geth eth1 service
Wants = network-online.target
After = network-online.target
[Service]
User = $(whoami)
ExecStart = /usr/bin/geth --http --goerli --metrics --pprof
Restart = on-failure
RestartSec = 3
TimeoutSec = 300
[Install]
WantedBy = multi-user.target
EOF
#move the file to /etc/systemd/system
sudo mv $HOME/eth1.service /etc/systemd/system/eth1.service
sudo chmod 644 /etc/systemd/system/eth1.service
#enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable eth1
sudo systemctl start eth1

Step 8: Downloading Prysm and importing the validator keys

In this tutorial, Prysm is used to set up the ETH 2.0 beacon chain node and validator. Therefore, in this step, we will be downloading Prysm and importing our validator keys that were generated in the previous steps

#install prysm
mkdir ~/prysm && cd ~/prysm
curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh && chmod +x prysm.sh
#import validator keys
#here you have to enter a new passwory to encrypt your local prysm wallet and the keystore password for your imported which was entered earlier
#NOTE: the prysm and keystore password can be the same

$HOME/prysm/prysm.sh validator accounts import --pyrmont --keys-dir=$HOME/eth2deposit-cli/validator_keys
#verify that the validators were imported
$HOME/prysm/prysm.sh validator accounts list --pyrmont

Step 9: Starting the beacon chain node

#create the service
cat > $HOME/beacon-chain.service << EOF
# The eth2 beacon chain service (part of systemd)
# file: /etc/systemd/system/beacon-chain.service
[Unit]
Description = eth2 beacon chain service
Wants = network-online.target
After = network-online.target
[Service]
Type = simple
User = $(whoami)
ExecStart = $(echo $HOME)/prysm/prysm.sh beacon-chain --pyrmont --p2p-max-peers=45 --monitoring-host="0.0.0.0" --http-web3provider=http://127.0.0.1:8545 --accept-terms-of-use
Restart = on-failure
[Install]
WantedBy = multi-user.target
EOF
#move the service to /etc/systemd/system
sudo mv $HOME/beacon-chain.service /etc/systemd/system/beacon-chain.service
sudo chmod 644 /etc/systemd/system/beacon-chain.service
#start the service
sudo systemctl daemon-reload
sudo systemctl enable beacon-chain
sudo systemctl start beacon-chain

Step 10: Storing the Prysm password

In this step, we store the Prysm password so that Prysm can pick it up, decrypt it and load the validator

#This is required so that Prysm can decrypt and load your validators.
echo 'my_password_goes_here' > $HOME/.eth2validators/validators-password.txt
sudo chmod 600 $HOME/.eth2validators/validators-password.txt

Step 11: Starting the validator

#create the service
cat > $HOME/validator.service << EOF
# The eth2 validator service (part of systemd)
# file: /etc/systemd/system/validator.service
[Unit]
Description = eth2 validator service
Wants = network-online.target beacon-chain.service
After = network-online.target
[Service]
User = $(whoami)
ExecStart = $(echo $HOME)/prysm/prysm.sh validator --pyrmont --accept-terms-of-use --wallet-password-file $(echo $HOME)/.eth2validators/validators-password.txt
Restart = on-failure
[Install]
WantedBy = multi-user.target
EOF
#move the file to /etc/systemd/system
sudo mv $HOME/validator.service /etc/systemd/system/validator.service
sudo chmod 644 /etc/systemd/system/validator.service
#start the service
sudo systemctl daemon-reload
sudo systemctl enable validator
sudo systemctl start validator

One can verify that the validator started by verifying that the validator’s public key appears in the logs as below:

INFO Enabled validator voting_pubkey: 0x2374.....7121

Adding more validators

This section explains how the number of validators in a node can be increased.

NOTE: On testnets such as Prater and Pyrmont, do not create more than 2 validators per node so that the activation queue is kept reasonably quick.

This tutorial assumes there are already 2 existing validators and adds 4 new ones.

Step 1: Backing up existing validator_keys

# Adjust your eth2deposit-cli directory accordingly
cd $HOME/eth2deposit-cli
# Renames and append the date to the existing validator_keys directory
mv validator_keys validator_keys_$(date +"%Y%d%m-%H%M%S")

Step 2: Generating new validator keys using the same mnemonic

Note: Use the same KEYSTORE password as before

# Generate from an existing mnemonic 4 more validators when 2 were previously already created
./deposit existing-mnemonic --validator_start_index 2 --num_validators 4 --chain pyrmont

Step 3: Uploading the deposit_data-#########.json file to the launchpad website

Upload the newly created deposit_data-#########.json files to the launchpad website as we did when creating the validator the first time in step 5 above.

Monitoring using Grafana and Prometheus

This section sets up monitoring assuming Grafana and Prometheus are already installed.

Step 1: Add the following jobs

NOTE: if Grafana and Prometheus are not set up on the same machine as the ETH 1 node, beacon chain node and ETH 2 validator node, localhost has to be changed to the respective IP of where they are set up.

- job_name: 'ETH 2 node_exporter'
static_configs:
- targets: ['localhost:9100']
- job_name: 'ETH 2 validator'
static_configs:
- targets: ['localhost:8081']
- job_name: 'ETH 2 beacon node'.
static_configs:
- targets: ['localhost:8080']
- job_name: 'ETH 1 node'
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /debug/metrics/prometheus
scheme: http
static_configs:
- targets: ['localhost:6060']

Step 2: Use the following templates for Grafana

Step 3: Enjoy the metrics!

ETH 2.0 metrics on Grafana

--

--