Skip to content

apollo_central_sync: use starknet version as single source of truth for non BC classes#13312

Open
noamsp-starkware wants to merge 1 commit intomainfrom
noam.s/apollo_central_sync_use_starknet_version_as_single_source_of_truth_for_non_bc_classes
Open

apollo_central_sync: use starknet version as single source of truth for non BC classes#13312
noamsp-starkware wants to merge 1 commit intomainfrom
noam.s/apollo_central_sync_use_starknet_version_as_single_source_of_truth_for_non_bc_classes

Conversation

@noamsp-starkware
Copy link
Copy Markdown
Contributor

@noamsp-starkware noamsp-starkware commented Mar 17, 2026

Note

Medium Risk
Changes the state sync/class-manager integration and compiled-class streaming behavior based on stored starknet_version, which can affect how/when classes and CASMs are persisted and sent to the class manager during sync.

Overview
Switches non-backward-compatible (non-BC) class handling to use the block header’s starknet_version as the single source of truth, removing the previous reliance on the compiler_backward_compatibility_marker and the store_sierras_and_casms_block_threshold config.

State diff processing now sends Sierra classes directly to the class manager only for BC blocks, and persists Sierra classes to storage only for non-BC blocks so the compiled-class stream can later attach CASM and call add_class_and_executable_unsafe. The compiled-class stream now scans headers to stop/pause at the first BC block and batches downloads to include only non-BC ranges; the sync “stuck” detector (check_sync_progress) is updated accordingly.

Removes store_sierras_and_casms_block_threshold from config/schema/deployment overlays and stops updating the compiler-compatibility marker during header writes (marker remains in storage with a TODO to delete).

Written by Cursor Bugbot for commit 8c6ec29. This will update automatically on new commits. Configure here.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Contributor Author

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 17, 2026

Artifacts upload workflows:

@noamsp-starkware noamsp-starkware marked this pull request as ready for review March 17, 2026 15:22
Copy link
Copy Markdown
Collaborator

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

@ShahakShama reviewed 9 files and all commit messages, and made 11 comments.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on noamsp-starkware).


crates/apollo_central_sync/src/lib.rs line 469 at r1 (raw file):

            .expect("Block header must be present before state diff is processed.");

        let is_bc_compatible_block = block_starknet_version >= STARKNET_VERSION_TO_COMPILE_FROM;

bc = backward compatibility. You're saying compatible twice
I personally prefer bc -> backward


crates/apollo_central_sync/src/lib.rs line 473 at r1 (raw file):

        // fails we retry the same block.
        if let Some(class_manager_client) = &self.class_manager_client {
            // Non-BC blocks (starknet_version < STARKNET_VERSION_TO_COMPILE_FROM) must be added

In the documentation at least you should have enough space to not use acronym (BC -> backward compatible)


crates/apollo_central_sync/src/lib.rs line 493 at r1 (raw file):

            }

            for (class_hash, deprecated_class) in &deprecated_classes {

Add a comment above here that deprecated classes are always backward compatible


crates/apollo_central_sync/src/lib.rs line 517 at r1 (raw file):

            if !is_bc_compatible_block {
                debug!(
                    "Storing Sierra classes {:?} in storage (non-BC block {block_number})",

Also in logs avoid using acronyms


crates/apollo_central_sync/src/lib.rs line 525 at r1 (raw file):

                }
            } else {
                debug!("Block {} contains non backward compatible classes.", block_number);

Restore this debug log


crates/apollo_central_sync/src/lib.rs line 558 at r1 (raw file):

    ) -> StateSyncResult {
        // The compiled class stream pauses when it reaches a BC block, so this function should
        // only be called for non-BC blocks.

same here (BC -> backward compatible)


crates/apollo_central_sync/src/lib.rs line 566 at r1 (raw file):

                .map(|v| v < STARKNET_VERSION_TO_COMPILE_FROM)
                .unwrap_or(true),
            "store_compiled_class called for BC block {block_number}"

same here (BC -> backward compatible)


crates/apollo_central_sync/src/lib.rs line 859 at r1 (raw file):

            while from < state_marker {
                // The block header is guaranteed to be in storage for any block below state_marker.
                let starknet_version_at_from = txn.get_starknet_version(from)?.expect("Block header must exist for block below state_marker.");

Rename this variable. What is at_from?


crates/apollo_central_sync/src/lib.rs line 879 at r1 (raw file):

                );
                pending::<()>().await;
                continue;

Do you really need this continue statement?


crates/apollo_central_sync/src/lib.rs line 894 at r1 (raw file):

            // Since starknet_version is monotonically non-decreasing, the non-BC range is always
            // a contiguous prefix.
            let mut up_to = min(state_marker, BlockNumber(from.0 + u64::from(max_stream_size)));

Consider extracting to a helper function


crates/apollo_central_sync/src/lib.rs line 990 at r1 (raw file):

            let is_casm_stuck = casm_marker == new_casm_marker
                && new_casm_marker < new_state_marker
                && reader

Move the read to the read that's done above

@github-actions
Copy link
Copy Markdown

There hasn't been any activity on this pull request recently, and in order to prioritize active work, it has been marked as stale.
This PR will be closed and locked in 7 days if no further activity occurs.
Thank you for your contributions!

@github-actions github-actions Bot added the stale label Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants