Skip to content

blockifier,apollo_batcher: produce OS initial reads behind os_input#14592

Open
yoavGrs wants to merge 1 commit into
mainfrom
yoav/os-initial-reads-1-produce
Open

blockifier,apollo_batcher: produce OS initial reads behind os_input#14592
yoavGrs wants to merge 1 commit into
mainfrom
yoav/os-initial-reads-1-produce

Conversation

@yoavGrs

@yoavGrs yoavGrs commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Add an os_input feature on blockifier and, behind it, compute the pre-block OS read values (CachedState::get_os_initial_reads) in finalize_block, expose them on BlockExecutionSummary/BlockExecutionArtifacts, and carry them into the batcher's CentralObjects decision-reached response. Not yet consumed downstream.

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

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

@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 block-close state extraction and enlarges consensus-facing payloads, but behavior is feature-gated and initial_reads is not yet used by downstream OS consumers.

Overview
Behind a new blockifier os_input feature (wired through apollo_batcher and CI), block finalization now builds pre-block StateMaps for Starknet OS replay via CachedState::get_os_initial_reads, which back-fills write-only storage, force-reads contract/class trie leaves, and drops declared_contracts.

Those values are attached to BlockExecutionSummary, carried in BlockExecutionArtifacts, and returned on CentralObjects.initial_reads in the decision_reached response alongside existing accessed_keys. Nothing downstream consumes initial_reads yet.

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

Comment thread crates/apollo_batcher/src/block_builder_test.rs
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-1-produce branch from 2eba218 to 94cf5bb Compare June 22, 2026 14:02
@yoavGrs yoavGrs requested a review from itamar-starkware June 22, 2026 14:42

@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.

There is one comment about the feature flag removal. Consider split to more PRs to handle this design issue.

Comment thread crates/blockifier/src/state/cached_state.rs
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-1-produce branch from 94cf5bb to c52efb3 Compare June 23, 2026 07:21

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c52efb3. Configure here.

let state_diff = block_state.to_state_diff()?.state_maps;

#[cfg(feature = "os_input")]
let initial_reads = block_state.get_os_initial_reads()?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Migration breaks OS initial reads

High Severity

get_os_initial_reads runs after set_compiled_class_hash_migration, so migrated classes already have post-migration compiled class hashes in the write cache. The OS backfill via get_compiled_class_hash then skips reading parent state and often leaves no pre-block compiled class hash in initial_reads, so downstream OS replay can get wrong trie inputs.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c52efb3. Configure here.

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.

It already inserts into the initial reads. See the discussion here:
https://reviewable.io/reviews/starkware-libs/sequencer/14612

Comment thread crates/blockifier/src/state/cached_state.rs

@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 made 1 comment.
Reviewable status: 0 of 10 files reviewed, 3 unresolved discussions (waiting on itamar-starkware).

Comment thread crates/blockifier/src/state/cached_state.rs
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-1-produce branch from c52efb3 to 15affd5 Compare June 23, 2026 08:56
@yoavGrs yoavGrs changed the base branch from main to graphite-base/14592 June 23, 2026 13:30
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-1-produce branch from 15affd5 to f5749a5 Compare June 23, 2026 13:31
@yoavGrs yoavGrs changed the base branch from graphite-base/14592 to yoav/migration-initial-reads-fix June 23, 2026 13:31
@yoavGrs yoavGrs force-pushed the yoav/migration-initial-reads-fix branch from 94279be to cdbf3ab Compare June 23, 2026 14:42
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-1-produce branch from f5749a5 to 9f42919 Compare June 23, 2026 14:42
Add an os_input feature on blockifier and, behind it, compute the pre-block OS read values (CachedState::get_os_initial_reads) in finalize_block, expose them on BlockExecutionSummary/BlockExecutionArtifacts, and carry them into the batcher's CentralObjects decision-reached response. Not yet consumed downstream.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yoavGrs yoavGrs changed the base branch from yoav/migration-initial-reads-fix to graphite-base/14592 June 23, 2026 18:32
@yoavGrs yoavGrs force-pushed the graphite-base/14592 branch from cdbf3ab to 01f17ad Compare June 23, 2026 18:32
@yoavGrs yoavGrs force-pushed the yoav/os-initial-reads-1-produce branch from 9f42919 to 6df9efa Compare June 23, 2026 18:32
@yoavGrs yoavGrs changed the base branch from graphite-base/14592 to main June 23, 2026 18:32

@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 made 1 comment.
Reviewable status: 0 of 10 files reviewed, 2 unresolved discussions (waiting on itamar-starkware).

let state_diff = block_state.to_state_diff()?.state_maps;

#[cfg(feature = "os_input")]
let initial_reads = block_state.get_os_initial_reads()?;

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.

It already inserts into the initial reads. See the discussion here:
https://reviewable.io/reviews/starkware-libs/sequencer/14612

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