Running an Ethereum Client

If you have the time and resources, you should attempt to run a full node, even if only to learn more about the process. In this section we cover how to download, compile, and run the Ethereum clients Parity and Geth. This requires some familiarity with using the command-line interface on your operating system. It’s worth installing these clients, whether you choose to run them as full nodes, as testnet nodes, or as clients to a local private blockchain.

Hardware Requirements for a Full Node

Before we get started, you should ensure you have a computer with sufficient resources to run an Ethereum full node. You will need at least 300 GB of disk space to store a full copy of the Ethereum blockchain. If you also want to run a full node on the Ethereum testnet, you will need at least an additional 45 GB. Downloading 345 GB of blockchain data can take a long time, so it’s recommended that you work on a fast internet connection.

Syncing the Ethereum blockchain is very input/output (I/O) intensive. It is best to have a solid-state drive (SSD). If you have a mechanical hard disk drive (HDD), you will need at least 8 GB of RAM to use as cache. Otherwise, you may discover that your system is too slow to keep up and sync fully.

Minimum requirements:

  • CPU with 2+ cores

  • At least 300 GB free storage space

  • 4 GB RAM minimum with an SSD, 8 GB+ if you have an HDD

  • 8 MBit/sec download internet service

These are the minimum requirements to sync a full (but pruned) copy of an Ethereum-based blockchain.

At the time of writing the Parity codebase is lighter on resources, so if you’re running with limited hardware you’ll likely see better results using Parity.

If you want to sync in a reasonable amount of time and store all the development tools, libraries, clients, and blockchains we discuss in this book, you will want a more capable computer.

Recommended specifications:

  • Fast CPU with 4+ cores

  • 16 GB+ RAM

  • Fast SSD with at least 500 GB free space

  • 25+ MBit/sec download internet service

It’s difficult to predict how fast a blockchain’s size will increase and when more disk space will be required, so it’s recommended to check the blockchain’s latest size before you start syncing.

Note

The disk size requirements listed here assume you will be running a node with default settings, where the blockchain is “pruned” of old state data. If you instead run a full “archival” node, where all state is kept on disk, it will likely require more than 1 TB of disk space.

These links provide up-to-date estimates of the blockchain size:

Software Requirements for Building and Running a Client (Node)

This section covers Parity and Geth client software. It also assumes you are using a Unix-like command-line environment. The examples show the commands and output as they appear on an Ubuntu GNU/Linux operating system running the bash shell (command-line execution environment).

Typically every blockchain will have its own version of Geth, while Parity provides support for multiple Ethereum-based blockchains (Ethereum, Ethereum Classic, Ellaism, Expanse, Musicoin) with the same client download.

Tip

In many of the examples in this chapter, we will be using the operating system’s command-line interface (also known as a “shell”), accessed via a “terminal” application. The shell will display a prompt; you type a command, and the shell responds with some text and a new prompt for your next command. The prompt may look different on your system, but in the following examples, it is denoted by a $ symbol. In the examples, when you see text after a $ symbol, don’t type the $ symbol but type the command immediately following it (shown in bold), then press Enter to execute the command. In the examples, the lines below each command are the operating system’s responses to that command. When you see the next $ prefix, you’ll know it’s a new command and you should repeat the process.

Before we get started, you may need to install some software. If you’ve never done any software development on the computer you are currently using, you will probably need to install some basic tools. For the examples that follow, you will need to install git, the source-code management system; golang, the Go programming language and standard libraries; and Rust, a systems programming language.

Git can be installed by following the instructions at https://git-scm.com.

Go can be installed by following the instructions at https://golang.org, or https://github.com/golang/go/wiki/Ubuntu if you are using Ubuntu.

Note

Geth requirements vary, but if you stick with Go version 1.10 or greater you should be able to compile any version of Geth you want. Of course, you should always refer to the documentation for your chosen flavor of Geth.

The version of golang that is installed on your operating system or is available from your system’s package manager may be significantly older than 1.10. If so, remove it and install the latest version from https://golang.org/.

Rust can be installed by following the instructions at https://www.rustup.rs/.

Note

Parity requires Rust version 1.27 or greater.

Parity also requires some software libraries, such as OpenSSL and libudev. To install these on a Ubuntu or Debian GNU/Linux compatible system, use the following command:

  1. $ sudo apt-get install openssl libssl-dev libudev-dev cmake clang

For other operating systems, use the package manager of your OS or follow the Wiki instructions to install the required libraries.

Now that you have git, golang, Rust, and the necessary libraries installed, let’s get to work!

Parity

Parity is an implementation of a full-node Ethereum client and DApp browser. It was written “from the ground up” in Rust, a systems programming language, with the aim of building a modular, secure, and scalable Ethereum client. Parity is developed by Parity Tech, a UK company, and is released under the GPLv3 free software license.

Note

Disclosure: One of the authors of this book, Dr. Gavin Wood, is the founder of Parity Tech and wrote much of the Parity client. Parity represents about 25% of the installed Ethereum client base.

To install Parity, you can use the Rust package manager cargo or download the source code from GitHub. The package manager also downloads the source code, so there’s not much difference between the two options. In the next section, we will show you how to download and compile Parity yourself.

Installing Parity

The Parity Wiki offers instructions for building Parity in different environments and containers. We’ll show you how to build Parity from source. This assumes you have already installed Rust using rustup (see Software Requirements for Building and Running a Client (Node)).

First, get the source code from GitHub:

  1. $ git clone https://github.com/paritytech/parity

Then change to the parity directory and use cargo to build the executable:

  1. $ cd parity
  2. $ cargo install --path .

If all goes well, you should see something like:

  1. $ cargo install --path .
  2. Installing parity-ethereum v2.7.0 (/root/parity)
  3. Updating crates.io index
  4. Updating git repository `https://github.com/paritytech/rust-ctrlc.git`
  5. Updating git repository `https://github.com/paritytech/app-dirs-rs` Updating git repository
  6. [...]
  7. Compiling parity-ethereum v2.7.0 (/root/parity)
  8. Finished release [optimized] target(s) in 10m 16s
  9. Installing /root/.cargo/bin/parity
  10. Installed package `parity-ethereum v2.7.0 (/root/parity)` (executable `parity`)
  11. $

Try and run parity to see if it is installed, by invoking the —version option:

  1. $ parity --version
  2. Parity Ethereum Client.
  3. version Parity-Ethereum/v2.7.0-unstable-b69a33b3a-20200124/x86_64-unknown-linux-gnu/rustc1.40.0
  4. Copyright 2015-2020 Parity Technologies (UK) Ltd.
  5. License GPLv3+: GNU GPL version 3 or later .
  6. This is free software: you are free to change and redistribute it.
  7. There is NO WARRANTY, to the extent permitted by law.
  8. By Wood/Paronyan/Kotewicz/Drwięga/Volf/Greeff
  9. Habermeier/Czaban/Gotchac/Redman/Nikolsky
  10. Schoedon/Tang/Adolfsson/Silva/Palm/Hirsz et al.
  11. $

Great! Now that Parity is installed, you can sync the blockchain and get started with some basic command-line options.

Go-Ethereum (Geth)

Geth is the Go language implementation that is actively developed by the Ethereum Foundation, so is considered the “official” implementation of the Ethereum client. Typically, every Ethereum-based blockchain will have its own Geth implementation. If you’re running Geth, then you’ll want to make sure you grab the correct version for your blockchain using one of the following repository links:

Note

You can also skip these instructions and install a precompiled binary for your platform of choice. The precompiled releases are much easier to install and can be found in the “releases” section of any of the repositories listed here. However, you may learn more by downloading and compiling the software yourself.

Cloning the repository

The first step is to clone the Git repository, to get a copy of the source code.

To make a local clone of your chosen repository, use the git command as follows, in your home directory or under any directory you use for development:

  1. $ git clone <Repository Link>

You should see a progress report as the repository is copied to your local system:

  1. Cloning into 'go-ethereum'...
  2. remote: Enumerating objects: 86915, done.
  3. remote: Total 86915 (delta 0), reused 0 (delta 0), pack-reused 86915
  4. Receiving objects: 100% (86915/86915), 134.73 MiB | 29.30 MiB/s, done.
  5. Resolving deltas: 100% (57590/57590), done.

Great! Now that you have a local copy of Geth, you can compile an executable for your platform.

Building Geth from source code

To build Geth, change to the directory where the source code was downloaded and use the make command:

  1. $ cd go-ethereum
  2. $ make geth

If all goes well, you will see the Go compiler building each component until it produces the geth executable:

  1. build/env.sh go run build/ci.go install ./cmd/geth
  2. >>> /usr/local/go/bin/go install -ldflags -X main.gitCommit=58a1e13e6dd7f52a1d...
  3. github.com/ethereum/go-ethereum/common/hexutil
  4. github.com/ethereum/go-ethereum/common/math
  5. github.com/ethereum/go-ethereum/crypto/sha3
  6. github.com/ethereum/go-ethereum/rlp
  7. github.com/ethereum/go-ethereum/crypto/secp256k1
  8. github.com/ethereum/go-ethereum/common
  9. [...]
  10. github.com/ethereum/go-ethereum/cmd/utils
  11. github.com/ethereum/go-ethereum/cmd/geth
  12. Done building.
  13. Run "build/bin/geth" to launch geth.
  14. $

Let’s make sure geth works without actually starting it running:

  1. $ ./build/bin/geth version
  2. Geth
  3. Version: 1.9.11-unstable
  4. Git Commit: 0b284f6c6cfc6df452ca23f9454ee16a6330cb8e
  5. Git Commit Date: 20200123
  6. Architecture: amd64
  7. Protocol Versions: [64 63]
  8. Go Version: go1.13.4
  9. Operating System: linux
  10. [...]

Your geth version command may show slightly different information, but you should see a version report much like the one seen here.

The next sections explains the challenge with the initial synchronization of Ethereum’s blockchain.