Skip to content

[bal-devnet-3] --exec.no-prune now disables all DB pruning#20914

Merged
mh0lt merged 1 commit intobal-devnet-3from
fix/exec-no-prune-cover-all
Apr 29, 2026
Merged

[bal-devnet-3] --exec.no-prune now disables all DB pruning#20914
mh0lt merged 1 commit intobal-devnet-3from
fix/exec-no-prune-cover-all

Conversation

@mh0lt
Copy link
Copy Markdown
Contributor

@mh0lt mh0lt commented Apr 29, 2026

Summary

`--exec.no-prune` previously only gated the state-aggregator's pruning paths via `dbg.NoPrune()` (Domain/InvertedIndex in `db/state/aggregator.go`, forkable in `db/state/forkable_agg.go`). Stage-level pruning ran regardless:

  • `PruneExecutionStage` was calling `rawdb.PruneTable` on `kv.ChangeSets3` and `kv.BlockAccessList`.
  • `PruneTxLookup`, `PruneWitnessProcessingStage` and `SnapshotsPrune` (`PruneAncientBlocks`, `pruneCanonicalMarkers`, `RetireBlocksInBackground`, `pruneBlockSnapshots`) had no guard.

The most disruptive case for bal-devnet-3 testing: BAL rows were being deleted every step once `ForwardProgress > MaxReorgDepth`, even with the flag set.

Fix

Add early-return guards on `dbg.NoPrune()` at the top of each stage prune entrypoint so the flag genuinely blocks every path that removes rows from MDBX. Each function still calls `s.Done(tx)` so the staged-sync state machine doesn't re-enter the prune step on every cycle.

Updated flag usage text to describe the wider semantic.

Test plan

  • `go test ./execution/stagedsync -run TestNoPrune` — new `no_prune_test.go` seeds rows in `kv.ChangeSets3`, `kv.BlockAccessList`, `kv.TxLookup`, `kv.BorWitnesses`; runs all four prune entrypoints with `NoPrune=true`; asserts no rows deleted and `PruneProgress` is recorded.
  • `make lint` — clean.
  • `make erigon` — builds.

…isables all DB pruning

The --exec.no-prune flag previously only gated the state-aggregator's
Domain/InvertedIndex/forkable pruning via dbg.NoPrune(). Stage-level
pruning ran regardless: PruneExecutionStage was still calling
rawdb.PruneTable on kv.ChangeSets3 and kv.BlockAccessList, and
PruneTxLookup, PruneWitnessProcessingStage and SnapshotsPrune were
fully active. Most relevant for bal-devnet-3 testing: BAL rows were
being deleted every step once ForwardProgress > MaxReorgDepth, even
with the flag set.

Add early-return guards on dbg.NoPrune() at the top of each prune
entrypoint so the flag genuinely blocks every path that removes rows
from MDBX. Bookkeeping (s.Done) still fires so the staged-sync state
machine doesn't re-enter the prune step on every cycle.

New test no_prune_test.go seeds rows in the affected tables, runs all
four prune entrypoints with NoPrune=true, and asserts no rows were
deleted plus PruneProgress is recorded.
@mh0lt mh0lt merged commit 671ece6 into bal-devnet-3 Apr 29, 2026
1 check failed
@mh0lt mh0lt deleted the fix/exec-no-prune-cover-all branch April 29, 2026 15:25
yperbasis pushed a commit to Sahil-4555/erigon that referenced this pull request Apr 30, 2026
…pruning (erigontech#20915)

## Summary

\`--exec.no-prune\` previously only gated the state-aggregator's pruning
paths via \`dbg.NoPrune()\` (Domain/InvertedIndex in
\`db/state/aggregator.go\`, forkable in \`db/state/forkable_agg.go\`).
Stage-level pruning ran regardless:

- \`PruneExecutionStage\` was calling \`rawdb.PruneTable\` on
\`kv.ChangeSets3\` and \`kv.BlockAccessList\`.
- \`PruneTxLookup\`, \`PruneWitnessProcessingStage\` and
\`SnapshotsPrune\` (\`PruneAncientBlocks\`, \`pruneCanonicalMarkers\`,
\`RetireBlocksInBackground\`, \`pruneBlockSnapshots\`) had no guard.

## Fix

Add early-return guards on \`dbg.NoPrune()\` at the top of each stage
prune entrypoint so the flag genuinely blocks every path that removes
rows from MDBX. Each function still calls \`s.Done(tx)\` so the
staged-sync state machine doesn't re-enter the prune step on every
cycle.

Updated flag usage text to describe the wider semantic.

Companion bal-devnet-3 PR: erigontech#20914

## Test plan

- [x] \`go test ./execution/stagedsync -run TestNoPrune\` — new
\`no_prune_test.go\` seeds rows in \`kv.ChangeSets3\`,
\`kv.BlockAccessList\`, \`kv.TxLookup\`, \`kv.BorWitnesses\`; runs all
four prune entrypoints with \`NoPrune=true\`; asserts no rows deleted
and \`PruneProgress\` is recorded.
- [x] \`make lint\` — clean.
- [x] \`make erigon\` — builds.

Co-authored-by: Alex Sharov <AskAlexSharov@gmail.com>
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