- Published on
Run reth on Ubuntu 20.04
- Authors
- Name
- merkle
- @merkle_mev
At merkle, we have experience running reth in production. This tutorial will help you start a reth node (with consensus client lighthouse) on a Ubuntu 20.04 server. Reth, built by Paradigm, it is a Rust implementation of the Ethereum 2.0 Execution Layer. For more in-depth information about Reth, follow the excellent reth book.
This tutorial uses systemd
and builds from source to squeeze out as much performance as possible. If you want to run reth and lighthouse with docker instead (easier), follow this reth book tutorial.
- Pre-requisites
- Building lighthouse
- Building reth
- Running reth and lighthouse
- (Optional) Turning reth and lighthouse into systemd services
- Reth
- Lighthouse
- Starting the services
- Enabling auto-start
- (Optional) Monitoring with Telegraf
Pre-requisites
Before starting reth, a consensus client must be running on the machine.
First, make sure you have Rust installed with:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Then, install the pre-requisites for building reth and lighthouse from source:
sudo apt install -y git gcc g++ make cmake pkg-config llvm-dev libclang-dev clang
Building lighthouse
Building lighthouse from source is the best way to go, as it creates a highly optimized binary for your machine. To get started, let's clone the lighthouse repository:
git clone https://github.com/sigp/lighthouse.git
Make you sure are on the latest stable branch:
cd lighthouse && git checkout stable
Now, build the lighthouse binary with MAXPERF
settings:
PROFILE=maxperf make
Building will take a few minutes.
Building reth
Now, let's clone the reth repository:
git clone https://github.com/paradigmxyz/reth
Reth is still in development, the latest stable version is v1.0.0
. Make sure you are on the latest release:
cd reth && git checkout v1.0.0
Now, build the reth binary:
RUSTFLAGS="-C target-cpu=native" cargo build --profile maxperf
This will take a while (~10-20 minutes).
Running reth and lighthouse
In order to enable secure communication between lighthouse and reth, we need to generate a shared secret. This can be done with the following command:
sudo mkdir /secrets && openssl rand -hex 32 | tr -d "\n" | sudo tee /secrets/jwt.hex
Now, we can start lighthouse:
./target/maxperf/lighthouse bn \
--network mainnet \
--execution-endpoint http://localhost:8551 \
--execution-jwt /secrets/jwt.hex \
--checkpoint-sync-url https://mainnet.checkpoint.sigp.io \
--disable-deposit-contract-sync
Don't pay attention to the Error during execution engine upcheck
errors, they are expected and will resolve themselves once reth is running.
Now start reth:
./target/maxperf/reth node \
--authrpc.jwtsecret /secrets/jwt.hex \
--authrpc.addr 127.0.0.1 \
--authrpc.port 8551 \
--http \
--ws \
--rpc-max-connections 429496729 \
--http.api trace,web3,eth,debug \
--ws.api trace,web3,eth,debug
# optionally, add the following flags to serve traffic publicly: --http.addr 0.0.0.0 and --ws.addr 0.0.0.0 (NOT RECOMMENDED, but useful for testing)
It should take a few days for reth to sync the chain.
(Optional) Turning reth and lighthouse into systemd services
First, let's copy the binary into /usr/local/bin
:
sudo cp ./target/maxperf/reth /usr/local/bin/reth
sudo cp ./target/maxperf/lighthouse /usr/local/bin/lighthouse
If you want to run reth and lighthouse as systemd services, you can use the following unit files:
Reth
Create a file named /etc/systemd/system/reth.service
:
[Unit]
Description=RETH
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/usr/local/bin/reth node --metrics 0.0.0.0:9002 --authrpc.jwtsecret /secrets/jwt.hex --authrpc.addr 127.0.0.1 --authrpc.port 8551 --http --ws --rpc-max-connections 429496729 --http.api trace,web3,eth,debug --ws.api trace,web3,eth,debug
[Install]
WantedBy=multi-user.target
Lighthouse
Create a file named /etc/systemd/system/lighthouse.service
:
[Unit]
Description=Lighthouse
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/usr/local/bin/lighthouse bn --network mainnet --metrics --execution-endpoint http://localhost:8551 --execution-jwt /secrets/jwt.hex --checkpoint-sync-url https://mainnet.checkpoint.sigp.io --disable-deposit-contract-sync
[Install]
WantedBy=multi-user.target
Starting the services
Now, you can start the services with:
sudo systemctl start reth
sudo systemctl start lighthouse
To make sure the services are running, you can run:
sudo systemctl status reth
sudo systemctl status lighthouse
To check the logs of the running services you can use journalctl
with:
sudo journalctl -u reth -f # -n 1000 to see more logs
sudo journalctl -u lighthouse -f # -n 1000 to see more logs
Enabling auto-start
In case your node goes down and reboots, you can enable auto-start with:
sudo systemctl enable reth
sudo systemctl enable lighthouse
This will make sure both reth and lighthouse restart on boot.
(Optional) Monitoring with Telegraf
At merkle, we utilize a central monitoring infrastructure powered by Grafana, InfluxDB and Telegraf. Our setup might look a little different than yours.
First, install Telegraf using:
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update && sudo apt-get install telegraf
Then edit the file /etc/telegraf/telegraf.conf
to include the following:
- # [[inputs.prometheus]]
- # urls = ["http://localhost:9100/metrics"]
+ [[inputs.prometheus]]
+ urls = ["http://localhost:5054", "http://localhost:9002"]
Make sure you add an output, we use InfluxDB, but you can use whatever you want. Once the output is added, restart Telegraf with:
sudo systemctl restart telegraf