Running Ethereum full node on Raspberry pi4b

SΞBASTIAN
Coinmonks
6 min readFeb 13, 2023

--

Hello there! Previously it has been explained RPC and its usage. Now we will show how to run a full node so we don't have to rely on any RPC provider and at the same time preserve our privacy. This article will be for more technical people who like to deep dive into CLI. It will commence assuming you already had set up OS on your device, and is either operating headless or not.

Static vs Dynamic IP

Good practice to start with is making sure we have static IP on our Raspberry which will help us avoid any discrepancies later with connectivity and maintenance of our node. Static IP once set up will always remain assigned to your device. To do that we have to follow a few steps:
— log in to the device
— find the current IP address by typing hostname -I and save it.
— find the current router’s IP address by typing ip r | grep default and save it.

router address

— find the current DNS IP address by typing sudo cat /etc/resolve.conf and save the one after ‘nameserver’
now as we have all the necessary information we can modify it as needed by typing sudo nano /etc/dhcpcd.conf
we will see something like this:

interface <strong>NETWORK</strong>
static ip_address=<strong>
STATIC_IP</strong>/24
static routers=<strong>
ROUTER_IP</strong>
static domain_name_servers=<strong>
DNS_IP</strong>

What we do here is modify:
NETWORK — it is either wlan0 for wifi connection or eth0 for Ethernet connection (what is recommended!)
STATIC_IP — we choose here the static IP address we want to be assigned to raspberry all the time
ROUTER_IP — paste router IP discovered in previous steps
DNS_IP — paste router IP discovered in previous steps

To save this file press Ctrl+X, then Y, and at the end ENTER
At last, we reboot Raspberry by typing sudo reboot

Installing the node

Currently running Ethereum full node requires both an Execution Layer and a Consensus Layer clients working at the same time.
For that, we will use Geth implementation for EL, and Prysm implementation for CL. Please bear in mind having a full node also means we will synchronize all the block history. It is worth mentioning here two features of syncing the blockchain:

— — Blockchain sync mode [- -syncmode]:
*archive sync(standard syncing of entire blockchain, usually takes long time)
*full sync(it relies mainly on bandwidth usage instead of processing power and downloads all the transaction receipts and the entire recent state database, once it finish, it’s going back to processing power)
*light sync(downloads only block headers what doesn't allow to create a full node on that)

— — Blockchain garbage collection mode [- -gcmode]: It saves space on your memory drive by discarding unnecessary data.
- -gcmode full (save a lot of space by keeping only what is needed)
- -gcmode archive (disabling gcmode by keeping everything u download, not needed for us at all)

//For the purpose of this article, it’s going to be fast sync and gcmode full, and choosen network: Goerli-testnet//

  1. Let’s start with installing all the necessary updates.
    sudo apt update && sudo apt upgrade
    sudo apt-get install git sysstat -y
  2. It is recommended to install SWAP on our Raspberry. SWAP is a file creating temporary storage on our HDD/SSD and allowing us to use more RAM than we technically have by default, by taking RAM usage from idle programs to the ones that need now.
    type: sudo nano /etc/dphys-swapfile
    and modify this file for the following entries.
The first rectangle is a target location for our swap file on an HDD/SDD, change it accordingly dependable where is your drive located

restart SWAP file:
sudo /etc/init.d/dphys-swapfile restart

3. Geth has to be allowed to accept connections on port 30303 from outside to communicate with other peers. We can do that from our router in the Port forwarding/Port triggering tab

4. Installing GO in $HOME directory.

ver=”1.19.1"
cd $HOME
wget “
https://golang.org/dl/go$ver.linux-arm64.tar.gz"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf “go$ver.linux-arm64.tar.gz”
rm “go$ver.linux-arm64.tar.gz”

Changing owner and permissions:
sudo chown root:root /usr/local/go
sudo chmod 755 /usr/local/go

4. Set environment variable by typing:

and add the last line as above

or paste this command in your terminal:
echo “export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin” >> $HOME/.bash_profile
source $HOME/.bash_profile

save, exit, and reboot:
sudo reboot

5. Let’s create a directory called ethereum which contains two subfolders: execution and consensus

6. Get inside consensus and run those commands:

mkdir prysm && cd prysm
curl
https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh — output prysm.sh && chmod +x prysm.sh

What it does is download Prysm client and make it executable at the end.

7. Now it's time for Geth to connect with our consensus client. Let’s change the directory to execution. Then download and run Geth installer from https://geth.ethereum.org/downloads/
wget
https://gethstore.blob.core.windows.net/builds/geth-linux-arm7-1.10.26-e5eb32ac.tar.gz
tar -zxvf
eth-linux-arm7–1.10.26-e5eb32ac.tar.gz

Now to execute Geth we run this command:
geth — goerli — http — http.api eth,net,engine,adminls -

If we had problems with this step, we can use those commands to manually download Github repository and make Geth:
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum
make geth
build /bin/geth

To confirm our geth is working properly we use this command:
geth version

Geth version result
Geth is syncing

8. As Geth is syncing now, we can take care of Prysm now.
Download this file into consensus directory and start beacon node from this command:
./prysm.sh beacon-chain — execution-endpoint=$HOME/.ethereum/<your.ipc> — prater — genesis-state=genesis.ssz

|replace <your.ipc> with the geth.ipc|

Beacon node is syncing

After all, when both Prysm and Geth are fully synced, we have fully working Ethereum full node!!

Validator

To setup a validator, we have to create validator keys from Ethereum Staking Deposit CLI.
We have to download the latest stable release from here,
Afterward, we run the following commands to create a mnemonic phrase and keys:
./deposit new-mnemonic — num_validators=1 — mnemonic_language=english — chain=prater

Now follow the script and we will get a few things:

  • Mnemonic phrase
  • validator_keys directory containing deposit_data-*.json and keystore-m_*.json files

Now copy validator_keys into the consensus folder and run the following command, but replace <YOUR FOLDER PATH> with the full path to your consensus/validator_keys directory:

./prysm.sh validator accounts import — keys-dir=<YOUR_FOLDER_PATH> — prater

After a few prompts, you should see Success. Next, go to the Goerli-Prater Launchpad’s deposit data upload page and upload your deposit_data-*.json file. You’ll be prompted to connect your wallet.

If you need some testnet Goerli ETH for transactions, use https://goerlifaucet.com/.
If you want to have your 32ETH, head over https://discord.com/invite/prysmaticlabs

At the end to deposit your ETH, use the launchpad page and run the following command:
./prysm.sh validator — wallet-dir=<YOUR_FOLDER_PATH> — prater
Please remember to replace <YOUR_FOLDER_PATH> with the full path to your consensus folder.

After all, we have to wait, usually a long time(weeks or even months) until our validator is fully activated. To have a detailed idea about our validator status we can use https://docs.prylabs.network/docs/monitoring/checking-status.

!!!Please note this article has been made for a learning purpose and some parts might not work for you as I am doing it for the first time based on my previous research from various sources. Thank you!!!

New to trading? Try crypto trading bots or copy trading on best crypto exchanges

Join Coinmonks Telegram Channel and Youtube Channel get daily Crypto News

Also, Read

--

--