- Blockchain node software is something that I want to learn more about
- An Ethereum archive node contains immense volumes of data to explore and analyze
- I'm impressed that such a system can sync and run indefinitely on less than 20 watts of electricity
- It seems like a cool idea
Erigon is still in beta, and may experience database corruption if the erigon
process is stopped during initial sync (e.g. to reboot).
- Prior to completion of the initial sync, users should plan to run their computer 24/7 in order to avoid this issue.
- Once the first sync has completed, the
erigon
process can be safely stopped and restarted without loss of data.
- I highly recommend using the 8GB version of the RPi Model 4.
- The EthereumOnARM team have built and tested their custom Ubuntu Server image specifically for the version with 8 GB RAM.
- Erigon already recommends a minimum of 16 GB RAM, more than that of the highest-tier RPi. So restricting RAM any further below 8 GB is not advised.
- You must have an internet connection with the ability to port-forward
- Port 30303 (on the IP address assigned to the Raspberry Pi) must be open to external traffic, both TCP and UDP, before the
erigon
process launches (on reboot) - If your router supports it, I find it helpful to assign a static IP address to the RPi
- Port 30303 (on the IP address assigned to the Raspberry Pi) must be open to external traffic, both TCP and UDP, before the
- The EthereumOnARM installer image is designed for wired networking.
- You may be able to complete the steps below using the Raspberry Pi's onboard WiFi, but this will require additional configuration to ensure internet connectivity upon boot.
- An SSD (Solid State Drive) is an absolute necessity, as HDDs (Hard Disk Drives) do not support the read/write speeds necessary for archive node sync.
- a SATA III SSD is more than fast enough to sync. More modern interfaces such as NVMe are unlikely to offer much of a performance improvement relative to their additional cost.
- As of writing, an Erigon archive node (without pruning) can still just barely be run on a 2TB drive.
- 4 TB is a more realistic minimum, as a 2 TB drive will soon be too small to store an entire Erigon archive node data.
- 8 TB is likely overkill, but could be useful in applications where additional storage space is desired.
- When comparing SSD options, pay attention to the "TBW" (Total Bytes Written) value associated with the warranty of each SSD.
- Solid State Drives are typically sold under a warranty for a given amount of time, but this warranty coverage will end early if the TBW value is exceeded.
- The SSD of an archive node will endure a significantly higher TBW per year of runtime, relative to other common SSD applications.
- Similarly-priced drives can have widely varying TBW limits!
- I used the NASPi, a NUC-style NAS server solution for SATA III drives.
- It is perfectly acceptable to use other alternative products.
- The goal is to facilitate safe integration of a SSD into the Raspberry Pi 4 system.
- The NASPi is sold by Geekworm at this URL, and is also available through other vendors.
- My specific model uses the X823 V1.5 and X-C1 V1.3 boards.
- Power Surge and Outage Protection
- At the very least, I recommend using a surge protector.
- A UPS (uninterruptable power supply) can protect from power surges and also maintain liveness during a power outage, preventing problems like data corruption and hardware failure.
- $50 can purchase a UPS with maximum output of 200W or more (far above the power needed for this project).
- $10 can purchase an Arduino Nano clone board to facilitate sending simple signals to the RPi GPIO, in this case a signal which turns off during a power outage.
- The Raspberry Pi can then detect this (lack of a) signal within Ubuntu Server, sending whatever commands are necessary to gracefully stop Erigon-related services and shut down the computer.
- Though it's not necessary for the underlying archive node functionality, I think that blackout protection and automatic shutdown (to conserve backup battery power) are worth the investment in this case.
- Heatsinks and Temperature Management
- I highly recommend some form of active cooling. Without a fan, the system can quickly reach internal temperatures of 90 degrees Celsius or above. Sustained periods of high temperature will reduce hardware lifetimes.
- If using the NASPi device, a fan is included but heatsinks are not.
- Any heatsink with thickness of 5 mm or below will fit under the NASPi fan bracket.
- I personally used the 4-pack of copper heatsinks (designed specifically for the Raspberry Pi 4) from this larger heatsink kit.
- With a 40mm fan but no heatsinks, my node ran at temperatures between 55 and 70 degrees Celsius during sync.
- After adding the heatsinks, I have seen a temperature reduction of approximately 7 degrees Celsius on average.
Unless otherwise noted, files will be located on the Raspberry Pi.
Intended local paths (within Ubuntu Server) are given in parenthesis after each filename.
-
Related to Erigon
- erigon.conf (
/etc/supervisor/conf.d/erigon.conf
) - rpcdaemon.conf (
/etc/supervisor/conf.d/rpcdaemon.conf
)
These two files are based on the work of Chase Wright (see Acknowledgements section).
- erigon.conf (
- Related to power monitoring with Arduino Nano
- nano_power_monitor.ino (N/A)
- Arduino script for upload to Nano device
- safe_shutdown.py (
/home/arduino/safe_shutdown.py
)- Python script which monitors GPIO for (lack of) signal from Arduino Nano
- Run manually with the following command (NOTE: normally not needed, as this is managed by
rc.local
)sudo python /home/arduino/safe_shutdown.py
- rc.local (
/etc/rc.local
)- Modified for automatic launch of
safe_shutdown.py
upon startup
- Modified for automatic launch of
- nano_power_monitor.ino (N/A)
-
Download and extract the EthereumOnARM custom Ubuntu Server image for Raspberry Pi
- Option 1: Direct Link to v21.03.00
- Option 2: Find the link in the "Downloads" section of the EthereumOnARM Quick Guide
-
Use a program like Balena Etcher to write this image onto a MicroSD card with at least 16GB capacity
-
Connect the SSD to the Raspberry Pi (via the USB3.0 interface, if using NASPi)
- NOTE: The SSD can be in any state, whether empty or formatted or full. The EthereumOnARM image will automatically reformat the disk as needed.
-
Connect the Arduino Nano, if applicable, by the following steps
- Connect two wires (e.g. Dupont jumper wires) to the Arduino Nano (if applicable)
- By default, my provided software uses the Arduino's Digital 2 pin and any Ground
- Jumper wires can be M-F or F-F
- The Raspberry Pi GPIO must connect to a Female terminal
- The Arduino Nano GPIO can likely accept both Male and Female jumpers, but this may vary depending on the exact model and manufacturer
- Connect the Arduino Nano device to a computer and upload the
nano_power_monitor.ino
script- A copy of
nano_power_monitor.ino
can be found this repository
- A copy of
- Disconnect the Arduino from the computer and reconnect it to a micro-USB power source
- This power source should NOT be connected to the UPS battery backup (if applicable) because the Arduino is supposed to lose all signal during a power outage.
- Connect each wire from the Arduino to its appropriate GPIO terminal on the RPi
- Digital 2 should connect to RPI GPIO 24 (unless you modify the code)
- Ground should connect an RPI GPIO Ground
- Connect two wires (e.g. Dupont jumper wires) to the Arduino Nano (if applicable)
-
Before connecting power to the device, connect the RPi to a router (or other appropriate device, such as a network switch) via the Ethernet port
-
Also attach a keyboard, mouse, and/or monitor if applicable
(Alternatively, you can interact through an SSH client from another computer)
-
-
Connect the device to power (and press the power button, if using a NASPi product)
-
Wait for the device to proceed through an automated setup process, including formatting the SSD, until it restarts and eventually prompts you with a login screen
- When prompted to log in, wait 3 additional minutes for multiple lines of other text to complete
-
Enter the username and password when prompted
-
USERNAME: ethereum
PASSWORD: ethereum
-
-
Change the password when prompted
-
Run the following commands for initial updates
sudo apt-get update
sudo apt-get upgrade
-
Run the following commands if using the "NASPi" product and/or Arduino-based automated shutdown (if applicable)
sudo apt-get install -y unzip make gcc python git wiringpi python3-pigpio python-setuptools
sudo apt-get install -y python3-distutils
wget https://github.com/joan2937/pigpio/archive/master.zip
unzip master.zip
cd pigpio-master
sudo make
sudo make install
cd ~
git clone https://github.com/geekworm-com/x-c1
cd x-c1
sudo chmod +x *.sh
sudo bash install-ubuntu.sh
echo "alias xoff='sudo /usr/local/bin/x-c1-softsd.sh'" >> ~/.bashrc
-
Edit
~/x-c1/fan.py
to change the temperature thresholds and/or fan speeds, if desiredsudo nano fan.py
-
Add the
safe_shutdown.py
file (if applicable)cd ..
until root directory is reachedcd home
sudo mkdir arduino
cd arduino
- Copy
safe_shutdown.py
to this folder
-
Install
supervisor
and configure services for Erigon-
cd ..
to root directory -
cd home
-
sudo apt-get install supervisor
-
cd ..
to root directory -
cd etc
-
sudo nano rc.local
to edit therc.local
file for autorun on startup- Replace the existing file contents with that of this repository
-
cd supervisor/conf.d
-
Create
/etc/supervisor/erigon.conf
and/etc/supervisor/rpcdaemon.conf
, pasting in the contents from this repositorysudo nano erigon.conf
sudo nano rpcdaemon.conf
NOTE: If you are using the default
erigon
service instead ofsupervisor
, the relevant configuration filepaths are/etc/ethereum/erigon.conf
and/etc/ethereum/erigon-rpc.conf
. -
-
Install Erigon
sudo apt-get install erigon
-
Stop and disable the
geth
service, which is enabled by defaultsudo systemctl stop geth
sudo systemctl disable geth
-
Ensure that the
erigon
process is disabled (to launch throughsupervisor
instead)sudo systemctl disable erigon
NOTE: If you are using the default
erigon
process instead ofsupervisor
, you should SKIP this step! -
Edit the file
/etc/ethereum/erigon.conf
to ensure Erigon is properly configured as an archive node without pruningcd ..
to root directorycd etc/ethereum
sudo nano erigon.conf
-
Delete the
--blockDownloaderWindow 32768 --prune=hrtc
content -
Full file should be a single line containing the following content only:
ARGS="--datadir /home/ethereum/.erigon --private.api.addr 127.0.0.1:8090"
-
-
If the system time is incorrect, set your timezone and enable network-based clock synchronization
-
sudo apt install systemd-timesyncd
-
sudo timedatectl set-timezone America/New_York
(or whatever timezone applies)-
If the above command fails, use
sudo dpkg-reconfigure tzdata
and select your timezone through the GUI
-
-
sudo timedatectl set-ntp true
-
Check the results of the clock sync with
timedatectl
-
-
Reboot one more time to begin the Erigon sync process (automatically upon startup)
sudo reboot
There are a variety of ways to monitor the Erigon sync process. I personally tend to keep multiple simultaneous SSH connections open, with different commands running in each terminal. The commands are explained below.
sudo tail -f /home/erigon.err.log
- Displays the most recent contents (and live updates) to the Erigon error logfile
- This will include warnings and errors, but also details about the current sync progress and actions
htop
- By default allows monitoring of CPU and memory usage, on both a total and per-process basis
- Through the F2 (Setup) option, you can add additional metrics for display
- I find the
DISK R/W
,DISK READ
, andDISK WRITE
columns to be especially useful for understanding SATA activity
- I find the
- Through the F4 (Filter) option, you can filter to display results containing the string "erigon"
sudo watch -n 2 sensors
- Outputs data from the Raspberry Pi temperature sensor, every 2 seconds
- Requires
sudo apt install lm-sensors
first
slurm -i eth0
- Given the name of a network interface, continuously displays data of download and upload rates. Includes a (terminal-based) graph of the instantaneous rates over time.
- Requires
sudo apt install slurm
first
When the initial sync has completed, I recommend backing up the Erigon chain data (and other related files).
If the live node state becomes corrupted in the future (or if you want to run an additional node) it is possible to restore from this backup, instead of waiting for the initial sync process to complete again.
sudo fdisk -l
- To list the disks available
sudo mkdir /mnt/backup
- Create a new directory (within
/mnt/
) at which the backup disk will be mounted
- Create a new directory (within
sudo mount /dev/sdb2 /mnt/backup
- To mount the chosen disk at
/mnt/backup
(replace/dev/sdb2
with your chosen disk)
- To mount the chosen disk at
sudo cp -rv /home/ethereum /mnt/backup
- To copy (and print a line for each copied file) the entire contents of
/home/ethereum
into the newly mounted disk
- To copy (and print a line for each copied file) the entire contents of
In the case of data corruption or other problems, you can run the following commands to stop Erigon and delete the existing data directory, then reboot to restart the sync from the beginning.
sudo systemctl stop supervisor
- NOTE: Use
sudo systemctl stop erigon
instead ifsupervisor
is not being used
- NOTE: Use
sudo rm -rf /home/ethereum/.erigon
sudo reboot
- To resume Erigon without a reboot, use
sudo systemctl start supervisor
- To resume Erigon without a reboot, use
- The Ethereum on ARM community for all of their research in creating the ARM64 image and for their documentation, especially the guide to managing Ethereum clients
- Chase Wright (@mysticryuujin) for his "Getting Started with Erigon on Ubuntu" blogpost