Skip to content

Conversation

@pthmas
Copy link
Contributor

@pthmas pthmas commented Jan 16, 2026

Overview

  • Adds a height-based pruning mechanism to the ev-node store:
    • Prunes /h/{height}, /d/{height}, /c/{height}, /i/{hash} up to a target height.
    • Also prunes per-height DA metadata (height → DA height mapping) for pruned heights.
    • Leaves /s/{height} (state), /t (current height), and global metadata keys untouched.
    • Tracks progress via a last-pruned-block-height metadata key so pruning is monotonic and idempotent.
  • Integrates pruning into block production:
    • After a block is committed, at configurable intervals, the executor computes a prune target and calls store.PruneBlocks synchronously.
    • The prune target is additionally capped by the DA-included height (DAIncludedHeightKey), so only blocks that are known to be DA-included are ever pruned; if no DA-included height is known yet, pruning is skipped.
  • Wires pruning into the go-header store:
    • Sets the go-header pruning window to PruningKeepRecent * BlockTime so header/data retention matches ev-node’s window.
  • Adds pruning for execution metadata:
    • Execution stores (EVM, ev-abci, etc.) expose PruneExecMeta to delete per-height ExecMeta entries up to a target height.
    • The executor implements an optional ExecMetaPruner interface, and the block executor calls it from the same pruning hook.
    • Execution environments that do not (yet) implement ExecMetaPruner are unaffected.

Config

New node config fields / flags:

  • --evnode.node.pruning_enabled
  • --evnode.node.pruning_keep_recent
  • --evnode.node.pruning_interval

Pruning actually runs only when all three are set to non-trivial values (enabled, keep_recent > 0, interval > 0).

Design trade-offs

  • Runs in the critical path:
    Pruning is called synchronously in produceBlock. On pruning heights, block production will incur extra latency proportional to the amount of data pruned and underlying storage performance.

  • Best-effort pruning:
    If pruning fails, we log the error but do not fail the block. This avoids halting the node but means disk usage can grow silently if pruning keeps failing; operators will need to watch logs/metrics.

  • Scope:
    This PR prunes ev-node’s own store, the go-header store, and execution metadata via the ExecMetaPruner hook.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedFeb 2, 2026, 5:09 PM

@claude
Copy link
Contributor

claude bot commented Jan 16, 2026

Code Review in Progress

Performing comprehensive code review of the block pruning feature.

Review Checklist

  • Read and analyze core pruning logic (store.go)
  • Review executor integration and critical path impact
  • Examine configuration and validation
  • Assess EVM store pruning implementation
  • Review error handling and resilience patterns
  • Evaluate test coverage and identify gaps
  • Check DA-included height safety mechanism
  • Address go-header store obsolescence concern
  • Provide final recommendations

View job run

Copy link
Member

@julienrbrt julienrbrt Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we have a lot of different stores and keys. Are we planning to prune as well:

(and eventually ev-abci store)

It will be inconsistent if we don't allow height pruning of all those stores (at once).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this PR to prune metadats, go-header store and evm store ✅
I'm happy to work on prunning ev-abci next, but I would probably do it in another PR to prevent this PR from getting too big if that's ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Now you can delete the go-header store pruning and rebase to main :p
We do not use that store at all now thanks to #3036.

@pthmas pthmas changed the title Block Prunning feat: block Prunning Jan 26, 2026
@pthmas pthmas changed the title feat: block Prunning feat: block Pruning Jan 26, 2026
@pthmas pthmas force-pushed the pierrick/prunning branch from 3e1e8e0 to ed66fe6 Compare January 26, 2026 15:01
@pthmas pthmas force-pushed the pierrick/prunning branch 7 times, most recently from 26628f5 to 4d65b1e Compare January 28, 2026 15:41
@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

❌ Patch coverage is 20.73171% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.37%. Comparing base (4252154) to head (4d65b1e).

Files with missing lines Patch % Lines
pkg/store/store.go 20.00% 24 Missing and 12 partials ⚠️
pkg/store/tracing.go 0.00% 11 Missing ⚠️
block/internal/executing/executor.go 0.00% 8 Missing and 1 partial ⚠️
pkg/config/config.go 37.50% 4 Missing and 1 partial ⚠️
pkg/sync/sync_service.go 33.33% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2984      +/-   ##
==========================================
- Coverage   55.55%   55.37%   -0.18%     
==========================================
  Files         116      116              
  Lines       11477    11557      +80     
==========================================
+ Hits         6376     6400      +24     
- Misses       4401     4439      +38     
- Partials      700      718      +18     
Flag Coverage Δ
combined 55.37% <20.73%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pthmas pthmas force-pushed the pierrick/prunning branch from f16d3b4 to 5fb8e87 Compare February 2, 2026 17: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.

4 participants