Skip to content

apollo_batcher: write accessed keys in the same storage transaction as the state diff#14871

Open
yoavGrs wants to merge 1 commit into
mainfrom
accessed-keys-atomic-write
Open

apollo_batcher: write accessed keys in the same storage transaction as the state diff#14871
yoavGrs wants to merge 1 commit into
mainfrom
accessed-keys-atomic-write

Conversation

@yoavGrs

@yoavGrs yoavGrs commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

…s the state diff

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

yoavGrs commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@yoavGrs
yoavGrs marked this pull request as ready for review July 22, 2026 08:04
@yoavGrs yoavGrs self-assigned this Jul 22, 2026
@cursor

cursor Bot commented Jul 22, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes persistence ordering and atomicity for OS-input accessed keys at block commit; incorrect None/Some handling could leave storage inconsistent with execution artifacts.

Overview
With os_input, accessed keys are no longer written in a separate storage call after the proposal commit. They are passed as Option<AccessedKeys> into commit_proposal_and_block and persisted inside commit_proposal in the same read-write transaction as the state diff and block-hash metadata (append_accessed_keys on that txn).

Locally executed blocks (decision_reached) build keys earlier via build_block_accessed_keys (renamed from write_block_accessed_keys, build-only) and pass Some(accessed_keys). Synced blocks pass None because keys are not available. The BatcherStorageWriter::write_accessed_keys API is removed; commit_proposal’s signature gains the optional keys under os_input. Tests use expect_commit_proposal_once / expect_commit_proposal_success to assert whether accessed keys are included.

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

@yoavGrs
yoavGrs requested a review from itamar-starkware July 22, 2026 08:04
@itamar-starkware

Copy link
Copy Markdown
Contributor

crates/apollo_batcher/src/batcher.rs line 1898 at r1 (raw file):

    ) -> StorageResult<()>;

    /// Commits the state diff and, when present, the accessed keys, in the same transaction.

Remove the comment; the only real info here is "Accessed keys are only available for blocks that were executed locally," and that's not always true, accessed keys can be available in sync if we choose too.

@itamar-starkware

Copy link
Copy Markdown
Contributor

:lgtm: but fix the comment

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