Guide: How to stake on ETH2 Medalla Testnet with Teku on Ubuntu

Medalla is a multi-client ETH 2.0 testnet. It implements the Ethereum 2.0 Phase 0 protocol for a proof-of-stake blockchain, enabling anyone holding Goerli test ETH to join.

​PegaSys Teku (formerly known as Artemis) is a Java-based Ethereum 2.0 client designed & built to meet institutional needs and security requirements. PegaSys is an arm of ConsenSys dedicated to building enterprise-ready clients and tools for interacting with the core Ethereum platform. Teku is Apache 2 licensed and written in Java, a language notable for its materity & ubiquity.

​🏁 0. Prerequisites

​👩💻 Skills for operating a eth2 validator and beacon node

As a validator for eth2, you will typically have the following abilities:

  • operational knowledge of how to set up, run and maintain a eth2 beacon node and validator continuously

  • a commitment to maintain your validator 24/7/365

  • basic operating system skills

​🎗 Minimum Setup Requirements

  • Operating system: 64-bit Linux (i.e. Ubuntu 20.04 LTS)

  • Processor: Dual core CPU, Intel Core i5–760 or AMD FX-8100 or better

  • Memory: 4GB RAM

  • Storage: 20GB SSD

  • Internet: Broadband internet connection with speeds at least 1 Mbps.

  • Power: Reliable electrical power.

  • ETH balance: at least 32 Goerli ETH

  • Wallet: Metamask installed

  • Operating system: 64-bit Linux (i.e. Ubuntu 20.04 LTS)

  • Processor: Quad core CPU, Intel Core i7–4770 or AMD FX-8310 or better

  • Memory: 8GB RAM

  • Storage: 100GB SSD

  • Internet: Broadband internet connections with speeds at least 10 Mbps

  • Power: Reliable electrical power with uninterruptible power supply (UPS)

  • ETH balance: at least 32 Goerli ETH

  • Wallet: Metamask installed

If you need to install Ubuntu, refer to

If you need to install Metamask, refer to

​🤖 1. Install a ETH1 node

Ethereum 2.0 requires a connection to Ethereum 1.0 in order to monitor for 32 ETH validator deposits. Hosting your own Ethereum 1.0 node is the best way to maximize decentralization and minimize dependency on third parties such as Infura.

Your choice of either OpenEthereum, Geth, Besu or Nethermind.

OpenEthereum (Parity)
Geth
Besu
Nethermind
OpenEthereum (Parity)

🤖 Install and run OpenEthereum.

mkdir ~/openethereum && cd ~/openethereum
wget https://github.com/openethereum/openethereum/releases/download/v3.0.1/openethereum-linux-v3.0.1.zip
unzip openethereum*.zip
chmod +x openethereum
rm openethereum*.zip

​⛓ Start OpenEthereum on goerli chain.

./openethereum --chain goerli
Geth

​🧬 Install from the repository.

sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update -y
sudo apt-get install ethereum -y

​🐣 Start the geth node for ETH Goerli testnet.

geth --goerli --datadir="$HOME/Goerli" --rpc
Besu

​🧬 Install java dependency.

sudo apt install openjdk-11-jdk

​🌜 Download and unzip Besu.

cd
wget -O besu.tar.gz https://bintray.com/hyperledger-org/besu-repo/download_file?file_path=besu-1.5.0.tar.gz
tar -xvf besu.tar.gz
rm besu.tar.gz
cd besu-1.5.0/bin

​⛓ Run Besu on the goerli network.

./besu --network=goerli --data-path="$HOME/Goerli"
Nethermind

​⚙ Install dependencies.

sudo apt-get update && sudo apt-get install libsnappy-dev libc6-dev libc6 unzip -y

​🌜 Download and unzip Nethermind.

mkdir ~/nethermind && cd ~/nethermind
wget -O nethermind.zip https://nethdev.blob.core.windows.net/builds/nethermind-linux-amd64-1.8.77-9d3a58a.zip
unzip nethermind.zip
rm nethermind.zip

​🛸 Launch Nethermind.

./Nethermind.Launcher
  • Select Ethereum Node

  • Select Goerli select Fast sync

  • Yes to enable web3 / JSON RPC

  • Accept default IP

  • Skip ethstats registration

Syncing the node could take up to 1 hour.

Your eth1 node is fully sync'd when these events occur.

  • OpenEthereum: Imported #<block number>

  • Geth: Imported new chain segment

  • Besu: Imported #<block number>

  • Nethermind: No longer syncing Old Headers

​⚙ 2. Obtain Goerli test network ETH

Join the Prysmatic Labs Discord and send a request for ETH in the -request-goerli-eth channel

!send <your metamask goerli network ETH address>

Otherwise, visit the 🚰 Goerli Authenticated Faucet.

​👩💻3. Signup to be a validator at the Launchpad

  1. Install dependencies, the ethereum foundation deposit tool and generate keys.

sudo apt install python3-pip git -y
mkdir ~/git
cd ~/git
git clone https://github.com/ethereum/eth2.0-deposit-cli.git
cd eth2.0-deposit-cli
sudo ./deposit.sh install
./deposit.sh --chain medalla

2. Follow the prompts and pick a password. Write down your mnemonic and keep this safe, preferably offline.

3. Follow the steps at https://medalla.launchpad.ethereum.org/ but skip the steps you already just completed. Study the eth2 phase 0 overview material. Understanding eth2 is the key to success!

4. Back on the launchpad website, upload the deposit_data.json found in the validator_keys directory.

5. Connect your metamask wallet, review and accept terms.

6. Confirm the transaction.

Be sure to safely save your mnemonic seed offline.

​💡 4. Build Teku from source

Install tmux and git.

sudo apt-get install git tmux -y

Install Java 11.

Ubuntu 20.x
Ubuntu 18.x
Ubuntu 20.x
sudo apt update
sudo apt install openjdk-11-jdk
Ubuntu 18.x
sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt install oracle-java11-set-default

Install and build Teku.

cd ~/git
git clone https://github.com/PegaSysEng/teku.git
cd teku
./gradlew distTar installDist
cd build/install/teku

This build process may take a few minutes.

Verify Teku was installed properly by displaying the help menu.

cd $HOME/git/teku/build/install/teku/bin
./teku --help

​🔥 5. Configure port forwarding and/or firewall

Specific to your networking setup or cloud provider settings, ensure your beacon node's ports are open and reachable. Use https://canyouseeme.org/ to verify.

  • Teku beacon chain node will use port 9151 for tcp and udp

  • geth node will use port 30303 for tcp and udp

​🏂 6. Start the beacon chain and validator

If you participated in any of the prior test nets, you need to clear the database.

rm -rf $HOME/.local/share/teku/data

Store your validator's password in a file.

echo "my_password_goes_here" > $HOME/git/teku/password.txt

Update the --validators-key-files with the full path to your validator key. If you possess multiple validator keys then separate with commas. Use a config file if you have many validator keys,

./teku --network=medalla --eth1-endpoint=http://localhost:8545 \
--validators-key-files=$HOME/git/eth2.0-deposit-cli/validator_keys/<my keystore file.json i.e. keystore-m_12...324.json> \
--validators-key-password-files=$HOME/git/teku/password.txt \
--rest-api-enabled=true --rest-api-docs-enabled=true \
--metrics-enabled \
--validators-graffiti="poapboP...CHANGEME" \
--p2p-port=9151 \
--rest-api-port=5151

WARNING: DO NOT USE THE ORIGINAL KEYSTORES TO VALIDATE WITH ANOTHER CLIENT, OR YOU WILL GET SLASHED.

Allow the beacon chain to fully sync with eth1 chain.

This message means your node is synced:

Eth1 tracker successfully caught up to chain head"

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.

Congratulations. Once your beacon-chain is sync'd, validator up and running, you just wait for activation. This process takes up to 8 hours. When you're assigned, your validator will begin creating and voting on blocks while earning ETH staking rewards.

Use beaconcha.in and register an account to create alerts and track your validator's performance.

​🕒 7. Time Synchronization

Because beacon chain relies on accurate times to perform attestations and produce blocks, your computer's time must be accurate to real NTP or NTS time within 0.5 seconds.

Setup Chrony with the following guide.

chrony is an implementation of the Network Time Protocol and helps to keep your computer's time synchronized with NTP.

​🧩 8. Reference Material

🧙♂ 9. Updating Teku

cd ~/git/teku
git pull
./gradlew distTar installDist

Restart Teku as per normal operating procedures.