Etherium 2.0 Single Machine Staking Guide

With the imminent launch of the Etherium 2.0 mainnet, I thought it would be good to do a quick write-up on how to quickly setup everything you need to become a validator on a single machine using Docker.

So assuming you already have Docker installed (I have it installed on a Ubuntu 18.10 host), you’ll need to run the following applications:

  • Eth 1.0 client node — We’ll use Geth.
  • Eth 2.0 beacon-chain node — We’ll use Prysm.
  • Eth 2.0 validator client — We’ll also use Prysm.

We’re going to run the containers with --restart=always to make sure that it automatically restarts the container after a host restart.

To run Geth in a Docker container:

docker run -d -p 30303:30303 -p 8545:8545 --restart=always \
-v ~/.ethereum:/root/.ethereum \
ethereum/client-go:stable \
--http --http.addr "0.0.0.0"

To run Prysm beacon-chain node in a Docker container:

docker run -d --restart=always -v ~/.eth2:/data -p 4000:4000 -p 13000:13000 -p 12000:12000/udp \gcr.io/prysmaticlabs/prysm/beacon-chain:stable \
--datadir=/data \
--rpc-host=0.0.0.0 \
--monitoring-host=0.0.0.0 \
--http-web3provider=http://$(hostname -I | awk '{print $1}'):8545 \
--accept-terms-of-use

Note: The $(hostname -I | awk '{print $1}') part of the command should return the IP address of the machine. This is needed for this container to talk to the Geth container.

In order to start the validator, you’ll need to generate a wallet and deposit the required 32 ETH.

Following the guide here: https://launchpad.ethereum.org/

cd ~/
wget https://github.com/ethereum/eth2.0-deposit-cli/releases/download/v1.1.0/eth2deposit-cli-ed5a6d3-linux-amd64.tar.gz
tar -xzf eth2deposit-cli-ed5a6d3-linux-amd64.tar.gz
cd eth2deposit-cli-ed5a6d3-linux-amd64/
./deposit new-mnemonic --num_validators 1 --chain mainnet

Generate and type in a secure password for the wallet. You’ll need this later.

Physically write down the mnemonic phrase. Manually retype to verify.

This will generate two json files in ~/eth2deposit-cli-ed5a6d3-cli-ed5a6d3-linux-amd64/validator_keys, a deposit_data-*.json and a keystore-*.json.

The launchpad guide will ask you to upload the deposit_data-*.jsonfile along with making the 32 ETH deposit. I used MetaMask to make my deposit.

Next, we need to import the wallet into a format that Prsym can use with the following command:

docker run -it -v ~/eth2deposit-cli-ed5a6d3-linux-amd64/validator_keys:/keys \
-v ~/Eth2Validators/prysm-wallet-v2:/wallet \
gcr.io/prysmaticlabs/prysm/validator:stable \
accounts import --keys-dir=/keys --wallet-dir=/wallet

This command will ask for the wallet password that you supplied earlier. It will ask for another password to secure the new wallet.

Create a text file with the new wallet password:

sudo vim ~/Eth2Validators/password.txt

Enter the new wallet password.

Finially run the validator client:

docker run -d --restart=always \
-v ~/Eth2Validators/prysm-wallet-v2:/wallet \
-v ~/Eth2Validators/password.txt:/password.txt \
-v ~/Eth2:/validatorDB \
gcr.io/prysmaticlabs/prysm/validator:stable \
--beacon-rpc-provider=$(hostname -I | awk '{print $1}'):4000 \
--wallet-dir=/wallet \
--wallet-password-file=/password.txt \
--datadir=/validatorDB \
--accept-terms-of-use

Some useful Docker commands:

# list all the containers
docker ps
# follow the logs of one of the containers
docker logs -f <container id/name>

Software engineer in the Boston area