DEV Community

Cover image for Setting Up Your Own Goerli Node: A Step-By-Step Guide
Abhishek Tripathi
Abhishek Tripathi

Posted on

Setting Up Your Own Goerli Node: A Step-By-Step Guide

Introduction

Goerli is one of Ethereum’s public testnets, designed to assists developers for testing their decentralized applications(dApps). A Goerli Node is a crucial component of this testnet as it maintains the network, process the transactions, and verify the correctness of smart contracts, all within a test environment.

Building you own Goerli Node will allow you to test and development of Ethereum based applications without using the real Ether.

Here, by following the steps you can setup you Goerli Node from scratch.

Requirements

Before, getting started make sure you have the following commands installed on your system and you have to reserve 300 GB of free disk space for you Goerli node.

  • Wget

  • Jq

  • Docker
    To install these packages, execute the following commands in terminal:

sudo apt update -y
sudo apt install -y wget jq docker.io
sudo usermod -aG docker $USER
newgrp docker && newgrp $USER
Enter fullscreen mode Exit fullscreen mode

Additionally, you’ll also need an Ethereum address on the Goerli network to serve as the fee recipient during the setup.
For that you have to just create a metamask wallet and change its network from Ethereum mainnet to Goerli test network.

Initialisation

  • Start by creating a directory for your Goerli node:
mkdir -p ~/goerli-node/docker-volumes/{geth,prysm}
Enter fullscreen mode Exit fullscreen mode
  • Now move to the goerli-node directory:
cd ~/goerli-node/
Enter fullscreen mode Exit fullscreen mode
  • Create a file in the directory as docker-compose.yml:
nano docker-compose.yml
Enter fullscreen mode Exit fullscreen mode
  • Open the docker-compose.yml file and write the following code and save it:
services:
  geth:
    image: ethereum/client-go:stable
    container_name: goerli-execution
    command: >
      --http
      --http.vhosts=*
      --http.rpcprefix=/
      --http.corsdomain=*
      --http.addr=0.0.0.0
      --http.api=eth,net,engine,admin
      --goerli
volumes:
      - ./docker-volumes/geth:/root/.ethereum
    ports:
      - "${L1_RPC_PORT}:8545"
      - "30303:30303/udp"


  prysm:
    image: gcr.io/prysmaticlabs/prysm/beacon-chain:stable
    container_name: goerli-consensus
    command: >
      sh -c "sleep 30 && exec --prater --datadir=/data --jwt-secret=/geth/goerli/geth/jwtsecret --rpc-host=0.0.0.0 --grpc-gateway-host=0.0.0.0 --monitoring-host=0.0.0.0 --execution-endpoint=/geth/goerli/geth.ipc --accept-terms-of-use --suggested-fee-recipient=${L1_SUGGESTED_FEE_RECIPIENT_ADDR} --checkpoint-sync-url=${L1_CHECKPOINT_URL}"
    volumes:
      - ./docker-volumes/prysm:/data
      - ./docker-volumes/geth:/geth
    ports:
      - "3500:3500"
      - "4000:4000"
      - "12000:12000/udp"
      - "13000:13000"
Enter fullscreen mode Exit fullscreen mode
  • Create and open a .env file:
nano.env
Enter fullscreen mode Exit fullscreen mode
  • Write the following code in the .env file and save it:
L1_RPC_PORT=8845
L1_SUGGESTED_FEE_RECIPIENT_ADDR=”0xYOUR_GOERLI_ADDRESS”
L1_CHECKPOINT_URL=https://goerli.checkpoint-sync.ethpandaops.io

//Make sure you change ”0xYOUR_GOERLI_ADDRESS”
 with your actual Goerli Address// 
Enter fullscreen mode Exit fullscreen mode

Deployment

Now, its time to deploy your Goerli node.
Start the Docker services by using the following command:

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Now, monitor the synchronization progress by checking thelogs of prysm and geth services.

To check prysm logs:

docker-compose logs -f prysm
Enter fullscreen mode Exit fullscreen mode

Just wait for the initial sync to complete you will see the log messages indicating the progress similar to this:

#goerli-consensus  | time="2023-06-19 09:39:44" level=info msg="Synced up to slot 5888296" prefix=initial-sync
Enter fullscreen mode Exit fullscreen mode

To check geth logs:

docker-compose logs -f geth
Enter fullscreen mode Exit fullscreen mode

In this process it will take couple of hours to display the log messages indicating the progress. On completion you will see the log message similar to the following:

#goerli-execution  | INFO [06-19|09:43:24.954] Syncing beacon headers                   downloaded=25600 left=9,177,918 eta=1h5m31.860s
#goerli-execution  | INFO [06-19|10:09:19.488] Syncing: state download in progress      synced=0.30% state=331.34MiB accounts=81053@20.52MiB slots=1,112,986@239.47MiB codes=11681@71.34MiB >
Enter fullscreen mode Exit fullscreen mode

Validation

When both the services show the sync completion and new blocks are being updated, you can validate your setup by making an RPC call. For instance, to get the current block number run the following code:

printf "%d\n" $(curl -s -X POST --header "Content-Type: application/json"  --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}' http://localhost:8845 | jq -r .result)
Enter fullscreen mode Exit fullscreen mode

If everything is setup correctly, you should see the current block number displayed.

Great Job! You have successfully set up your own full Goerli node. Now you can explore, experiment, and contribute to the Goerli Testnet and the Ethereum ecosystem without using the real Ether.

Top comments (0)