Skip to content

fix(store): handle AllEntries pagination for genesis block storage maps#1816

Draft
mmagician wants to merge 2 commits into0xMiden:nextfrom
mmagician:mmagician-claude/fix-allentries-genesis
Draft

fix(store): handle AllEntries pagination for genesis block storage maps#1816
mmagician wants to merge 2 commits into0xMiden:nextfrom
mmagician:mmagician-claude/fix-allentries-genesis

Conversation

@mmagician
Copy link
Contributor

Summary

  • Fixes a bug where GetAccount RPC with AllEntries(true) returns an internal error for storage maps with entries exceeding the pagination limit when all entries are in genesis block 0
  • Root cause: select_account_storage_map_values_paged computes last_block_num.saturating_sub(1) = -1 (i64) when all entries share the same block, which fails BlockNumber::from_raw_sql
  • Fix: when take_while yields empty results (single-block overflow), return block_range.start() to signal no pagination progress, triggering limit_exceeded in the caller

Discovered via 0xMiden/miden-client#1926

Test plan

  • Added test select_storage_map_sync_values_all_entries_in_genesis_block that reproduces the bug (fails without fix, passes with fix)
  • Full miden-node-store test suite passes (121 tests)

🤖 Generated with Claude Code

claude added 2 commits March 21, 2026 11:07
…sis block

When all storage map entries exceed the pagination limit and reside in
a single block (e.g. genesis block 0), `take_while` produces empty
results since all rows share the same block_num. Previously this led
to `last_block_num.saturating_sub(1)` = -1 (i64) which failed
BlockNumber::from_raw_sql, returning an internal error to the client.

Now when take_while yields no values (all entries in one block), we
return block_range.start() as last_block_included with empty values.
The caller (reconstruct_storage_map_from_db) interprets this as no
pagination progress and returns limit_exceeded, which is the correct
response for maps exceeding the entry limit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants