Installing and Running an Ethereum 2 PegaSys Teku Validator on the Altona Testnet

Dr Steve Berryman
Chain started: Altona 29th June 2020
Last tested and updated: 3rd July 2020
Node: ConsenSys PegaSys Teku
Source code hash: af4dfd4c36149444426a350642de0f3ebf6c8dee
Ubuntu: 18.04.3 ubuntu-18.04.3-desktop-amd64.iso
Technical Skills: A basic understanding of Linux
Audience: Developers looking for a quick step-by-step guide to install and run a Teku validator node without leaving this document.

Introduction
The purpose of this document is to provide a go to guide for installing a Beacon Node and running a Validator on the Teku Ethereum 2 Altona multi-client testnet. It’s intended to be the minimum set of steps to get a node and validator up and running and if more details are required, then please refer to the PegaSys Teku documentation. These instructions are for building from source and not using docker.
These steps are for installing the testnet node from source on a fresh Ubuntu 18.4 and are likely to work on different code versions but we only tested it on the source code hash above. Attestant is constantly building nodes and updating this document, if you have any issues please let us know. These instructions were used for building a node on the date specified above on the testnet Altona beacon chain, which was launched on the 29th June 2020. The instructions below also show you how to obtain the source code hash for the current version of the software you have downloaded.
Attestant tested the install on 8th-generation 1.80 GHz Kaby Lake Intel Core i5–8250U/i7–8550U processor with 64GB and 1TB SSD. Approximate times are given, where appropriate and the full install took around 1 hour (most of that time is synching the ETH1 testnet). You need at least 16GB of memory but we recommend at least 32GB.
Note: Each new command line starts with a $ and each line needs to be run separately with a return. The $ is command prompt and should not be copied.
Install Java 11
The first step is to install the Java 11 virtual machine and some useful tools required by this guide.
$ sudo apt install git screen -y
$ sudo add-apt-repository ppa:linuxuprising/java
$ sudo apt install openjdk-11-jre-headless
Install and Build PegaSys Teku
Clone the git repository and compile the code.
$ git clone https://github.com/PegaSysEng/teku.git
$ cd teku && ./gradlew distTar installDist
The source code hash for the installation covered in this guide is given at the top of the document. You should compare your version using:
$ git rev-parse HEAD
Remember that this repo is under development so expect the code, and hash, to change frequently.
The next step is to add the Teku binaries to your $PATH variable so it can be run from anywhere. This can be appended to your .bashrc file so it’s automatically added to you path when you log in. By running “source .bashrc” saves you logging out and back in again for the current session.
$ cd
$ echo “export PATH=$PATH:$HOME/teku/build/install/teku/bin” >> .bashrc
$ source .bashrc
Installing Geth — Ethereum 1 Node
Ethereum 2 requires you to interact with the Altona deposit contract on the Ethereum 1 Goerli testnet. So the next step is to install and run a geth Ethereum 1 node.
Install Geth
$ sudo add-apt-repository -y ppa:ethereum/ethereum
$ sudo apt-get install ethereum -y
Run Goerli testnet
Run geth, unattached to the terminal process, by using the tool “screen” which was installed in the first step.
$ screen -S EthTestnet
$ geth --goerli --rpc &>> $HOME/goerli.log
$ Cntl+a d
It will take around 40 minutes for the testnet to sync so that the beacon node and validator can determine the ETH1 deposit has been made.
Create a Ethereum 2 Withdrawal and Validator Key
Ethereum 2 validators require a withdrawal key (kept private) and a signing key (for attestations). The command below command below will generate encrypted withdrawal and validation keys in the current directory and then send 32 Goreli ETH to the deposit contract, all in one go. You will be prompted for withdrawal and validation password and then asked to confirm the 32 ETH transaction on the Ethereum 1 testnet. It will take at least 8 hours for it to show up on Ethereum 2 but you can view the ETH1 deposit transaction using the Goreli block explorer https://goerli.etherscan.io and the status of the Ethereum 2 validator on the Altona block explorer https://altona.beaconcha.in.
If you require Goerli Testnet ETH1 to fund your deposit contract, you can receive some by sending your test address to the Discord channel -request-goerli-eth https://discord.gg/u5j8S2.
$ teku validator generate-and-register \
--network=altona \
--eth1-endpoint=http://localhost:8545 \
--eth1-private-key <xxxxxxx>
For simplicity we are using the Ethereum 1 private key directly, as a command line parameter, in order to deposit the 32 ETH but this approach shouldn’t be used on the mainnet. You can use a geth key wallet format by using the following teku command line parameters:
--eth1-keystore-file=walletKey \
--eth1-keystore-password-file=password.txt
Running the Beacon Chain and Validator
The Beacon Chain and validator can be launched with a single command and, as with geth, you will want to run it unattached to the terminal. Currently it takes less than 5 minutes to sync the Beacon Chain.
$ screen -S TekuValidator
$ teku --network=altona --eth1-endpoint=http://localhost:8545 \
--validators-key-files=validator_key/key1_validator.json, validator_key/key2_validator.json \
--validators-key-password-files=passKey1.txt, passKey2.txt \
--rest-api-enabled=true --rest-api-docs-enabled=true \
--metrics-enabled
$ Cntl+a d
If you just want to run a Beacon Chain, without any validators, then run the following:
$ teku --network=altona --metrics-enabled --rest-api-enabled --rest-api-docs-enabled
Now just sit back and monitor your Ethereum 2 validator key using the block explorer https://altona.beaconcha.in.
Useful Links
Attestant Ethereum Staking Posts
Ethereum 2 Staking Keys
Etherscan for the current beacon chain testnet
Installing and running an Ethereum 2 Prysm Validator
Ethereum 2 Node Monitoring Tool
Contact
If you wish to know more about Attestant, you can contact the team on Telegram https://t.me/attestant