Eth2 staking on RaspberryPi 4 with Prysm
Ultimate beginner guide
EDIT: It’s been 5months and my raspberry4 (4gb ram) still validating with 100% effectiveness.
Prerequisites
- 16gb microSD card + reader
- Reliable internet connection
- Raspberry Pi 4 (4GB RAM option) with 3A charger (amazon link)
- Heatsink (with fans recommended)
- 100gb+ SSD (source)
Can either be USB3 SSD, or USB3 adapter for SSD/m2, or even a sandisk 3.1 thumbdrive in my case (amazon link).
*Make sure the usb case/adapter supports UASP
If you have slow sync problems/dmesg errors, your adapter might not be UASP compatible. Here’s a patch that might fix it but not guaranteed.
Step1 — Flash the OS
Download raspios64 image and flash the image into SD card with raspberrypi imager
Step2 — Enable SSH and wireless*
After flashing you should be able to access the boot partition on sd card.
Go to boot partition and create empty file named ssh
*If you’re connecting via ethernet instead of wireless you can skip the this:
Create a wpa_supplicant.conf
configuration file in the boot
partition with the following content:
# wpa_supplicant.confctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>network={
ssid="<Insert your Wifi network's name here>"
psk="<Insert your Wifi network's password here>"
}
Step3— SSH into raspberry
Plug the sd card, power on and use your command-line to:
ssh pi@raspberrypi
- You might need to replace raspberrypi with your raspberry IP address
- The default password is raspberry (use passwd to change it after login)
Step4— Make raspberry USB bootable*
*If you’ve done this step before on your raspberry you can skip it
Update your pi firmware by running:
sudo apt update
sudo apt full-upgrade
sudo rpi-update
After reboot (sudo reboot)
sudo rpi-eeprom-update -d -a
Reboot again
Launch raspi-config
sudo raspi-config
Boot Options ->Boot ROM Version-> Latest and press Enter.
Select No to use the latest boot ROM. This will trigger the Raspberry Pi to complete a series of behind the scenes configuration steps. Press Ok to close the next dialog.
Boot Options-> Boot Order->USB boot
Select No to use the latest boot ROM. This will trigger the Raspberry Pi to complete a series of behind the scenes configuration steps. Press Ok to close the next dialog.
Now your raspberry should be able to boot from USB.
Note that if there is a bootable micro SD card inserted, the Raspberry Pi will boot using that.
Step5 — Copy microSD contents to SSD
Make sure you connect your SSD the Pi’s USB 3 port (the blue port).
Use the following commands to copy the contents
git clone https://github.com/billw2/rpi-clone.git
cd rpi-clone
sudo cp rpi-clone rpi-clone-setup /usr/local/sbin
sudo rpi-clone-setup -t raspberrypi
sudo rpi-clone sda
Make sure destination disk is your SSD and proceed.
After the copy is complete, you can shutdown the raspberry to remove sd card.
sudo shutdown -h now
Now raspberry should boot without micro sd card.
Remove the microsd and just replug the power cable.
Step6— Increase swap size to 2GB
Note: Swap acts as a breather to your system when the RAM is exhausted. When the RAM is exhausted, your Linux system uses part of the hard disk memory and allocates it to the running application.
Use the Pi’s built-in text editor nano to open up the swap file:
sudo nano /etc/dphys-swapfile
Change the value assigned to CONF_SWAPSIZE
from 100
to 2048
:
...# set size to absolute value, leaving empty (default) then uses computed value
# you most likely don't want this, unless you have an special disk situation
CONF_SWAPSIZE=2048...
Save (Ctrl+S
) and exit (Ctrl+X
).
Reboot your Pi to have the above changes take effect:
sudo reboot
Step7 — Installing Prysm (The eth2 client/validator)
The easiest way to install Prysm is by running the prysm.sh
script.
SSH into raspberry and create prysm directory by running:
mkdir ~/prysm && cd ~/prysm
Then execute this command to download prysm.sh
script.
curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh && chmod +x prysm.sh
Step8 — Launching Prysm on testnet
You want to make sure your raspberrypi setup/ssd can handle the blockchain. So it’s a good idea to test everything on testnet first.
For this step you’ll need to pair the beacon node with a Web3 provider capable of serving Eth1 event logs. This could be a locally running Eth1 client such as Geth or a cloud service such as alchemyapi.io
Signup for alchemyapi.io and create Goerli — testnet app.
Goerli is the name of eth1 testnet
We will use screen to keep script running in the background.
sudo apt install screen
screen
And press Enter, Now If you lose your session you can always use screen -r to get it back
Replace — http-web3provider with your provider url and run the code below:
./prysm.sh beacon-chain --http-web3provider=https://eth-goerli.alchemyapi.io/v2/xxx --enable-upnp --datadir=$HOME/.eth2-testnet --pyrmont
Pyrmont is the name of eth2 testnet
The blockchain started syncing.
Now open another terminal, and you can keep this one running if you want. As mentioned before, if you lose your session you can always use screen -r to get it back.
Step 9: Obtain 32ETH and make the deposit
Download Ethereum deposit command-line tool on pi:
git clone -b master --single-branch https://github.com/ethereum/eth2.0-deposit-cli.git
cd eth2.0-deposit-cli/
Create an venv virtualenv under repository directory:
virtualenv venv
source venv/bin/activate
Install the dependency packages:
sudo python3 setup.py install
pip3 install -r requirements.txt
Type the following lines into the terminal window and go trough the process:
python3 ./eth2deposit/deposit.py new-mnemonic --chain pyrmont
Keep your seeds safe
Open a new terminal and download the keys to your local machine (You will need it for next step)
scp -r pi@raspberrypi:eth2.0-deposit-cli/validator_keys validator_keys
Remember the location where above files are saved.
I’ll be using chrome metamask extension for eth operations.
Switch your metamask chrome extention to goerli test network.
For the next step you will need 32eth, testnet has some free faucets.
You can ask a bot on discord https://discord.gg/3fAHvPD #request-goerli-eth channel.
After you get 32eth proceed with the Official Testnet Eth2 Launchpad step-by-step process to upload the deposit data and deposit your 32 ETH to become a validator. Select Geth for eth1 and Prysm for eth, and you can skip the deposit-cli process, since we’ve already done that.
Step 10: Import accounts and start the validator
~/prysm/prysm.sh validator accounts import --keys-dir=$HOME/eth2.0-deposit-cli/validator_keys --wallet-dir=$HOME/.testnetwallet
You will be asked to create a new wallet password, and another passwords to unlock the imported accounts.
After accounts imported you can start the validator:
It will ask you for your wallet password you just created.
screen
~/prysm/prysm.sh validator --wallet-dir=$HOME/.testnetwallet --pyrmont
Please note that it may take more than 14 hours for nodes in the ETH2 network to process a deposit and for the beacon chain to synchronize.
Once validator is activated by ETH2 network and eth2 chain is synced. The validator will be ready to start proposing blocks and signing votes.
To check on the status of your validator on pyrmont.beaconcha.in by the Etherscan team. You can find out your public keys by running
~/prysm/prysm.sh validator accounts list --wallet-dir=$HOME/.testnetwallet
- If you have a heatsink with a fan you can overclock your raspberry to 2ghz to speed up the blockchain sync process.
- How to tell if Prysm is running as expected (official Prysm manual)
- If upnp not supported forward ports 13000 and 12000 on your router, otherwise you might get low peer count
These 10 steps should be enough to start validating on the testnet.
Next part will focus on setting up autostart, grafana dashboards and switching to mainnet to start earning real eth.