Overview
Hyperledger Besu is an open-source Ethereum client designed for demanding enterprise applications requiring secure, high-performance transaction processing in a private network. It's developed under the Apache 2.0 license and written in Java .
Official Links
1. Initial configuration
Create a service user for the execution service, create data directory and assign ownership.
Copy sudo adduser --system --no-create-home --group execution
sudo mkdir -p /var/lib/besu
sudo chown -R execution:execution /var/lib/besu
Install dependencies.
Copy sudo apt install -y openjdk-21-jdk libjemalloc-dev jq
2. Install Binaries
Downloading binaries is often faster and more convenient.
Building from source code can offer better compatibility and is more aligned with the spirit of FOSS (free open source software).
Option 1 - Download binariesRun the following to automatically download the latest linux release, un-tar and cleanup.
Copy RELEASE_URL = "https://api.github.com/repos/hyperledger/besu/releases/latest"
TAG = $( curl -s $RELEASE_URL | jq -r .tag_name )
BINARIES_URL = "https://github.com/hyperledger/besu/releases/download/$TAG/besu-$TAG.tar.gz"
echo Downloading URL: $BINARIES_URL
cd $HOME
wget -O besu.tar.gz $BINARIES_URL
tar -xzvf besu.tar.gz -C $HOME
rm besu.tar.gz
sudo mv $HOME /besu-* besu
Install the binaries.
Copy sudo mv $HOME /besu /usr/local/bin/besu
Option 2 - Build from source codeBuild the binaries.
Copy mkdir -p ~/git
cd ~/git
# Clone the repo
git clone https://github.com/hyperledger/besu.git
cd besu
# Get new tags
git fetch --tags
# Get latest tag name
latestTag = $( git describe --tags ` git rev-list --tags --max-count=1 ` )
# Checkout latest tag
git checkout $latestTag
# Build
./gradlew installDist
Verify Besu was properly built by checking the version.
Copy ./build/install/besu/bin/besu --version
Sample output of a compatible version.
Copy besu/v23.4.0/linux-x86_64/openjdk-java-17
Install the binaries.
Copy sudo cp -a $HOME /git/besu/build/install/besu /usr/local/bin/besu
3. Setup and configure systemd
Create a systemd unit file to define your execution.service
configuration.
Copy sudo nano /etc/systemd/system/execution.service
Paste the following configuration into the file.
Copy [Unit]
Description = Besu Execution Layer Client service for Mainnet
Wants = network-online.target
After = network-online.target
Documentation = https://www.coincashew.com
[Service]
Type = simple
User = execution
Group = execution
Restart = on-failure
RestartSec = 3
KillSignal = SIGINT
TimeoutStopSec = 900
Environment = "JAVA_OPTS=-Xmx5g"
ExecStart = /usr/local/bin/besu/bin/besu \
--network=mainnet \
--p2p-port=30303 \
--rpc-http-port=8545 \
--engine-rpc-port=8551 \
--max-peers=25 \
--metrics-enabled=true \
--metrics-port=6060 \
--rpc-http-enabled=true \
--sync-mode=SNAP \
--data-storage-format=BONSAI \
--Xbonsai-limit-trie-logs-enabled=true \
--data-path= "/var/lib/besu" \
--Xplugin-rocksdb-high-spec-enabled \
--engine-jwt-secret=/secrets/jwtsecret
[Install]
WantedBy = multi-user.target
Running less than 32GB of RAM? Deleting the flag, --Xplugin-rocksdb-high-spec-enabled
is advisable.
To exit and save, press Ctrl
+ X
, then Y
, then Enter
.
Run the following to enable auto-start at boot time.
Copy sudo systemctl daemon-reload
sudo systemctl enable execution
Finally, start your execution layer client and check it's status.
Copy sudo systemctl start execution
sudo systemctl status execution
Press Ctrl
+ C
to exit the status.
4. Helpful execution client commands
View Logs Stop Start View Status Reset Database
Copy sudo journalctl -fu execution | ccze
A properly functioning Besu execution client will indicate "Fork-Choice-Updates". For example,
Copy 2022-03-19 04:09:36.315+00:00 | vert.x-worker-thread-0 | INFO | EngineForkchoiceUpdated | Consensus fork-choice-update: head: 0xcd2a_8b32..., finalized: 0xfa22_1142...
2022-03-19 04:09:48.328+00:00 | vert.x-worker-thread-0 | INFO | EngineForkchoiceUpdated | Consensus fork-choice-update: head: 0xff1a_f12a..., finalized: 0xfa22_1142...
Copy sudo systemctl stop execution
Copy sudo systemctl start execution
Copy sudo systemctl status execution
Common reasons to reset the database can include:
Recovering from a corrupted database due to power outage or hardware failure
Re-syncing to reduce disk space usage
Upgrading to a new storage format
Copy sudo systemctl stop execution
sudo rm -rf /var/lib/besu/*
sudo systemctl restart execution
Time to re-sync the execution client can take a few hours up to a day.
Now that your execution client is configured and started, proceed to the next step on setting up your consensus client.
If you're checking the logs and see any warnings or errors, please be patient as these will normally resolve once both your execution and consensus clients are fully synced to the Ethereum network.