Guide to setup your machine to join the Goerli/Prater merge testnet
- Ubuntu 20.04
# Install prerequisites commonly available.
sudo apt -y install software-properties-common wget curl
# Add the Ethereum PPA and install the Geth package.
sudo sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
sudo apt-get update
sudo apt-get install ethereum
#Check installation
geth โ-help
"Geth is an execution client, Historically, an execution client alone was enough to run a full Ethereum node. However, ever since Ethereum swapped from proof-of-work (PoW) to proof-of-stake (PoS) based consensus, Geth has needed to be coupled to another piece of software called a "consensus client"."
See : Connecting to Consensus Clients
Geth users are required to install and run a consensus client. Otherwise, Geth will not be able to track the head of the chain.
Client : Lighthouse
#datadir
cd ~/.ethereum/goerli
mkdir consensus
cd consensus
mkdir lighthouse && cd lighthouse
# Install lighthouse
wget https://github.com/sigp/lighthouse/releases/download/v3.5.1/lighthouse-v3.5.1-x86_64-unknown-linux-gnu.tar.gz
tar xvf lighthouse-v3.5.1-x86_64-unknown-linux-gnu.tar.gz
rm lighthouse-v3.5.1-x86_64-unknown-linux-gnu.tar.gz
#Test the binary
./lighthouse --version
# Generate JWT token file
openssl rand -hex 32 | tr -d "\n" > jwttoken
sudo chmod +r jwttoken
# Run Nodes on the terminal
# Run the execution client, by default : --syncmode snap
geth --goerli --datadir /home/bjeab/.ethereum/goerli/ --http --http.api eth,net,web3,txpool,engine,admin --authrpc.jwtsecret /home/bjeab/.ethereum/goerli/consensus/lighthouse/jwttoken --metrics --metrics.expensive
You can create a Bash execute file, once done (Ctrl + X, Y, Enter)
cd ~
mkdir run
nano ~/run/geth.sh
#[geth]
#!/bin/bash
geth --goerli --datadir /home/bjeab/.ethereum/goerli/ --http --http.api eth,net,web3,txpool,engine,admin --authrpc.jwtsecret /home/bjeab/.ethereum/goerli/consensus/lighthouse/jwttoken --metrics --metrics.expensive
# Run the beacon node using lighthouse
cd ~/.ethereum/goerli/consensus/lighthouse
./lighthouse bn --network goerli --execution-endpoint http://localhost:8551 --metrics --validator-monitor-auto --checkpoint-sync-url https://checkpoint-sync.goerli.ethpandaops.io --execution-jwt /home/bjeab/.ethereum/goerli/consensus/lighthouse/jwttoken --http --disable-deposit-contract-sync
You can also create a Bash execute file, once done (Ctrl + X, Y, Enter)
nano ~/run/lighthouse.sh
#[lighthouse]
#!/bin/bash
/home/bjeab/.ethereum/goerli/consensus/lighthouse/lighthouse bn --network goerli --execution-endpoint http://localhost:8551 --metrics --validator-monitor-auto --checkpoint-sync-url https://checkpoint-sync.goerli.ethpandaops.io --execution-jwt /home/bjeab/.ethereum/goerli/consensus/lighthouse/jwttoken --http --disable-deposit-contract-sync
Start with :
/bin/bash /home/bjeab/run/geth.sh
/bin/bash /home/bjeab/run/lighthouse.sh
Execution node sync status
geth version
geth --goerli attach
Watch the last block with this command:
> eth.getBlock('latest').number
8659221
If the value is 0, it's just charging blocks then use:
#To watch the current charged block
eth.syncing
#if false => it's updated
Watch a specific transaction with this command:
# Tx is the transaction
eth.getTransaction("#Tx")
Configure hardhat to deploy a smart contract through your node
require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();
var API_KEY = process.env.API_KEY;
var PRIVATE_KEY = process.env.PRIVATE_KEY;
module.exports = {
solidity: {
version: "0.8.17",
settings : {
optimizer : {
enabled: true,
runs: 200
}
},
},
networks: {
goerli: {
url:`https://goerli.infura.io/v3/${API_KEY}`,
//url: `https://eth-goerli.g.alchemy.com/v2/${API_KEY}`,
chainId: 5,
accounts :[`${PRIVATE_KEY}`],
},
goerliPvNode: {
url:`http://localhost:8545`,
//url: `https://eth-goerli.g.alchemy.com/v2/${API_KEY}`,
chainId: 5,
accounts :[`${PRIVATE_KEY}`],
},
mumbai: {
url:`https://polygon-mumbai.infura.io/v3/${API_KEY}`,
//url:`https://polygon-mumbai.g.alchemy.com/v2/${API_KEY}`,
chainId: 80001,
accounts :[`${PRIVATE_KEY}`],
},
},
gasReporter: {
enabled: true,
currency: 'USD',
gasPrice: 21
}
};
# Deploy contract
npx hardhat run scripts/deploy.js --network goerliPvNode
#response
network goerliPvNode
0x0591F951415Dc471Aa948A49E9Fe752ACB028E9B
Tokenization address: 0x10E0640875817EeFe75F3414522Ae9faa334BFca
Smart Contract addresse 0x10E0640875817EeFe75F3414522Ae9faa334BFca
Create a systemd service config file to configure the Geth node service
sudo nano /etc/systemd/system/geth.service
Paste this configuration file into it and save once done (Ctrl + X, Y, Enter):
[Unit]
Description=Go Ethereum Client - Geth (Goerli)
After=network.target
Wants=network.target
[Service]
Type=simple
Restart=always
RestartSec=5
TimeoutStopSec=180
ExecStart=geth \
--goerli \
--http \
--http.api eth,net,web3,txpool,engine,admin \
--datadir /home/bjeab/.ethereum/goerli/ \
--metrics \
--metrics.expensive \
--pprof \
--authrpc.jwtsecret=/home/bjeab/.ethereum/goerli/consensus/lighthouse/jwttoken
[Install]
WantedBy=default.target
#(reload to reflect the changes)
sudo systemctl daemon-reload
#(lauch)
sudo systemctl start geth.service
#(check)
sudo systemctl status geth.service
#(to stop/restart)
sudo systemctl stop geth.service
sudo systemctl restart geth.service
#(You can enable/disable the geth service to automatically start on reboot)
sudo systemctl enable geth.service
sudo systemctl disable geth.service
To monitor you can check the geth.service status with :
systemctl status geth
#Or
journalctl -fu geth
sudo journalctl -f -u geth.service -o cat | ccze -A
#Press Ctrl + C to stop showing those messages.
Create a systemd service config file to configure the Lighthouse consensus node service
sudo nano /etc/systemd/system/lighthouse.service
Paste this configuration file into it and save once done (Ctrl + X, Y, Enter):
[Unit]
Description=Lighthouse Ethereum Client Beacon Node (Prater)
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
Restart=always
RestartSec=5
ExecStart=/home/bjeab/.ethereum/goerli/consensus/lighthouse/lighthouse bn \
--network goerli \
--datadir /home/bjeab/.ethereum/goerli/ \
--http \
--execution-endpoint http://localhost:8551 \
--checkpoint-sync-url https://checkpoint-sync.goerli.ethpandaops.io \
--execution-jwt /home/bjeab/.ethereum/goerli/consensus/lighthouse/jwttoken \
--metrics \
--validator-monitor-auto \
--disable-deposit-contract-sync
[Install]
WantedBy=multi-user.target
#(reload to reflect the changes)
sudo systemctl daemon-reload
#(lauch)
sudo systemctl start lighthouse.service
#(check)
sudo systemctl status lighthouse.service
#(to stop/restart)
sudo systemctl stop lighthouse.service
sudo systemctl restart lighthouse.service
#(You can enable/disable the lighthouse service to automatically start on reboot)
sudo systemctl enable lighthouse.service
sudo systemctl disable lighthouse.service
To monitor you can check the lighthouse.service status with :
systemctl status lighthouse
#Or
journalctl -fu lighthouse
sudo journalctl -f -u lighthouse.service -o cat | ccze -A
#Press Ctrl + C to stop showing those messages.