Skip to content

apollo_batcher: cache recent state commitment infos in memory - #15066

Open
yoavGrs wants to merge 1 commit into
commitment-infos-1-committer-read-apifrom
commitment-infos-2-batcher-cache
Open

apollo_batcher: cache recent state commitment infos in memory#15066
yoavGrs wants to merge 1 commit into
commitment-infos-1-committer-read-apifrom
commitment-infos-2-batcher-cache

Conversation

@yoavGrs

@yoavGrs yoavGrs commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

yoavGrs commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

@cursor

cursor Bot commented Aug 27, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Read-path caching and revert cleanup mirror the established block-hash cache; no new persistence or external API semantics beyond faster reads for recent blocks.

Overview
Adds an in-memory LRU cache (20 blocks) for compressed state commitment infos, parallel to the existing recent block-hash cache.

Commitment manager: Populates the cache when commitment results are written to storage; removes the entry for a block when a revert completes.

Batcher API: get_state_commitment_infos and has_state_commitment_infos now take &mut self, drain pending commitment results first (same as get_block_hash), then return from the cache when present before falling back to storage.

Tests cover cache hits after ReadPathsAndCommitBlock, and that revert clears the cache.

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

@yoavGrs
yoavGrs force-pushed the commitment-infos-2-batcher-cache branch from 098f1f3 to 8aad038 Compare August 27, 2026 14:56

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

@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 1 potential issue.

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 b2dccee. Configure here.

// Add commitment infos to cache.
if let Some(state_commitment_infos) = state_commitment_infos.clone() {
self.recent_state_commitment_infos_cache.put(height, state_commitment_infos);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale cache after block revert

Medium Severity

wait_for_revert_result pops the reverted height from recent_state_commitment_infos_cache, but write_commitment_results_to_storage then caches any still-pending commit for that same height. get_state_commitment_infos and has_state_commitment_infos then return that entry after storage has already dropped it.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b2dccee. Configure here.

@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 5 files reviewed, 2 unresolved discussions (waiting on itamar-starkware).

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