fix(store): detect single-block overflow in reconstruct_storage_map_from_db#1824
Closed
mmagician wants to merge 4 commits into0xMiden:release/v0.14.0-alphafrom
Closed
Conversation
…rom_db The previous pagination fix in `select_account_storage_map_values_paged` correctly signals "no progress" by returning empty values when a single block exceeds the entry limit. But the caller (`reconstruct_storage_map_from_db`) didn't detect this because the loop exits at the top when `last_block_included == block_num` (both 0 for genesis), before reaching the progress check inside the loop body. This resulted in returning `AllEntries([])` instead of `LimitExceeded`, causing the client to import genesis accounts with empty storage maps. Add an early check after the first page: if no values were returned and we didn't advance past the starting block, the block has more entries than the limit allows, so return `LimitExceeded`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bbdcd9e to
a9bb1e4
Compare
…tion Replace `last_block_num.saturating_sub(1)` with reading block_num from the last kept `AccountVaultValue`. Same approach as the storage map fix in 0xMiden#1816. No unit test added because `select_account_vault_assets` uses a hardcoded `MAX_ROWS` (~61k) derived from `MAX_RESPONSE_PAYLOAD_BYTES`, making it impractical to trigger the overflow in a test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…pagination Replace `last_block_num.saturating_sub(1)` with reading block_num from the last kept `TransactionRecordRaw`. Same approach as the storage map fix in 0xMiden#1816. This is unlikely to be triggered in practice (genesis blocks don't have transactions, and a single non-genesis block is unlikely to exceed the 4MB size-based limit), but we fix it for consistency and safety. No unit test added because the function uses `MAX_RESPONSE_PAYLOAD_BYTES` (4MB) as the size limit, making it impractical to trigger in a test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…agination Replace `last_created_at_block.saturating_sub(1)` with a backward scan to find the last kept row's block number. Uses reverse iteration to avoid an extra allocation (AccountId has no block_num field, so we can't use the single-pass approach from the other fixes). No unit test added because the function uses a hardcoded MAX_ROWS (~61k) that is impractical to trigger in a test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
superseded by #1825 |
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
select_account_storage_map_values_pagedreconstruct_storage_map_from_db(the caller) doesn't detect itlast_block_included == block_num(both 0 for genesis), before reaching the progress check inside the loop bodyAllEntries([])instead ofLimitExceeded, causing the client to import genesis accounts with empty storage mapsLimitExceededTest plan
reconstruct_storage_map_from_db_returns_limit_exceeded_for_genesis_overflowthat fails without the fix (AllEntries([])) and passes with it (LimitExceeded)miden-node-storetest suite passes (124 tests)import_account_with_large_storage_mapimports the genesis test account with 2000 storage map entries🤖 Generated with Claude Code