fix(cold-sql): pool starvation and query inefficiencies#45
Merged
Conversation
prestwich
added a commit
to init4tech/node-components
that referenced
this pull request
Apr 3, 2026
Update all signet-storage family crates (signet-storage, signet-cold, signet-hot, signet-hot-mdbx, signet-cold-mdbx, signet-storage-types) to 0.7 from init4tech/storage#45. Bump workspace version to 0.17.1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 tasks
- Add per-backend pool defaults and SqlConnector builder - Add safety checks to integer conversions - Replace get_logs COUNT+SELECT with single LIMIT query - Consolidate get_receipt and batch drain_above - Bump workspace version to 0.7.0 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c4a8b9e to
b513020
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the custom `PoolOverrides` struct and accept `sqlx::pool::PoolOptions<Any>` directly, giving callers the full sqlx pool configuration surface. Only force `max_connections = 1` for in-memory SQLite URLs where per-connection state isolation requires it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add convenience builder methods on SqlConnector for the most common pool settings: max_connections, min_connections, acquire_timeout, max_lifetime, and idle_timeout. The full PoolOptions can still be set via with_pool_options. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use from_i64 for prior_cumulative_gas (was bypassing debug assertion) - Use actual tx_index from DB row instead of enumerate index in drain_above - Read first_log_index from DB instead of recomputing in drain_above - Add debug_assert on gas_used subtraction for corruption detection - Import BTreeMap at file top instead of inline fully-qualified paths - Remove dead r_tx_index column from combined get_receipt query - Extract shared delete_above_in_tx helper from truncate/drain_above Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fraser999
reviewed
Apr 6, 2026
Enhance conformance tests to verify receipt properties that were previously only checked as counts: - test_drain_above: assert transaction_index, first_log_index (via log_index), gas_used, tx_hash, from, block_hash, block_timestamp on all drained receipts across multiple blocks - test_cold_receipt_metadata: verify all fields on get_receipts_in_block results (was only checking gas_used) - test_confirmation_metadata: add tx_hash and from assertions on receipt lookups Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace `r.*` with explicit column lists in `drain_above` and `get_receipts_in_block` to avoid potential column name collisions from the JOIN with the transactions table. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fraser999
approved these changes
Apr 6, 2026
prestwich
added a commit
to init4tech/node-components
that referenced
this pull request
Apr 8, 2026
* chore: bump signet-storage to 0.7 and workspace to 0.17.1 Update all signet-storage family crates (signet-storage, signet-cold, signet-hot, signet-hot-mdbx, signet-cold-mdbx, signet-storage-types) to 0.7 from init4tech/storage#45. Bump workspace version to 0.17.1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: switch signet-storage deps from git to crates.io 0.7 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes ENG-2124
PoolOverrideswithsqlx::pool::PoolOptions<Any>, giving callers the full sqlx pool configuration surface. Only forcemax_connections = 1for in-memory SQLite URLs (where per-connection state isolation requires it); file-backed SQLite and PostgreSQL honor caller-provided options as-is. AddsSqlConnector::with_pool_optionsbuilder method for production tunability.get_logsoptimization: Replace COUNT(*) + SELECT with single LIMIT query — faster in both under-limit and over-limit cases.get_receiptconsolidation: Merge 5 sequential queries (header, receipt+tx, logs, prior gas) into 2-3 via combined JOIN with COALESCE subquery.drain_abovebatch override: Replace default N+1 implementation (3N+7 queries) with batched single-transaction approach (9 queries regardless of block count).to_i64/from_i64, checkedtx_typeconversion throughout.Test plan
cargo t -p signet-cold-sql --all-features— SQLite + PG conformance passingcargo clippy -p signet-cold-sql --all-features --all-targets— cleancargo clippy -p signet-cold-sql --no-default-features --all-targets— cleancargo clippy --workspace --all-features --all-targets— cleancargo +nightly fmt— clean./scripts/test-postgres.sh— PostgreSQL conformance against real databaseReview Fixes
from_i64forprior_cumulative_gasinstead of rawas u64cast (bypassed debug assertion)tx_indexfrom DB row instead of enumerate index indrain_abovefirst_log_indexfrom DB instead of recomputing from log counts indrain_abovedebug_assertongas_usedsubtraction to detect cumulative gas corruptionBTreeMapat file top instead of inline fully-qualified pathsr_tx_indexcolumn from combinedget_receiptquerydelete_above_in_txhelper fromtruncate_above/drain_abovedrain_aboveconformance test (transaction_index, first_log_index, gas_used, tx_hash, from, block metadata)get_receipts_in_blockand receipt lookup conformance assertionsReviewed and updated by Claude Code.
🤖 Generated with Claude Code