Skip to content

fix: lower sei-cosmos pagination query MaxLimit to 10,000#3494

Open
amir-deris wants to merge 2 commits into
mainfrom
amir/plt-361-lower-sei-cosmos-pagination-query-limit
Open

fix: lower sei-cosmos pagination query MaxLimit to 10,000#3494
amir-deris wants to merge 2 commits into
mainfrom
amir/plt-361-lower-sei-cosmos-pagination-query-limit

Conversation

@amir-deris
Copy link
Copy Markdown
Contributor

@amir-deris amir-deris commented May 21, 2026

Summary

  • Lowers MaxLimit in sei-cosmos/types/query/pagination.go from math.MaxUint64 to 10_000 to cap the number of items a paginated RPC query can request in a single call, preventing unbounded scans that can degrade node performance.
  • Updates internal callers in x/bank (ExportGenesis, TotalSupply invariant) that legitimately need to iterate all supply entries to pass math.MaxUint64 directly, preserving their existing behavior.

Test plan

  • Confirm paginated RPC queries with a limit above 10,000 are rejected or clamped
  • Confirm ExportGenesis and TotalSupply invariant still work correctly on a node with many token denominations

@amir-deris amir-deris self-assigned this May 21, 2026
@amir-deris amir-deris changed the title Updated max limit for sei_cosmos query pagination fix: lower sei-cosmos pagination query MaxLimit to 10,000 May 21, 2026
@cursor
Copy link
Copy Markdown

cursor Bot commented May 21, 2026

PR Summary

Medium Risk
Medium risk because it changes public query behavior by rejecting large limit values, which can break existing clients that request very high limits. Bank genesis export and invariants are adjusted to avoid the new cap, reducing runtime risk there.

Overview
Capped query pagination by lowering query.MaxLimit to 10_000 and adding a guard in query.Paginate that returns InvalidArgument when a request exceeds the cap.

Updated bank module callers (ExportGenesis and TotalSupply invariant) to compute total supply via IterateTotalSupply rather than GetPaginatedTotalSupply with an effectively-unbounded limit, avoiding failures under the new pagination restriction.

Reviewed by Cursor Bugbot for commit d5241fa. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 21, 2026, 11:28 PM

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit da36bbb. Configure here.

// MaxLimit is the maximum limit the paginate function can handle
// which equals the maximum value that can be stored in uint64
const MaxLimit = math.MaxUint64
const MaxLimit = uint64(10_000)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test still uses reduced MaxLimit constant

Medium Severity

Reducing query.MaxLimit from math.MaxUint64 to uint64(10_000) affects genesis_test.go line 123, which still uses query.MaxLimit to fetch all supply entries. The production code in genesis.go and invariants.go was correctly updated to use math.MaxUint64 directly, but the test was missed. If test data ever exceeds 10,000 denominations, the test would silently return truncated results and could produce false-passing assertions.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit da36bbb. Configure here.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 63.15789% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.08%. Comparing base (ef425cc) to head (d5241fa).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sei-cosmos/x/bank/keeper/invariants.go 0.00% 5 Missing ⚠️
sei-cosmos/types/query/pagination.go 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3494   +/-   ##
=======================================
  Coverage   59.08%   59.08%           
=======================================
  Files        2187     2187           
  Lines      182237   182249   +12     
=======================================
+ Hits       107679   107689   +10     
- Misses      64911    64914    +3     
+ Partials     9647     9646    -1     
Flag Coverage Δ
sei-chain-pr 77.56% <63.15%> (?)
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-cosmos/x/bank/keeper/genesis.go 81.63% <100.00%> (+5.03%) ⬆️
sei-cosmos/types/query/pagination.go 82.95% <77.77%> (-0.59%) ⬇️
sei-cosmos/x/bank/keeper/invariants.go 47.36% <0.00%> (-3.99%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant