You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

**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…

(Targetting 24.1.2 release, but currently you must be on the besu main branch for this to work)

  1. Update besu config to add --Xbonsai-limit-trie-logs-enabled but don’t restart yet

  2. Stop besu

  3. (optional) Run /usr/local/bin/besu/bin/besu --data-storage-format=BONSAI --data-path=/var/lib/besu --sync-mode=X_SNAP storage x-trie-log prune

  4. Start besu (remembering to run sudo systemctl daemon-reload if you use a systemd service file as per CoinCashew and Somer)

  5. Look out for Limit trie logs enabled: retention: 512; prune window: 30000 in your besu config printout during startup

  6. Enjoy 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.

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/

In reality, whilst the Merkle Patricia Trie is implicitly pruned, the BONSAI feature did introduce an extra data structure: the Trie Log (more detail about BONSAI and trie logs here: https://consensys.io/blog/bonsai-tries-guide)

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 want maximum database size reduction, read on…

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 seconds. 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 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).

If you followed Somer Esat’s (https://someresat.medium.com/guide-to-staking-on-ethereum-ubuntu-teku-f09ecd9ef2ee ) or CoinCashew’s guide (https://www.coincashew.com/coins/overview-eth/guide-or-how-to-setup-a-validator-on-eth2-mainnet/part-i-installation/step-3-installing-execution-client/besu) then you likely have these options set in your besu.service or execution.service systemd file:

...
ExecStart=/usr/local/bin/besu/bin/besu \
...
  --sync-mode=X_SNAP \
  --data-path="/var/lib/besu" \
  --data-storage-format=BONSAI \
...

So in order to prune the trie logs, your command should be something like:

/usr/local/bin/besu/bin/besu --data-storage-format=BONSAI --data-path=/var/lib/besu --sync-mode=X_SNAP storage x-trie-log prune


If you use a toml config file, then you can simply do something like:

/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…
/usr/local/bin/besu/bin/besu --data-path=/var/lib/besu --data-storage-format=BONSAI --sync-mode=X_SNAP storage x-trie-log prune

and besu should be shutdown before running it.

java.lang.IllegalArgumentException: Subcommand only works with data-storage-format=BONSAI

Are you missing --data-storage-format=BONSAI? It must be add before the storage subcommand, i.e.

/usr/local/bin/besu/bin/besu --data-storage-format=BONSAI --data-path=/var/lib/besu --sync-mode=X_SNAP storage x-trie-log prune


java.lang.RuntimeException: Column handle not found for segment TRIE_BRANCH_STORAGE

Did you specify the `data-path`?

/usr/local/bin/besu/bin/besu --data-path=/var/lib/besu --data-storage-format=BONSAI --sync-mode=X_SNAP storage x-trie-log prune


… | INFO | RocksDBKeyValueStorageFactory | No existing database detected at /tmp/besu. Using version 2

java.lang.IllegalArgumentException: Trying to retain more trie logs than chain length (0), skipping pruning

Did you specify the correct data-path for your node?

/usr/local/bin/besu/bin/besu --data-path=/var/lib/besu --data-storage-format=BONSAI --sync-mode=X_SNAP storage x-trie-log prune


java.lang.IllegalArgumentException: Cannot store generated private key.

Did you specify the correct data-path for your node?

/usr/local/bin/besu/bin/besu --data-path=/var/lib/besu --data-storage-format=BONSAI --sync-mode=X_SNAP storage x-trie-log prune


… | INFO | KeyPairUtil | Attempting to load public key from /data/besu/key

java.lang.IllegalArgumentException: Supplied file does not contain valid keyPair pair.

Check your file permission, you made need to run the command as sudo:
sudo /usr/local/bin/besu/bin/besu --data-storage-format=BONSAI --data-path=/var/lib/besu storage --sync-mode=X_SNAP x-trie-log prune


java.lang.RuntimeException: Column handle not found for segment WORLD_STATE

Are you using data-storage-format=FOREST instead of data-storage-format=BONSAI on an existing bonsai database?


org.hyperledger.besu.plugin.services.exception.StorageException: org.rocksdb.RocksDBException: While lock file: /data/besu/database/LOCK: Resource temporarily unavailable

Is besu already running? You need to shut the besu client down before running this subcommand.


java.lang.IllegalStateException: Unable to change the sync mode when snap sync is incomplete, please restart with snap sync mode

Have you specified the sync-mode? Default is sync-mode=FAST. Most mainnet users use X_SNAP or X_CHECKPOINT

/usr/local/bin/besu/bin/besu --sync-mode=X_SNAP --data-storage-format=BONSAI --data-path=/var/lib/besu storage x-trie-log prune


java.lang.RuntimeException: No finalized block present, can't safely run trie log prune

If your node is relatively new or recently resynced, you might not need to run this command.


org.hyperledger.besu.util.InvalidConfigurationException: Supplied genesis block does not match chain data stored in /data/besu.

Are you running this command for a network other than mainnet? You need to specify the network…

/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:

https://github.com/hyperledger/besu/issues/5390

https://github.com/hyperledger/besu/pull/6026

  • No labels