**WORK IN PROGRESS **(FKA Trie Log Pruning)instructions only work for besu version 24.3.0 onwards**
UPDATE: Since 24.6.0, this feature has been promoted to production ready and is enabled by default: `--bonsai-limit-trie-logs-enabled`
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
...
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. See here for more details about resource usage: https://eth-docker.net/Usage/ResourceUsage/#disk-ram-cpu-requirements
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 logs should look something like this...
Code Block |
---|
2024-0102-3102 05:1045:4341.777162+00:00 | main | INFO | KeyPairUtil | Attempting to load public key from /data/besu/key ... 2024-0102-3102 05:1045:4743.574433+00:00 | main | INFO | TrieLogSubCommand | CalculatingEstimating trie logs size before pruning... 2024-0102-3102 05:1045:5143.100837+00:00 | main | INFO | TrieLogSubCommand | TrieEstimated trie logs size before pruning: 89 GiB 2024-01-31 05:12:45.907-02-02 05:46:09.863+00:00 | main | INFO | TrieLogHelper | Starting pruning: retain 512 trie logs, processing in 1 batches... 2024-02-02 05:46:09.918+00:00 | main | INFO | TrieLogHelper | Saving trie logs to retain in file /data/besu/database/trieLogsToRetain-1 (batch 1)... 2024-0102-3102 05:1246:4509.916926+00:00 | main | INFO | TrieLogHelper | Obtaining trielogs from db, this may take a few minutes... 2024-0102-3102 05:1246:4610.036100+00:00 | main | INFO | TrieLogHelper | Clear trie logs... 2024-0102-3102 05:1246:4610.100155+00:00 | main | INFO | TrieLogHelper | Restoring trie logs retained from batch 1... 2024-0102-3102 05:1246:4610.168222+00:00 | main | INFO | TrieLogHelper | Key(0): 0xc0a1f26bf828ae6d9af8fda8af3126f12a6d986afea05fdc61b25d0d0ab3b8d40xcd50706da7f6f2db7f9d54f3589122760900d9ab2508c20a4ca40b496d930368 ... 2024-0102-3102 05:1246:4610.263336+00:00 | main | INFO | TrieLogHelper | Key(511): 0x5eb700164f4190b8806c7ce3de2f6e5b4f4c05a61bba4058f1b0a5ef63ec73af0x238f9649b59616430ad7e43b8f3cf65bc97cac4aa54a3eddf3ad6ee666ce733e 2024-0102-3102 05:1246:4610.359441+00:00 | main | INFO | TrieLogHelper | Deleting files... 2024-0102-3102 05:1246:4610.363446+00:00 | main | INFO | TrieLogSubCommand | Finished pruning. Re-estimating trie recalculatinglogs size... 2024-0102-3102 05:1246:5111.658023+00:00 | main | INFO | TrieLogSubCommand | TrieEstimated trie logs size after pruning: 0 B (0 B estimate is normal when using default settings) 2024-02-02 05:46:11.023+00:00 | main | INFO | TrieLogSubCommand | Prune ran successfully. We estimate you freed up 8 9 GiB! Prune ran successfully. We estimate you freed up 9 GiB! |
If you use a toml config file, then you can simply do something like:
...
java.lang.RuntimeException: Column handle not found for segment WORLD_STATE
sudo
Are you using data-storage-format=FOREST
instead of data-storage-format=BONSAI
on an existing bonsai database?
...
https://github.com/hyperledger/besu/issues/5390
https://github.com/hyperledger/besu/pull/6026
https://github.com/hyperledger/besu/pull/6303