Skip to content

refactor(storage): dedup blocks/states keep-roots pruning branch#969

Merged
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:audit/arch-09-dedup-sqlite-keep-roots
Jun 12, 2026
Merged

refactor(storage): dedup blocks/states keep-roots pruning branch#969
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:audit/arch-09-dedup-sqlite-keep-roots

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

Summary

The pruning routine in the SQLite storage backend repeated identical keep-roots delete logic for the blocks and states tables, differing only in the table name. Since both tables share the same root and slot columns, this collapses the two branches into a single nested helper parameterized by table name.

  • Extracts the slot-threshold delete (with the kept-roots exclusion) into one helper, routing both the blocks and states branches through it.
  • Preserves exact SQL semantics: the same NOT IN exclusion is built when roots are kept, and the clause is omitted for an empty keep set to avoid invalid empty parentheses.
  • The trailing slot-index prune is unchanged.

Testing

  • uv run pytest tests/node/storage/test_sqlite.py — 36 passed.
  • just check — clean (lint, format, typecheck, spell, mdformat, lock).

🤖 Generated with Claude Code

The pruning routine repeated identical keep-roots delete logic for the
blocks and states tables, differing only in the table name. Both tables
share the same root and slot columns, so route both through a single
nested helper parameterized by table name. SQL semantics are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger merged commit 625a355 into leanEthereum:main Jun 12, 2026
14 checks passed
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