How to Run an Ethereum Node on a Raspberry Pi

How to Run an Ethereum Node on a Raspberry Pi

Blockchains rely on their community to run nodes and provide security for the network. The larger the network in terms of participating peers, the harder it becomes for adversaries to take over the network or manipulate transaction history. Therefore, running your own Ethereum node is beneficial to the network. It is also a great way to familiarize yourself with the Ethereum ecosystem and to remove third-party dependencies for blockchain access. However, running a node is also very resource expensive. It usually requires a dedicated computer to be connected around the clock. However, an Ethereum node can alternatively be ran using a Raspberry Pi

The latest model, Raspberry Pi 4, is just about powerful enough to run a full Ethereum node. In this article, we explain the steps necessary to run an Ethereum node on a Raspberry Pi and to sync to the main network. We will use the Go Ethereum client for this guide, but Parity Ethereum can also be used on a Raspberry Pi. Some basic knowledge of the Linux command line and operating system configuration is required. 

Raspberry Pi

Requirements

In addition to a Raspberry Pi 4 with a compatible power supply, we require an SD card to hold the operating system. Furthermore, in order to run an Ethereum full node, we also require a sufficiently large external solid-state hard drive. Disk IO speed is the most important performance requirement for running a full Ethereum node. The reason for this is the high frequency of writing data to disk in small chunks during transaction processing. It is therefore important to use a very fast external USB 3.0 drive without any moving parts. 500 GB should be enough to run a full Ethereum node, as this currently takes up less than 300 GB of space, but some growth should be expected.

Running an archive node on a Raspberry Pi is not practical since this would take up more than 2 TB of disk space, which would negate the cost advantage of a Raspberry Pi. Furthermore, the space requirements for archive nodes increases much faster than for regular full nodes. Fortunately, for most uses, archive nodes are not a necessity. 

In addition, some form of cooling for the Raspberry Pi is probably a good idea, in order to avoid overheating. Simple heatsinks and fans should suffice and are cheaply available. 

Preparing the Raspberry Pi

A clean Linux installation on the Rasberry Pi’s SD card is required before we can install any Ethereum-specific software. We recommend Rasbian, but a number of Linux distributions exist for Raspberry Pis. Installing the operating system is beyond the scope of this article, but simple instructions can be found in the official installation guide

In order to be able to compile the Go version of Ethereum, we need a workable Go language environment. This can be installed by running the following commands:

$ wget https://dl.google.com/go/go1.13.1.linux-armv6l.tar.gz

$ sudo tar -C /usr/local -xvf go1.13.1.linux-armv6l.tar.gz

Of course, we need to add the resulting /usr/local/go/bin directory to our PATH variable, before it can be used.

Installing Ethereum  

Once the Raspberry Pi is up and running we can install Geth on the system. There are some pre-compiled images for Raspberry Pis available on a number of sites on the web. However, these tend to get behind the latest releases in terms of version numbers very quickly. Therefore, it is best to build a version from the latest source code, which is exactly why we needed to install a Go language environment. 

To do so, we need to clone the Geth GitHub repository with the following command:

$ git clone https://github.com/ethereum/go-ethereum.git

This will install the latest unstable version but in order to be sure to install a stable release, we can add the following parameter to specify a specific version number:

–branch v<version> 

Now we can enter the newly-created directory and build Geth executing:

$ make geth

This should take a bit longer than on a desktop machine, but once completed we have a fully operational Ethereum node for ARM processors. 

Running an Ethereum Light Node 

The easiest and least resource hungry way of connecting to the Ethereum network is running a light node. A light node does not sync to the latest blockchain state, does not store the blockchain locally, and does not validate transactions itself. Instead, a  light node relies on more powerful peers to process transactions on its behalf.

If a light node is all we require, SD card storage is sufficient and we do not have to worry about connecting an external hard drive.

Simply type the following command to start the node:

$ geth –cache=218 –syncmode “light”

The “cache” parameter ensures the node does not consume too much memory. 

Running an Ethereum Full Node

If the goal is to run a full node that maintains the latest blockchain state locally, we need to connect the above mentioned external hard drive. As already mentioned, it is essential to choose a very fast solid-state drive connected via USB 3.0, in order to keep up with the blockchain.

We need to create a partition on the external drive, which is beyond the scope of this guide, as it refers to basic Linux administration skills. 

Once we have sufficient fast storage we can start Geth, making sure that the blockchain state is stored on the newly created partition:

$ geth –syncmode fast –cache 256 –datadir <storage path>

The datadir parameter is used to indicate where the storage is mounted.

Syncing to the blockchain’s latest state can take a long time, even using fast sync mode, but once completed, the node is ready to be used.

Connecting to the Node

Our newly launched node can be used from the Raspberry Pi’s command line in the usual way. More details on how to do this can be found in our article on installing and using Geth and in the official documentation. In order to use the Raspberry Pi as a permanent Ethereum gateway in the local network, some additional steps may be required, such as forwarding certain ports and making sure Geth runs as a daemon. Again, these basic network administration skills are beyond the scope of this article. Users should acquire these skills before experimenting with live digital assets, as misconfigurations can have serious security implications.