celestia-node icon indicating copy to clipboard operation
celestia-node copied to clipboard

feat(pruner): Implement `full` and `bridge` node pruning

Open renaynay opened this issue 1 year ago • 3 comments

This PR introduces full and bridge node pruning via the --experimental-pruning flag. Support is included for nodes that start from scratch with pruning enabled and also for archival (nodes retaining all historical blocks) that enable the --experimental-pruning flag.

Note that this PR does not support the conversion of a pruned node into an archival one explicitly (it would not support re-syncing deleted blocks).

With pruning enabled, full and bridge nodes' block stores can be expected not to exceed ~4TB (as the upper bound).

In follow-up PRs (hardening), the following features can be expected:

  • [ ] discovery for archival nodes for archival sync
  • [ ] inverted_index / light node pruning
  • [ ] include more metrics for errors

TODO:

  • [x] clean up some TODOs
  • [x] fix one flakey unit test
  • [x] change values back to the actual (GC cycle, sampling window, pruning window, etc).
  • [x] figure out whether to store error in pruner checkpoint
  • [x] fix issue with pruning genesis block via findPruneableHeaders
  • [x] metrics for failed prunes
  • [x] set a sane default for max pruneable / consider removing MaxPruneablePerGC as now context timeouts are on a per block basis
  • [ ] dedup findPruneableHeader test utility
  • [x] badger dep

renaynay avatar Jan 31 '24 15:01 renaynay

Codecov Report

Attention: Patch coverage is 60.08584% with 93 lines in your changes are missing coverage. Please review.

Project coverage is 52.89%. Comparing base (1809680) to head (5918f6d). Report is 6 commits behind head on main.

Files Patch % Lines
pruner/metrics.go 9.09% 30 Missing :warning:
pruner/service.go 73.80% 18 Missing and 4 partials :warning:
cmd/util.go 0.00% 14 Missing :warning:
pruner/checkpoint.go 71.87% 5 Missing and 4 partials :warning:
pruner/finder.go 83.78% 3 Missing and 3 partials :warning:
header/headertest/testing.go 72.22% 4 Missing and 1 partial :warning:
pruner/params.go 54.54% 5 Missing :warning:
cmd/node.go 0.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3150      +/-   ##
==========================================
+ Coverage   51.92%   52.89%   +0.97%     
==========================================
  Files         178      183       +5     
  Lines       11316     9539    -1777     
==========================================
- Hits         5876     5046     -830     
+ Misses       4942     3980     -962     
- Partials      498      513      +15     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Feb 22 '24 12:02 codecov-commenter

TODO @renaynay:

add some protection in finder.go to prevent

2024-02-28T16:10:59.333+0100	ERROR	pruner/service	pruner/service.go:129	failed to find prune-able blocks	{"error": "header/store: invalid range(26625,26624)"}

(can sometimes happen but is non-critical error, just ugly)

renaynay avatar Feb 28 '24 15:02 renaynay

@renaynay, there is a little conflict fyi

Wondertan avatar Mar 11 '24 12:03 Wondertan