Skip to content

fix(provider): respect changeset range bounds - #28601

Queued
0xKarl98 wants to merge 4 commits into
mainfrom
0xKarl98/changeset-ranges
Queued

0xKarl98 wants to merge 4 commits into
mainfrom
0xKarl98/changeset-ranges

Conversation

@0xKarl98

Copy link
Copy Markdown
Collaborator

Account and storage changeset ranges can omit the last block on disk and include in-memory blocks outside the requested range. Read through the disk anchor, then append only the matching in-memory blocks in ascending order. Preserve inclusive and unbounded endpoints through u64::MAX. This is the range-query portion of #28599.

Include the last block on disk when combining account or storage changesets with the in-memory chain. Append only the requested in-memory blocks in ascending order and preserve inclusive bounds through the largest block number.
@0xKarl98 0xKarl98 added the C-bug An unexpected or incorrect behavior label Nov 18, 2026
@tempoxyz-bot

tempoxyz-bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

👁️ Cyclops Security Review

✅ Reviewed c655207 (latest) · Coverage: partial · no open findings · report
⚠️ Not checked: Changeset range bound handling and the disk/memory merge in ConsistentProvider, DatabaseProvider, StaticFileProvider and the walkers: ruled out without reading the cited code at this commit
⚠️ Not checked: Incremental push: account ownership in the range test: ruled out without reading the cited code at this commit
⚠️ Not checked: Consistent account and storage range split: dropped anchor, duplicate rows, and prune bypass: ruled out without reading the cited code at this commit

# Severity Finding Introduced Status
1 🟢 Low Storage-v2 changeset range reads overflow at a u64::MAX segment tip b91a0aa ✅ Fixed in 55b8055

Iterate the inclusive block range so both static-file walkers return the final block and finish without computing its successor. Exercise the storage-v2 read path with indexed account and storage changesets in the last two blocks.

@mattsse mattsse left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice fixes. Capping the database read at the first in-memory block instead of anchor().number no longer drops the last persisted block. In-memory blocks are now filtered to the requested range, and changeset_block_range handles ..0, ..=u64::MAX and Excluded(u64::MAX) without overflowing. Dropping the stable sort is safe because database-then-reversed-memory output is already ordered. mablr's open notes are worth folding in but not blocking: changesets_range repeats the bound normalisation, and the in-memory test would benefit from a second block to cover a range ending inside memory and an excluded start. LGTM.

Avoid overflowing composite storage keys at the last block in MDBX. Use the shared inclusive range conversion for account and disk/memory reads, and cover direct storage reads and ordering across two in-memory blocks.
Account loses Copy when account-ext is enabled. Clone each owned snapshot in the two-block changeset test so it builds with all workspace features.
@0xKarl98
0xKarl98 added this pull request to the merge queue Nov 19, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

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

Labels

C-bug An unexpected or incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants