Skip to content

Instantly share code, notes, and snippets.

@yorickdowne
Last active March 31, 2024 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yorickdowne/2b12d29dd4346453f9029ea393b64231 to your computer and use it in GitHub Desktop.
Save yorickdowne/2b12d29dd4346453f9029ea393b64231 to your computer and use it in GitHub Desktop.
Optimal Besu settings for database growth

Overview

Besu, an Ethereum execution layer client, can be optimized for minimal database growth (7-8 GiB/week), and for block processing speed.

The relevant parameter is --Xbonsai-limit-trie-logs-enabled=true

If you have 64 GiB of RAM or more, you can also add --Xplugin-rocksdb-high-spec-enabled=true for even better performance.

A long-running Besu DB will have sizeable trie log storage. This can be reduced with a one-off prune using the storage x-trie-log prune subcommand.

Somer Esat adjustment

Edit the service:

sudo nano /etc/systemd/system/besu.service

Add two lines to ExecStart. You'll add a \ to the last line, then ones more line after that. It'll look something like this, with the new lines after the jwt secret:

ExecStart=/usr/local/bin/besu/bin/besu \
  --network=mainnet \
  --data-path=/var/lib/besu \
  --engine-jwt-secret=/var/lib/jwtsecret/jwt.hex \
  --Xbonsai-limit-trie-logs-enabled=true

If you have 64 GiB of RAM or more, also add --Xplugin-rocksdb-high-spec-enabled=true so it looks something like this instead

ExecStart=/usr/local/bin/besu/bin/besu \
  --network=mainnet \
  --data-path=/var/lib/besu \
  --engine-jwt-secret=/var/lib/jwtsecret/jwt.hex \
  --Xbonsai-limit-trie-logs-enabled=true \
  --Xplugin-rocksdb-high-spec-enabled=true

Keep an eye on release notes, as the trie log parameter will be renamed to --bonsai-limit-trie-logs-enabled and become default, likely from Besu 24.6.0

One-off pruning

If you have a long-running Besu DB, there will be accumulated trie logs in it. These can be pruned once, and from there the trie log pruning parameter in ExecStart takes care of any new entries.

Get into screen or tmux, so that the session won't be interrupted

screen

Stop the service

sudo systemctl stop besu

Prune Besu

sudo -u besu besu --data-path=/var/lib/besu storage x-trie-log prune

Once this is done, start the service

sudo systemctl start besu

Obligatory Docker flex

For users of Eth Docker, these parameters are active by default. A long-running DB can be pruned with ./ethd prune-besu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment