mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 08:52:54 +00:00
Add commmand for pruning states (#4835)
## Issue Addressed Closes #4481. (Continuation of #4648) ## Proposed Changes - [x] Add `lighthouse db prune-states` - [x] Make it work - [x] Ensure block roots are handled correctly (to be addressed in 4735) - [x] Check perf on mainnet/Goerli/Gnosis (takes a few seconds max) - [x] Run block root healing logic (#4875 ) at the beginning - [x] Add some tests - [x] Update docs - [x] Add `--freezer` flag and other improvements to `lighthouse db inspect` Co-authored-by: Michael Sproul <michael@sigmaprime.io> Co-authored-by: Jimmy Chen <jimmy@sigmaprime.io> Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
@@ -158,3 +158,38 @@ lighthouse db version --network mainnet
|
||||
```
|
||||
|
||||
[run-correctly]: #how-to-run-lighthouse-db-correctly
|
||||
|
||||
## How to prune historic states
|
||||
|
||||
Pruning historic states helps in managing the disk space used by the Lighthouse beacon node by removing old beacon
|
||||
states from the freezer database. This can be especially useful when the database has accumulated a significant amount
|
||||
of historic data. This command is intended for nodes synced before 4.4.1, as newly synced node no longer store
|
||||
historic states by default.
|
||||
|
||||
Here are the steps to prune historic states:
|
||||
|
||||
1. Before running the prune command, make sure that the Lighthouse beacon node is not running. If you are using systemd, you might stop the Lighthouse beacon node with a command like:
|
||||
|
||||
```bash
|
||||
sudo systemctl stop lighthousebeacon
|
||||
```
|
||||
|
||||
2. Use the `prune-states` command to prune the historic states. You can do a test run without the `--confirm` flag to check that the database can be pruned:
|
||||
|
||||
```bash
|
||||
sudo -u "$LH_USER" lighthouse db prune-states --datadir "$LH_DATADIR" --network "$NET"
|
||||
```
|
||||
|
||||
3. If you are ready to prune the states irreversibly, add the `--confirm` flag to commit the changes:
|
||||
|
||||
```bash
|
||||
sudo -u "$LH_USER" lighthouse db prune-states --confirm --datadir "$LH_DATADIR" --network "$NET"
|
||||
```
|
||||
|
||||
The `--confirm` flag ensures that you are aware the action is irreversible, and historic states will be permanently removed.
|
||||
|
||||
4. After successfully pruning the historic states, you can restart the Lighthouse beacon node:
|
||||
|
||||
```bash
|
||||
sudo systemctl start lighthousebeacon
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user