🐳Docker

Authors: [Vince | Nodeify]

Last updated at date: 10.04.2024 - updated opgeth and opnode images

System Requirements

CPU
OS
RAM
DISK

8c CPU

Ubuntu 22.04

>= 16GB

>= 5TB

Note: The Base archive node consumes 5.1 TB of space on June 13.2024

Base 🔵

Official Docs https://docs.base.org/guides/run-a-base-node/

Pre-requisites

Update, upgrade, and clean the system, and then firewall management (ufw), Docker, and the Git version control system.

sudo apt update -y && sudo apt upgrade -y && sudo apt auto-remove -y
sudo apt install docker.io docker-compose git ufw -y

Set explicit default UFW rules

sudo ufw default deny incoming
sudo ufw default allow outgoing

Allow SSH, HTTP and HTTPS

sudo ufw allow 22/tcp
sudo ufw allow 80
sudo ufw allow 443

Setting up a domain name to access RPC

Get the IP address of the host machine, you can use the following command in a terminal or command prompt

Set an A record for a domain, you need to access the domain's DNS settings and create an A record that points to the IP address of the host machine. This configuration allows users to reach your domain by resolving the domain name to the specific IP address associated with your host machine. Example video of How to Point a Domain Name to an IP Address

Create base directory

The first command, mkdir base, will create a new directory named base in the current location. The second command, cd base, will change your current working directory to the newly created base directory. Now you are inside the base directory and can start storing docker-compose and related files in it.

Create .env file

Paste the following into the file.

ctrl + x and y to save file

Ensure you have an Ethereum L1 full node RPC available. It needs to be synced before Base will be able to fully sync

Make configuration directory

Download genesis.json and rollup.json

Create base_geth_data docker volume

Initialize Geth

This command runs a Docker container using the op-geth image. It mounts two volumes: base_geth_data to /data inside the container and /root/base/config to /config. The container then initializes the Ethereum client with a genesis file located at /config/genesis-l2.json using the --datadir option to specify the data directory as /data

You should receive a quick output that your genesis file has been initialized.

INFO [08-14|19:31:15.573] Successfully wrote genesis state

Create jwt.hex

Create docker-compose.yml

Assuming that this guide is current, you’ll be able to paste the following into the docker-compose.yml and then ctrl + x and y to save file. The more likely scenario is that this .yml template is a bit outdated and you will need to update the version under the opnode > image as well as the geth > image sections. You can find the latest releases of the op-node and geth nodes here: https://docs.optimism.io/builders/node-operators/releases.

Paste the following into the docker-compose.yml

ctrl + x and y to save file

To sync from a snapshot, visit the Base Docs to validate the recommended approach for restoring from snapshot: https://docs.base.org/tutorials/run-a-base-node/#snapshots. Next, in the home directory of your (i.e. the base folder), create a folder named geth-data. If you already have this folder, remove it to clear the existing state and then recreate it. Next, run the following code and wait for the operation to complete.

As downloading a snapshot takes about 9 hrs it is better to run it in a screen session

Use aria2c to download the most recent Mainnet Archive Snapshot

press ctrl+A and D to return to previous screen and continue installation

You'll then need to untar the downloaded snapshot and place the geth subfolder inside of it in the geth-data folder you created (unless you changed the location of your data directory)

Next, you’ll need to move the snapshot to the where the geth data was stored in the docker container. If you initially tried to sync the node from scratch and are now trying with a snapshot:

Run Base Node

Monitor Logs

Use docker logs to monitor your geth and op-node. The -f flag ensures you are following the log output

Once your Base node starts syncing, the logs should look like this:

for op-geth:

for op-node:

The result will return false if a node is fully synced

Alternatively you can run

and it will return more details about syncing progress

Last updated

Was this helpful?