Skip to content

Commit

Permalink
GITBOOK-22: change request with no subject merged in GitBook
Browse files Browse the repository at this point in the history
  • Loading branch information
Tweeddalex authored and gitbook-bot committed Jan 6, 2025
1 parent c12f5f1 commit 7c7675e
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions docs/validator-guide/pruning.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Optimising storage with pruning
# Optimising disk storage with pruning

## Context

Cosmos SDK and Tendermint has a concept of *pruning*, which allows reducing the disk utilisation and [storage required on a node](../setup-and-configure/requirements.md).
Cosmos SDK and Tendermint has a concept of _pruning_, which allows reducing the disk utilisation and [storage required on a node](../setup-and-configure/requirements.md).

There are two kinds of pruning controls available on a node:

1. **Tendermint pruning**: This impacts the `~/.cheqdnode/data/blockstore.db/` folder by only retaining the last *n* specified blocks. Controlled by the `min-retain-blocks` parameter in `~/.cheqdnode/config/app.toml`.
1. **Tendermint pruning**: This impacts the `~/.cheqdnode/data/blockstore.db/` folder by only retaining the last _n_ specified blocks. Controlled by the `min-retain-blocks` parameter in `~/.cheqdnode/config/app.toml`.
2. **Cosmos SDK pruning**: This impacts the `~/.cheqdnode/data/application.db/` folder and prunes Cosmos SDK app-level state (a logical layer higher than Tendermint, which is just peer-to-peer). These are set by the `pruning` parameters in the `~/.cheqdnode/config/app.toml` file.

This can be done by modifying the pruning parameters inside `/home/cheqd/.cheqdnode/config/app.toml` file.

## Instructions

> ⚠️ In order for either type of pruning to work, your node should be running the [latest stable release of cheqd-node](https://github.com/cheqd/cheqd-node/releases/latest) (at least **v1.3.0+**).
Expand All @@ -21,13 +21,13 @@ You can check which version of `cheqd-noded` you're running using:
cheqd-noded version
```

The output should be a version higher than v1.3.0. If you're on a lower version, you either manually upgrade the node binary or [use the interactive installer to execute an upgrade](../setup-and-configure/README.md) while retaining settings.
The output should be a version higher than v1.3.0. If you're on a lower version, you either manually upgrade the node binary or [use the interactive installer to execute an upgrade](../setup-and-configure/) while retaining settings.

The instructions below assume that the home directory for the `cheqd` user is set to the default value of `/home/cheqd`. If this is *not* the case for your node, please modify the commands below to the correct path.
The instructions below assume that the home directory for the `cheqd` user is set to the default value of `/home/cheqd`. If this is _not_ the case for your node, please modify the commands below to the correct path.

### Check systemd service status

Follow [similar instructions as mentioned in the installer guide](../setup-and-configure/README.md) to check systemd service status:
Follow [similar instructions as mentioned in the installer guide](../setup-and-configure/) to check systemd service status:

```bash
systemctl status cheqd-cosmovisor.service
Expand All @@ -46,7 +46,7 @@ cd ~

### Display current directory usage/size for the node data folder

Before you make changes to pruning configuration, you might want to capture the *existing* usage first (only copy the command bit, not the full line):
Before you make changes to pruning configuration, you might want to capture the _existing_ usage first (only copy the command bit, not the full line):

```bash
root@hostname ~# du -h -d 1 /home/cheqd/.cheqdnode/data/ 2>/dev/null
Expand Down Expand Up @@ -77,19 +77,19 @@ Instructions on how to use text editors such as `nano` is out of the scope of th

> ⚠️ If your node was configured to work with **release version v1.2.2 or earlier**, you may have been advised to run in `pruning="nothing"` mode due to a bug in Cosmos SDK.
>
> Ensure you've upgraded to the [latest stable release](https://github.com/cheqd/cheqd-node/releases/latest) ([using the installer](../setup-and-configure/README.md)) or otherwise. When running a validator node, you're recommended to change this value to `pruning="default"`.
> Ensure you've upgraded to the [latest stable release](https://github.com/cheqd/cheqd-node/releases/latest) ([using the installer](../setup-and-configure/)) or otherwise. When running a validator node, you're recommended to change this value to `pruning="default"`.
The file should already be populated with values. Edit the `pruning` parameter value to one of following:

1. `pruning="nothing"` (*highest* disk usage): This will *disable* Cosmos SDK pruning and set your node to behave like an "archive" node. This mode consumes the highest disk usage.
1. `pruning="nothing"` (_highest_ disk usage): This will _disable_ Cosmos SDK pruning and set your node to behave like an "archive" node. This mode consumes the highest disk usage.
2. `pruning="default"` (**recommended**, moderate disk usage): This keeps the last 100 states in addition to every 500th state, and prunes on 10-block intervals. This configuration is safe to use on all types of nodes, especially validator nodes.
3. `pruning="everything"` (*lowest* disk usage): This mode is **not recommended** when running validator nodes. This will keep the current state and also prune on 10 blocks intervals. This settings is useful for nodes such as seed/sentry nodes, as long as they are not used to query RPC/REST API requests.
3. `pruning="everything"` (_lowest_ disk usage): This mode is **not recommended** when running validator nodes. This will keep the current state and also prune on 10 blocks intervals. This settings is useful for nodes such as seed/sentry nodes, as long as they are not used to query RPC/REST API requests.
4. `pruning="custom"` (custom disk usage): If you set the `pruning` parameter to `custom`, you will have to modify two additional parameters:
* `pruning-keep-recent`: This will define how many recent states are kept, e.g., `250` (contrast this against `default`).
* `pruning-interval`: This will define how often state pruning happens, e.g., `50` (contrast against `default`, which does it every 10 blocks)
* `pruning-keep-every`: This parameter is deprecated in newer versions of Cosmos SDK. You can delete this line if it's present in your `app.toml` file.

Although the paramters named `pruning-*` are *only* supposed to take effect if the pruning strategy is `custom`, in practice it seems that in Cosmos SDK v0.46.10 these settings still impact pruning. Therefore, you're advised to **comment out these lines** when using `default` pruning.
Although the paramters named `pruning-*` are _only_ supposed to take effect if the pruning strategy is `custom`, in practice it seems that in Cosmos SDK v0.46.10 these settings still impact pruning. Therefore, you're advised to **comment out these lines** when using `default` pruning.

Example configuration file with recommended settings:

Expand All @@ -105,11 +105,11 @@ pruning = "default"

Configuring `min-retain-blocks` parameter to a non-zero value activates Tendermint pruning, which specifies minimum block height to retain. By default, this parameter is set to `0`, which disables this feature.

Enabling this feature can reduce disk usage significantly. **Be careful in setting a value**, as it must be *at least* higher than 250,000 as calculated below:
Enabling this feature can reduce disk usage significantly. **Be careful in setting a value**, as it must be _at least_ higher than 250,000 as calculated below:

* [Unbonding time](../../architecture/adr-list/adr-005-genesis-parameters.md) (14 days) converted to seconds = 1,210,000 seconds
* ...divided by average block time = approx. 6s / block
* = approx. 210,000 blocks
* \= approx. 210,000 blocks
* Adding a safety margin (in case average block time goes down) = approx. 250,000 blocks

Therefore, this setting must always be updated to carefully match a valid value in case the unbonding time on the network you're running on is different. (E.g., this value is different on mainnet vs testnet due to different unbonding period.)
Expand All @@ -130,7 +130,7 @@ Save and exit from the `app.toml` file. Working with text editors is outside the

### Switch user and restart service

> ℹ️ **NOTE**: You need root or *at least* a user with super-user privileges using the `sudo` prefix to the commands below when interact with systemd.
> ℹ️ **NOTE**: You need root or _at least_ a user with super-user privileges using the `sudo` prefix to the commands below when interact with systemd.
If you switched to the cheqd user, exit out to a root/super-user:

Expand All @@ -154,7 +154,7 @@ Check the systemd service status and confirm that it's running:
systemctl status cheqd-cosmovisor.service
```

Our [installer guide](../setup-and-configure/README.md) has a section on how to check service status.
Our [installer guide](../setup-and-configure/) has a section on how to check service status.

## Next steps

Expand All @@ -166,4 +166,20 @@ If you've gone from a higher disk usage setting to a lower disk usage setting, r
du -h -d 1 /home/cheqd/.cheqdnode/data/ 2>/dev/null
```

The output shown *should* show a difference in disk usage from the previous run before settings were changed for the `application.db` folder (if the `pruning` parameters were changed) and/or the `blockstore.db` folder (if `min-retain-blocks`) was changed.
The output shown _should_ show a difference in disk usage from the previous run before settings were changed for the `application.db` folder (if the `pruning` parameters were changed) and/or the `blockstore.db` folder (if `min-retain-blocks`) was changed.

## Third-Party Snapshots for Reference

Instead of syncing a full node from scratch, validators can leverage pruned snapshots provided by trusted third-party services. These snapshots are substantially smaller (usually 3-10 GB compared to 100s of GBs for a full node), allowing faster setup and reduced storage requirements.

### **Available Third-Party Snapshots**

1. **NodeStake**
* Website: [https://nodestake.org/cheqd](https://nodestake.org/cheqd)
* Instructions: Navigate to the **Snapshot** tab for detailed steps on downloading and using their snapshots.
2. **Nysa Network**
* Website: [https://snapshots.nysa.network/#cheqd-mainnet-1/](https://snapshots.nysa.network/#cheqd-mainnet-1/)
* Snapshot details and setup instructions are provided on the site.
3. **Lavender.Five Nodes**
* Website: [https://services.lavenderfive.com/mainnet/cheqd/snapshot](https://services.lavenderfive.com/mainnet/cheqd/snapshot)
* Visit the page for links and commands to restore a node from their pruned snapshots.

0 comments on commit 7c7675e

Please # to comment.