**WORK IN PROGRESS **
(FKA Trie Log Pruning)
Step by Step Guide
IMPORTANT: we strongly recommend reading the rest of this documentation before running these commands because your node’s configuration may require changes to these commands…
(Targeting 24.1.2 release, but currently you must be on the besu main
branch for this to work)
Update besu config to add
--Xbonsai-limit-trie-logs-enabled
but don’t restart yetStop besu
(optional) Run:
sudo /usr/local/bin/besu/bin/besu --data-storage-format=BONSAI --data-path=/var/lib/besu --sync-mode=X_SNAP storage x-trie-log prune
Start besu (remembering to run
sudo systemctl daemon-reload
if you use a systemd service file as per CoinCashew and Somer)Look out for
Limit trie logs enabled: retention: 512; prune window: 30000
in your besu config printout during startupEnjoy more GBs
What?
We have a new experimental feature available: --Xbonsai-limit-trie-logs-enabled
which aims to keep Besu’s database as small as it can be. After a brief grace period, we intend to make this enabled by default for stakers. This is only relevant if you're using data-storage-format=BONSAI
.
From our testing, we estimate this will save users > 3 GB per week in database growth. Early testing indicates Besu’s overall database growth with this enabled is ~7 GB per week (thanks Yorick!) which is on par with geth.
Why?
Some users noticed that resyncing Besu can free up disk space, especially for longer running nodes. This is despite --data-storage-format=BONSAI
having “implicit pruning”. More on this reddit thread: https://www.reddit.com/r/ethstaker/comments/12xnxxi/clearing_up_besubonsai_confusion_on_state_growth/
...
The Trie Logs are retained in order to cope with chain reorgs. After each block is finalized, Trie Logs older than that are no longer required so it is safe to remove them from both the node's and the network's point of view.
How?
If you want to use this feature before it is enabled by default, simply add this option to your besu command: --Xbonsai-limit-trie-logs-enabled
When you restart besu it will begin pruning, block by block (and a cheeky bit during besu startup).
...
If you have a long-running node, this will not immediately clear your backlog of trie logs in the same way that resyncing does. In order to do this we’re providing a “run once” offline command to immediately prune all your old trie logs in a few minutes or less. Note, this requires besu to be shutdown before running, but downtime will be minimal. You will not need to run this command a second time if you keep --Xbonsai-limit-trie-logs-enabled
.
I’m impatient, reduce my database size now!
Okay, okay - we got you! We built a one-off besu command to remove this extra data (usually in seconds)and avoid having to resync. For minimal downtime, we recommend running this command before restarting Besu --Xbonsai-limit-trie-logs-enabled
(easiest to do it all at the same time).
...
sudo /usr/local/bin/besu/bin/besu --config-file=besu-config.toml storage x-trie-log prune
Subcommand Troubleshooting
The prune command should look something like this for mainnet users…sudo /usr/local/bin/besu/bin/besu --data-path=/var/lib/besu --data-storage-format=BONSAI --sync-mode=X_SNAP storage x-trie-log prune
...
sudo /usr/local/bin/besu/bin/besu --network=holesky --sync-mode=X_SNAP --data-storage-format=BONSAI --data-path=/var/lib/besu storage x-trie-log prune
The Details
Too much detail for users but if you’re interested:
...