Skip to content

blockifier,apollo_batcher: trim OS initial reads to the accessed-key set#14595

Merged
yoavGrs merged 1 commit into
mainfrom
yoav/thread-os-initial-reads-to-cende
Jun 24, 2026
Merged

blockifier,apollo_batcher: trim OS initial reads to the accessed-key set#14595
yoavGrs merged 1 commit into
mainfrom
yoav/thread-os-initial-reads-to-cende

Conversation

@yoavGrs

@yoavGrs yoavGrs commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Drop initial-reads entries whose keys are not in AccessedKeys (e.g. storage cells read only by a reverted transaction). The OS replays from the read values of the keys it accesses and needs nothing beyond that set, so the extra entries would only bloat the cende blob. Validated by the OS flow tests (113 passing), including all reverted-tx cases.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

yoavGrs commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

@yoavGrs yoavGrs marked this pull request as ready for review June 22, 2026 11:57
@cursor

cursor Bot commented Jun 22, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes what data is shipped for OS replay; incorrect trimming could break OS correctness, but scope is limited to filtering existing reads and is covered by OS flow tests including reverted transactions.

Overview
OS initial reads are filtered to the accessed-key set so payloads no longer carry pre-block values for keys the OS never touches (notably reads from reverted transactions).

StateMaps gains trim_to_accessed_keys, which keeps storage, nonce, class-hash, and compiled-class-hash entries only when their keys appear in AccessedKeys.

In decision_reached (with os_input), the batcher builds accessed_keys, trims initial_reads, and passes the trimmed map in CentralObjects instead of the full execution cache.

OS flow tests apply the same trim before assembling block OS input, matching production and exercising reverted-tx cases.

A small committer comment clarifies the os_input vs non-os_input CommitterRequest surface.

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

@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from baca9cc to c0904c6 Compare June 22, 2026 14:02
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-3-flow-tests branch from f4a9965 to 94b61d9 Compare June 22, 2026 14:02
@yoavGrs yoavGrs requested a review from itamar-starkware June 22, 2026 14:41
@yoavGrs yoavGrs self-assigned this Jun 22, 2026
@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from c0904c6 to 28dc2c0 Compare June 23, 2026 07:21
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-3-flow-tests branch from 94b61d9 to 4cc1677 Compare June 23, 2026 07:21
@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from 28dc2c0 to 840c728 Compare June 23, 2026 08:56
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-3-flow-tests branch from 4cc1677 to 5410333 Compare June 23, 2026 08:56
@itamar-starkware

itamar-starkware commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Suggestion from Claude Code:

Could we add direct unit tests in cached_state_test.rs?

  • trim_to_accessed_keys: build a StateMaps with entries across all four maps plus extras absent from accessed_keys; assert the extras are dropped and the hits retained. Cover empty accessed_keys → all empty, and pin the declared_contracts pass-through (it's not trimmed — intentional only because get_os_initial_reads pre-clears it; worth asserting so a future pub caller doesn't get surprised). The test_state_maps helper (~line 700) has the construction pattern.
  • get_os_initial_reads: assert the three back-fills (class-hash + nonce per accessed contract, compiled-class-hash per declared class) land, and that declared_contracts comes back cleared.

@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from 840c728 to 41b34a9 Compare June 23, 2026 10:41
@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from 41b34a9 to f334583 Compare June 23, 2026 13:31
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-3-flow-tests branch from 5410333 to 9d4eabf Compare June 23, 2026 13:31
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-3-flow-tests branch from 9d4eabf to d57b5a2 Compare June 23, 2026 14:42
@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from f334583 to c7678fc Compare June 23, 2026 14:42
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-3-flow-tests branch from d57b5a2 to 9863839 Compare June 23, 2026 18:32
@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from c7678fc to d865f09 Compare June 23, 2026 18:32

@itamar-starkware itamar-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@itamar-starkware reviewed 4 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on yoavGrs).

@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from d865f09 to 89077d2 Compare June 24, 2026 08:26
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-3-flow-tests branch from 9863839 to 3f9bc02 Compare June 24, 2026 08:26
@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from 89077d2 to f85eb08 Compare June 24, 2026 08:57
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-3-flow-tests branch from 3f9bc02 to af1d0d4 Compare June 24, 2026 08:57
@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from f85eb08 to 32d8ff2 Compare June 24, 2026 09:07
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-3-flow-tests branch 2 times, most recently from e1f8308 to d493b74 Compare June 24, 2026 09:54
@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from 32d8ff2 to eeea13b Compare June 24, 2026 09:54
@yoavGrs yoavGrs changed the base branch from yoav/os-initial-reads-3-flow-tests to graphite-base/14595 June 24, 2026 10:26
@yoavGrs yoavGrs force-pushed the graphite-base/14595 branch from d493b74 to a3a16c7 Compare June 24, 2026 10:26
@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from eeea13b to ec51fe6 Compare June 24, 2026 10:27
@yoavGrs yoavGrs changed the base branch from graphite-base/14595 to main June 24, 2026 10:27
Drop initial-reads entries whose keys are not in AccessedKeys (e.g. storage cells read only by a reverted transaction). The OS replays from the read values of the keys it accesses and needs nothing beyond that set, so the extra entries would only bloat the cende blob. Validated by the OS flow tests (113 passing), including all reverted-tx cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yoavGrs yoavGrs force-pushed the yoav/thread-os-initial-reads-to-cende branch from ec51fe6 to ba1162c Compare June 24, 2026 13:07

@yoavGrs yoavGrs left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@yoavGrs reviewed 2 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on yoavGrs).

@yoavGrs yoavGrs added this pull request to the merge queue Jun 24, 2026
Merged via the queue into main with commit 89e663a Jun 24, 2026
40 of 43 checks passed

Copy link
Copy Markdown
Contributor

Security scan complete — no issues detected.


Generated by Claude Code

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.

4 participants