Skip to content

Prune spendjournal depth - #8

Open
allocz wants to merge 1 commit into
masterfrom
prune_spendjournal_depth
Open

allocz wants to merge 1 commit into
masterfrom
prune_spendjournal_depth

Conversation

@allocz

@allocz allocz commented Jul 27, 2026

Copy link
Copy Markdown
Owner

This patch implements spend journal pruning by deleting spend journal entries older than the default target of 288 entries, this means that we can process up to 288 blocks (~2 days) of chain re-org.

Previously, archival nodes stored all the spend journal entries forever, ~75GiB of the ~90GiB used by leveldb was being used by the spend journal.

This patch makes possible to run archive nodes with better performance in devices constrained in RAM and SSD, by keeping leveldb in a small SSD and the blocks in an HDD.

@allocz

allocz commented Jul 27, 2026

Copy link
Copy Markdown
Owner Author

Note: for nodes with IBD complete, a manual leveldb compaction should be ran to release the storage used by the deleted data.

@allocz
allocz force-pushed the prune_spendjournal_depth branch from 17bf5ee to 78ace52 Compare October 5, 2026 17:18
Previously, archive nodes stored all the spend journal entries forever,
~75GiB of the ~90GiB used by leveldb was being used by the spend
journal.

This patch makes possible to run archive nodes with better performance
in devices constrained in RAM and SSD by keeping leveldb in a small
SSD to reduce IO latency, while keeping the blocks in an HDD (point
--datadir to an HDD with enough available storage to store all blocks,
then move the metadata directory to the SSD and replace it with a
symlink).

spend journal pruning can be enabled with the flag
--prunespendjournal=<pruneDepthBlocks>, where the user can pass a prune
depth of at least 288 blocks, which is enough to handle an unlikely
chain reorg of ~2 days. If a reorg of more than prune depth blocks
happen, a clean IBD is required to reach the chain tip again.

Spend journal pruning is exclusive against cfindex, txindex and
addrindex, this means that at least for now, these indexes must not be
enabled/initialized to enable spend journal pruning.

--prunespendjournal may be passed only once, as the config will be saved
in the database and next btcd initializations will keep pruning the
journal with the last depth passed to --prunespendjournal.

As of now, after enabling spend journal pruning, it can only be disabled
by deleting all node data and performing IBD again.
@allocz
allocz force-pushed the prune_spendjournal_depth branch from 78ace52 to 029c474 Compare November 10, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant