celestiaorg / celestiaorg/celestia-node

Pruned full/bridge nodes: minimum viable pruning

Open
#2,615 4 comments 0 reactions 0 assignees View on GitHub
external kind:discussion
Dominant language
Go
Stars
996
Forks
1.1k
Avg merge
1d 6h
Merged PRs (30d)
34

Description

#OperationSaveStorageSpace

This is issue describes the minimum viable pruning needed for full and bridge nodes, which are milestones 1 and 2 in https://github.com/celestiaorg/celestia-node/issues/2033.

First, let us define a [storage window](https://github.com/celestiaorg/celestia-node/discussions/2034) in terms of numbers of blocks, such that blocks before that period aren't kept. For example if the storage window is 172,800, this would be 30 days worth of blocks, assuming a 15 second block time. Defining it in days would be better but may not be trivial.

For light nodes, they should only sample blocks within the storage window.

For full and bridge nodes, we should add a flag --pruned [true/false] that persists a config setting that is true by default on init.

When this flag is true, only blocks within the storage window are sampled, and the CAR files of blocks outside of the storage window are automatically deleted from the store. Headers can still be kept and synced.

The most complicated part will be pruning the badger inverted index. To do so, we can split badger into multiple databases, for each rolling storage window (eg, a database for the last 100k blocks, another database for the next 100k blocks before that). This would mean a that getting entries from the inverted index would require up to two reads, but that is okay as it can be parallelized, and we plan to remove the inverted index anyway. This also means that it might not be possible to switch a non-pruned node to a pruned node, because the inverted indexes are stored differently, unless we add logic for this, but it's not necessary to support this for minimum viable pruning.

Pruned nodes should advertise themselves on a new discovery topic for pruned full nodes. Then, shrexeds/nd should have logic to discover non-pruned nodes in addition to pruned nodes if they try to access data from blocks older than the storage window.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.