Skip to content

refactor(cold): remove metadata table and consolidate SQL queries#22

Merged
prestwich merged 1 commit intomainfrom
refactor/remove-cold-metadata-consolidate-sql
Feb 12, 2026
Merged

refactor(cold): remove metadata table and consolidate SQL queries#22
prestwich merged 1 commit intomainfrom
refactor/remove-cold-metadata-consolidate-sql

Conversation

@prestwich
Copy link
Member

Summary

  • Remove the metadata table from all three cold storage backends (in-memory, MDBX, SQL). It only tracked latest_block/earliest_block, which are trivially derivable from the headers table. This was dead weight left over from the BlockTag removal in e5f3e05.
  • Consolidate SQL queries in signet-cold-sql:
    • get_transaction: 3 sequential queries → 1 JOIN query
    • get_receipt: 4 sequential queries → 2 (JOIN for receipt+block_hash, separate for logs)
    • get_receipts_in_block: N+1 queries → 2 (batch-fetch all logs for a block)
  • Remove 5 dead helper methods (resolve_tx_spec, resolve_receipt_spec, fetch_tx_by_location, fetch_block_hash, fetch_receipt_by_location)

Net: -235 lines

Test plan

  • cargo +nightly fmt
  • cargo clippy with --all-features and --no-default-features for signet-cold, signet-cold-mdbx, signet-cold-sql
  • cargo t -p signet-cold — in-memory conformance passes
  • cargo t -p signet-cold-mdbx --all-features — MDBX conformance passes
  • cargo t -p signet-cold-sql --all-features — SQLite conformance passes
  • ./scripts/test-postgres.sh — PostgreSQL conformance passes

🤖 Generated with Claude Code

The metadata table only tracked latest_block, which is trivially
derivable from the headers table. Remove it from all three backends
(in-memory, MDBX, SQL) and derive get_latest_block from headers
directly.

Additionally consolidate SQL queries in the cold-sql backend:
- get_transaction: use JOINs to fetch tx + block_hash in one query
- get_receipt: use JOINs to fetch receipt + block_hash in one query
- get_receipts_in_block: fix N+1 by batch-fetching all logs for a
  block instead of per-receipt
- Remove 5 dead helper methods made redundant by the consolidation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@prestwich prestwich merged commit a71ba60 into main Feb 12, 2026
6 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