Nodes

System Requirements and Prerequisites

Before starting, ensure you have the following (recommended):

  • Hyperledger Besu installed on your machine. Installation Guide.

  • Java 17 or higher.

  • RAM: 8GB

  • Storage: 750GB

Install Besu

Prerequisites

There are multiple methods for installing Hyperledger Besu ( from source binary or Docker image).

Install java JDK 17+ (If not installed, check: `java -version`).

apt install openjdk-17-jre-headless
apt install libjemalloc-dev unzip
Download Besu

You can download the latest version of Hyperledger Besu from the official releases page : packaged binaries.

wget https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/24.1.1/besu-24.1.1.zip

Once downloaded, extract the archive to a directory.

unzip besu-24.1.1.zip

Change into the besu- directory.

cd besu-24.1.1/

To confirm installation:

bin/besu --help
bin/besu --version

To run besu as a command go to .bashrc.

nano .bashrc

Add this line:

export PATH=$PATH:/pathTO/besu-24.1.1/bin
source .bashrc

Verify:

besu --help
besu --version

Get Started

Initialize Node Directories
  1. Create a directory

mkdir -p network/node1/data
cp network/node1/data
  1. Generate a Node Key for the New Node

besu --data-path=data public-key export --to=data/key.pub

Copy the Genesis File

The new node needs to be initialized with the same genesis file as the rest of the network. Copy the genesis.json file.

cd network/node1

Download the Testnet genesis.json file.

Create config.toml Configuration Files

cd network/node1
nano config.toml 
Exemple of Configuration
# Valid TOML config file
data-path="data" # Path
#static-nodes-file="data/static-nodes.json"

# Network
bootnodes=["enode://23b6a539306cc1f3a61230e3253cebf9b6cad37fa045954fe27cef265ab232329456c786d16d6c132eaf957b75f5e87629ec7e6a7aa271e9c346b2cde2e0a4d0@95.111.219.167:30301"]
#p2p-host="0.0.0.0"
p2p-port=30305
max-peers=42
host-allowlist=["*"]

[sync]
#sync-mode="X_SNAP" # Enables Snap sync

logging="DEBUG"

min-gas-price=0

revert-reason-enabled=true

rpc-http-enabled=true
#rpc-http-host="0.0.0.0"
rpc-http-port=22005
rpc-http-cors-origins=["*"]
rpc-http-api=["ADMIN", "ETH", "NET", "WEB3", "QBFT"]

#rpc-ws-host="0.0.0.0"
rpc-ws-enabled=true
rpc-ws-port=32005
rpc-ws-api=["ADMIN", "ETH", "NET", "WEB3", "QBFT"]

# Chain
genesis-file="genesis.json" # Path to the custom genesis file
Configuration with static-nodes.json

Sync your node using static-nodes

Uncomment in the configuration file the following line :

static-nodes-file="data/static-nodes.json"
cd network/node1/data

Create a static-nodes.json file with the following content :

For Testnet
[
  "enode://23b6a539306cc1f3a61230e3253cebf9b6cad37fa045954fe27cef265ab232329456c786d16d6c132eaf957b75f5e87629ec7e6a7aa271e9c346b2cde2e0a4d0@95.111.219.167:30301"
]
For Mainnet
[
  "enode://39f394a6c9bec694d2c7dc5b1c5b20611fbfb9212a5f75c28febdff92eb290ea7ec1c5a3873d7e14a32ec3bc7072f52ef4dfbf9c7387c8315b9d3a5b48e981df@94.237.66.224:30301"
]

Start Node

besu --config-file=config.toml

Run as a Service

Simple service
sudo adduser --system --no-create-home --group besu
sudo chown -R besu:besu /path/to/NodeDirectory

Create a service file for each node in /etc/systemd/system/.

sudo nano /etc/systemd/system/besu.service
[Unit]
Description=Hyperledger Besu Ethereum Node
After=network.target

[Service]
Type=simple
User=besu
Group=besu
WorkingDirectory=/path/to/Node1
ExecStart=/path/to/besu-24.1.1/bin/besu --config-file /path/to/Node1/config.toml
KillMode=process
KillSignal=SIGINT
TimeoutStopSec=90
Restart=on-failure
RestartSec=100

[Install]
WantedBy=multi-user.target

Reload the systemd daemon:

sudo systemctl daemon-reload

Start and enable the service:

sudo systemctl enable besu
sudo systemctl start besu
sudo systemctl status besu

Verify the status service:

journalctl -fu besu
sudo journalctl -f -u besu.service -o cat
sudo journalctl -f -u besu.service -o cat | ccze -A

If the ports are already used on the local machine.

Check:

sudo netstat -tulpn | grep LISTEN

Stop them if you can:

kill <PID>  or kill -9 <PID> (to force)

And restart the service:

sudo systemctl restart besu
Confirm the node is running

We can call the JSON-RPC API methods to confirm the node is running. eth_syncing return the synchronization status : returns the starting, current, and highest block, or false if not synchronizing (or if the head of the chain has been reached).

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":51}' http://127.0.0.1:22005

Last updated