[PLT-700] Add MaxTxSearchResults cap to tx_search and block_search#3608
[PLT-700] Add MaxTxSearchResults cap to tx_search and block_search#3608amir-deris wants to merge 5 commits into
Conversation
Adds a `max-tx-search-results` config field to RPCConfig (default 10,000) and applies it in TxSearch and BlockSearch before pagination, preventing unbounded result sets from materialising in memory on index-heavy queries. Context propagation from the HTTP request through to the KV scan loops was already wired correctly; no changes needed there. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR SummaryMedium Risk Overview
Unit tests cover post-sort truncation, disabled cap, and when matches are under the limit. Reviewed by Cursor Bugbot for commit 6008230. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 146439f. Configure here.
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Cap applied before sort caused TxSearch to return an arbitrary subset of matches instead of the top N by order_by, and BlockSearch with order_by=desc to omit the newest blocks entirely (indexer returns heights ascending). Move the cap to after sort and before pagination so the truncation always preserves the correct ordering intent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3608 +/- ##
==========================================
- Coverage 59.02% 58.14% -0.88%
==========================================
Files 2215 2141 -74
Lines 182521 173981 -8540
==========================================
- Hits 107734 101167 -6567
+ Misses 65091 63819 -1272
+ Partials 9696 8995 -701
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…Search Covers three cases each: cap applied after sort (the ordering-correctness invariant the cursor bot flagged), cap disabled (MaxTxSearchResults=0), and results under the cap (full set returned unchanged). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Summary
MaxTxSearchResultsfield toRPCConfig(default 10,000) with mapstructure tagmax-tx-search-resultsTxSearchandBlockSearchafter sort and before pagination — preservingorder_bycorrectness while bounding response size and pagination workDefaultRPCConfig(),ValidateBasic(), and the toml templatectx.Done()checks) was already wired correctly; no changes needed thereAPI note
total_countnow reflects the capped result set (min(matches, max-tx-search-results)), not the true match cardinality above the limit. Clients that need the full match count must use narrower queries or a dedicated indexer.Files changed
sei-tendermint/config/config.go— new field + default + validationsei-tendermint/config/toml.go— template entrysei-tendermint/internal/rpc/core/env.go— debug log helper for cap truncationsei-tendermint/internal/rpc/core/tx.go— cap applied inTxSearchsei-tendermint/internal/rpc/core/blocks.go— cap applied inBlockSearchsei-tendermint/internal/rpc/core/tx_test.go— unit testssei-tendermint/internal/rpc/core/block_search_test.go— unit testsFollow-up
The RPC-layer cap does not bound KV indexer memory/CPU: the indexer still materialises and RPC still sorts the full match set before truncation.
Test plan
go test ./sei-tendermint/config/... ./sei-tendermint/internal/rpc/core/... -run 'TestRPCConfigValidateBasic|TestTxSearchCap|TestBlockSearchCap'passesmax-tx-search-results = 0to disable the cap if needed