Skip to content

Storage cache: Use HashMap, group by ContractId - #1010

Merged
xgreenx merged 3 commits into
masterfrom
dento/storage-map-change
Apr 29, 2026
Merged

xgreenx merged 3 commits into
masterfrom
dento/storage-map-change

Conversation

@Dentosal

@Dentosal Dentosal commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Makes storage cache smaller and faster.

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • If performance characteristic of an instruction change, update gas costs as well or make a follow-up PR for that
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

@Dentosal Dentosal self-assigned this Apr 29, 2026
@cursor

cursor Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches core interpreter storage caching that affects hot/cold read behavior and gas determinism; while mostly a data-structure refactor, incorrect cache updates could change gas charges or storage results.

Overview
Refactors the VM storage_slot_cache from a single BTreeMap<(ContractId, Bytes32), ...> into a nested HashMap<ContractId, HashMap<Bytes32, ...>>, updating all storage read/write/clear paths to use the new grouped layout.

Updates reset_vm_state to correctly reconcile cached storage slots when applying diffs (overwrite stale cached values, convert stale present values to warm-absent None, and preserve cold-absent slots as uncached), and adjusts the diff tests accordingly. Adds a changelog entry documenting the cache change.

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

@Dentosal
Dentosal marked this pull request as ready for review April 29, 2026 14:04
@xgreenx
xgreenx added this pull request to the merge queue Apr 29, 2026
Merged via the queue into master with commit 214a08a Apr 29, 2026
45 checks passed
@xgreenx
xgreenx deleted the dento/storage-map-change branch April 29, 2026 15:33
@github-actions github-actions Bot mentioned this pull request Apr 29, 2026
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.

3 participants