Skip to content

feat(cold): add max_logs parameter to get_logs#29

Merged
prestwich merged 4 commits intomainfrom
feat/get-logs-max-limit
Feb 14, 2026
Merged

feat(cold): add max_logs parameter to get_logs#29
prestwich merged 4 commits intomainfrom
feat/get-logs-max-limit

Conversation

@prestwich
Copy link
Member

Summary

  • Add max_logs: usize parameter to ColdStorage::get_logs trait method to cap result sets and prevent unbounded memory usage from wide eth_getLogs queries
  • All backends short-circuit early: in-memory/MDBX break out of the log loop at the limit, SQL appends LIMIT $N to the query
  • Bump workspace version to 0.5.0

Test plan

  • cargo clippy for signet-cold, signet-cold-mdbx, signet-cold-sql with --all-features and --no-default-features
  • cargo t -p signet-cold (in-memory conformance)
  • cargo t -p signet-cold-mdbx --all-features (MDBX conformance)
  • cargo t -p signet-cold-sql --all-features (SQLite conformance)
  • ./scripts/test-postgres.sh (PostgreSQL conformance)
  • New conformance test verifies max_logs=2 returns exactly 2 logs in correct order

🤖 Generated with Claude Code

prestwich and others added 4 commits February 14, 2026 10:55
Add a `max_logs: usize` parameter to `ColdStorage::get_logs` to cap
result sets at the trait level, preventing unbounded memory usage from
wide `eth_getLogs` queries.

Backend implementations short-circuit early:
- In-memory/MDBX: break out of the log collection loop at the limit
- SQL: appends `LIMIT $N` to let the database engine stop scanning

Bump workspace version to 0.5.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change `get_logs` semantics: return `TooManyLogs` error when the query
would produce more than `max_logs` results instead of silently
truncating. Each backend checks efficiently:

- In-memory: returns error as soon as count exceeds limit
- MDBX: collects up to max_logs+1, async wrapper checks and errors;
  also drains logs via `into_iter()` instead of cloning (ir is owned)
- SQL: runs a cheap `COUNT(*)` query first, errors before fetching rows

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the TooManyLogs check into the inner log collection loop so we
bail out as soon as the limit is reached instead of collecting all
results first.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@prestwich prestwich merged commit 09b3801 into main Feb 14, 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