Home

Awesome

Erigon-on-RPi-4

My personal guide to running an Erigon archive node (Ethereum) on an 8GB Raspberry Pi 4

<br /> <br />

Why?

<br /> <br />

WARNINGS

Erigon is still in beta, and may experience database corruption if the erigon process is stopped during initial sync (e.g. to reboot).

<br /> <br />

NOTES:

Raspberry Pi Selection

Network Setup

Drive Selection: Type

Drive Selection: Size

Drive Selection: Other

SSD Integration

Other Upgrades for Longevity

<br /> <br />

FILES INCLUDED:

Unless otherwise noted, files will be located on the Raspberry Pi.<br /> Intended local paths (within Ubuntu Server) are given in parenthesis after each filename.

<br /> <br /> <br />

STEPS TO INSTALL AND SYNC ERIGON:

  1. Download and extract the EthereumOnARM custom Ubuntu Server image for Raspberry Pi

  2. Use a program like Balena Etcher to write this image onto a MicroSD card with at least 16GB capacity

  3. Connect the SSD to the Raspberry Pi (via the USB3.0 interface, if using NASPi)

    1. NOTE: The SSD can be in any state, whether empty or formatted or full. The EthereumOnARM image will automatically reformat the disk as needed.
  4. Connect the Arduino Nano, if applicable, by the following steps

    1. Connect two wires (e.g. Dupont jumper wires) to the Arduino Nano (if applicable)
      1. By default, my provided software uses the Arduino's Digital 2 pin and any Ground
      2. Jumper wires can be M-F or F-F
        1. The Raspberry Pi GPIO must connect to a Female terminal
        2. The Arduino Nano GPIO can likely accept both Male and Female jumpers, but this may vary depending on the exact model and manufacturer
    2. Connect the Arduino Nano device to a computer and upload the nano_power_monitor.ino script
      1. A copy of nano_power_monitor.ino can be found this repository
    3. Disconnect the Arduino from the computer and reconnect it to a micro-USB power source
      1. 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.
    4. Connect each wire from the Arduino to its appropriate GPIO terminal on the RPi
      1. Digital 2 should connect to RPI GPIO 24 (unless you modify the code)
      2. Ground should connect an RPI GPIO Ground
  5. 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

    1. Also attach a keyboard, mouse, and/or monitor if applicable

      (Alternatively, you can interact through an SSH client from another computer)

  6. Connect the device to power (and press the power button, if using a NASPi product)

  7. 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

    1. When prompted to log in, wait 3 additional minutes for multiple lines of other text to complete
  8. Enter the username and password when prompted

    1. USERNAME: ethereum

      PASSWORD: ethereum

  9. Change the password when prompted

  10. Run the following commands for initial updates

    1. sudo apt-get update
    2. sudo apt-get upgrade
  11. Run the following commands if using the "NASPi" product and/or Arduino-based automated shutdown (if applicable)

    1. sudo apt-get install -y unzip make gcc python git wiringpi python3-pigpio python-setuptools
    2. sudo apt-get install -y python3-distutils
    3. wget https://github.com/joan2937/pigpio/archive/master.zip
    4. unzip master.zip
    5. cd pigpio-master
    6. sudo make
    7. sudo make install
    8. cd ~
    9. git clone https://github.com/geekworm-com/x-c1
    10. cd x-c1
    11. sudo chmod +x *.sh
    12. sudo bash install-ubuntu.sh
    13. echo "alias xoff='sudo /usr/local/bin/x-c1-softsd.sh'" >> ~/.bashrc
  12. Edit ~/x-c1/fan.py to change the temperature thresholds and/or fan speeds, if desired

    1. sudo nano fan.py
  13. Add the safe_shutdown.py file (if applicable)

    1. cd .. until root directory is reached
    2. cd home
    3. sudo mkdir arduino
    4. cd arduino
    5. Copy safe_shutdown.py to this folder
  14. Install supervisor and configure services for Erigon

    1. cd .. to root directory

    2. cd home

    3. sudo apt-get install supervisor

    4. cd .. to root directory

    5. cd etc

    6. sudo nano rc.local to edit the rc.local file for autorun on startup

      1. Replace the existing file contents with that of this repository
    7. cd supervisor/conf.d

    8. Create /etc/supervisor/erigon.conf and /etc/supervisor/rpcdaemon.conf, pasting in the contents from this repository

      1. sudo nano erigon.conf
      2. sudo nano rpcdaemon.conf
      <br />

    NOTE: If you are using the default erigon service instead of supervisor, the relevant configuration filepaths are /etc/ethereum/erigon.conf and /etc/ethereum/erigon-rpc.conf.

  15. Install Erigon

    1. sudo apt-get install erigon
  16. Stop and disable the geth service, which is enabled by default

    1. sudo systemctl stop geth
    2. sudo systemctl disable geth
  17. Ensure that the erigon process is disabled (to launch through supervisor instead)

    1. sudo systemctl disable erigon
    <br />

    NOTE: If you are using the default erigon process instead of supervisor, you should SKIP this step!

  18. Edit the file /etc/ethereum/erigon.conf to ensure Erigon is properly configured as an archive node without pruning

    1. cd .. to root directory
    2. cd etc/ethereum
    3. sudo nano erigon.conf
      1. Delete the --blockDownloaderWindow 32768 --prune=hrtc content

      2. 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"

  19. If the system time is incorrect, set your timezone and enable network-based clock synchronization

    1. sudo apt install systemd-timesyncd

    2. sudo timedatectl set-timezone America/New_York (or whatever timezone applies)

      1. If the above command fails, use

        sudo dpkg-reconfigure tzdata

        and select your timezone through the GUI

    3. sudo timedatectl set-ntp true

    4. Check the results of the clock sync with

      timedatectl

  20. Reboot one more time to begin the Erigon sync process (automatically upon startup)

    1. sudo reboot
<br /> <br />

STEPS TO MONITOR THE SYNC:

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.

  1. 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
  2. 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, and DISK WRITE columns to be especially useful for understanding SATA activity
    • Through the F4 (Filter) option, you can filter to display results containing the string "erigon"
  3. sudo watch -n 2 sensors
    • Outputs data from the Raspberry Pi temperature sensor, every 2 seconds
    • Requires sudo apt install lm-sensors first
  4. 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
<br /> <br />

STEPS TO BACK UP (AFTER SYNC COMPLETION):

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.

  1. sudo fdisk -l
    1. To list the disks available
  2. sudo mkdir /mnt/backup
    1. Create a new directory (within /mnt/) at which the backup disk will be mounted
  3. sudo mount /dev/sdb2 /mnt/backup
    1. To mount the chosen disk at /mnt/backup (replace /dev/sdb2 with your chosen disk)
  4. sudo cp -rv /home/ethereum /mnt/backup
    1. To copy (and print a line for each copied file) the entire contents of /home/ethereum into the newly mounted disk
<br /> <br />

STEPS TO RESTART SYNC:

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.

  1. sudo systemctl stop supervisor
    1. NOTE: Use sudo systemctl stop erigon instead if supervisor is not being used
  2. sudo rm -rf /home/ethereum/.erigon
  3. sudo reboot
    1. To resume Erigon without a reboot, use sudo systemctl start supervisor
<br /> <br />

ACKNOWLEDGEMENTS