Skip to content

Conversation

@AvivYossef-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@AvivYossef-starkware AvivYossef-starkware changed the title starknet_os_runner: c;asses provider using class manager starknet_os_runner: classes provider using class manager Dec 23, 2025
@AvivYossef-starkware AvivYossef-starkware marked this pull request as ready for review December 23, 2025 12:55
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/convert_back_entry_points_ branch from 065855c to 578c249 Compare December 24, 2025 13:58
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/classes_provider_using_class_manager branch from f86b54c to 04f96ab Compare December 24, 2025 13:58
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

@Yoni-Starkware made 1 comment.
Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @AvivYossef-starkware).


crates/starknet_os_runner/src/classes_provider.rs line 67 at r2 (raw file):

            }

            // Fallback to fetch.

Why not reuse the mechanism of StateReaderAndContractManager?
You get almost everything for free. The casm hash is cached, etc.

Code quote:

            // Fallback to fetch.

@AvivYossef-starkware AvivYossef-starkware changed the base branch from aviv/convert_back_entry_points_ to graphite-base/11006 December 25, 2025 08:22
Copy link
Contributor Author

@AvivYossef-starkware AvivYossef-starkware left a comment

Choose a reason for hiding this comment

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

@AvivYossef-starkware made 1 comment.
Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @Yoni-Starkware).


crates/starknet_os_runner/src/classes_provider.rs line 67 at r2 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Why not reuse the mechanism of StateReaderAndContractManager?
You get almost everything for free. The casm hash is cached, etc.

I have two problems witht that,

  1. the RPC state reader returns a dummy compiled class hash
  2. the RPC state reader compile to cam -> convert to contract_class v1 -> we need to convert to casm again

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/classes_provider_using_class_manager branch from 04f96ab to 56285d5 Compare December 25, 2025 08:23
@AvivYossef-starkware AvivYossef-starkware changed the base branch from graphite-base/11006 to aviv/convert_back_entry_points_ December 25, 2025 08:24
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/convert_back_entry_points_ branch from f231222 to aa61b12 Compare December 25, 2025 14:47
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/classes_provider_using_class_manager branch from 56285d5 to bc7d82e Compare December 25, 2025 14:47
Copy link
Contributor Author

@AvivYossef-starkware AvivYossef-starkware left a comment

Choose a reason for hiding this comment

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

@AvivYossef-starkware made 1 comment.
Reviewable status: 0 of 5 files reviewed, 1 unresolved discussion (waiting on @Yoni-Starkware).


crates/starknet_os_runner/src/classes_provider.rs line 67 at r2 (raw file):

Previously, AvivYossef-starkware wrote…

I have two problems witht that,

  1. the RPC state reader returns a dummy compiled class hash
  2. the RPC state reader compile to cam -> convert to contract_class v1 -> we need to convert to casm again

Done

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/classes_provider_using_class_manager branch from bc7d82e to e6ce528 Compare December 28, 2025 06:30
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/convert_back_entry_points_ branch from aa61b12 to 3a77b16 Compare December 28, 2025 06:30
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

@Yoni-Starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: 1 of 5 files reviewed, 2 unresolved discussions (waiting on @AvivYossef-starkware).


crates/starknet_os_runner/Cargo.toml line 10 at r5 (raw file):

[features]
cairo_native = ["blockifier/cairo_native"]

Is this necessary?

Code quote:

cairo_native = ["blockifier/cairo_native"]

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/classes_provider_using_class_manager branch from e6ce528 to 864211d Compare December 28, 2025 09:25
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/convert_back_entry_points_ branch from 3a77b16 to 2c77dea Compare December 28, 2025 09:25
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

@Yoni-Starkware made 3 comments and resolved 1 discussion.
Reviewable status: 1 of 5 files reviewed, 3 unresolved discussions (waiting on @AvivYossef-starkware).


crates/starknet_os_runner/Cargo.toml line 10 at r5 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Is this necessary?

Oh, nevermind


crates/starknet_os_runner/src/classes_provider.rs line 35 at r5 (raw file):

        for &class_hash in executed_class_hashes {
            let (compiled_class_hash, casm) = self.fetch_class(class_hash)?;
            compiled_classes.insert(compiled_class_hash, casm);

Add a TODO to parallelize this

Code quote:

        for &class_hash in executed_class_hashes {
            let (compiled_class_hash, casm) = self.fetch_class(class_hash)?;
            compiled_classes.insert(compiled_class_hash, casm);

crates/starknet_os_runner/src/classes_provider.rs line 40 at r5 (raw file):

    }

    /// Fetch class by class hash.

Suggestion:

    /// Fetches class by class hash.

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/classes_provider_using_class_manager branch from 864211d to 818a21b Compare December 28, 2025 09:38
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

@Yoni-Starkware made 2 comments.
Reviewable status: 1 of 5 files reviewed, 5 unresolved discussions (waiting on @AvivYossef-starkware).


crates/starknet_os_runner/src/classes_provider.rs line 74 at r5 (raw file):

        entry_points_by_type: (&class.entry_points_by_type).into(),
    }
}

And move this below all impl blocks

Suggestion:

/// Converts a `CompiledClassV1` to a `CasmContractClass` for OS execution.
/// Note: Some fields are not preserved in `CompiledClassV1` and are set to default values:
/// - `compiler_version`: Set to empty string
/// - `hints`: Set to empty (OS doesn't use them from this struct for Cairo 1 contracts)
/// - `pythonic_hints`: Set to None
fn compiled_class_v1_to_casm(class: &CompiledClassV1) -> CasmContractClass {
    // TODO(Aviv): Consider using dummy prime since it is not used in the OS.
    let prime = Felt::prime();

    let bytecode: Vec<BigUintAsHex> = class
        .program
        .iter_data()
        .map(|maybe_relocatable| match maybe_relocatable {
            MaybeRelocatable::Int(felt) => BigUintAsHex { value: felt.to_biguint() },
            _ => panic!("Expected all bytecode elements to be MaybeRelocatable::Int"),
        })
        .collect();

    CasmContractClass {
        prime,
        compiler_version: String::new(),
        bytecode,
        bytecode_segment_lengths: Some(class.bytecode_segment_felt_sizes().into()),
        hints: Vec::new(),
        pythonic_hints: None,
        entry_points_by_type: (&class.entry_points_by_type).into(),
    }
}

crates/starknet_os_runner/src/classes_provider.rs line 90 at r5 (raw file):

            RunnableCompiledClass::V1(compiled_class_v1) => {
                let casm = compiled_class_v1_to_casm(&compiled_class_v1);
                let compiled_class_hash = self.get_compiled_class_hash(class_hash)?;

I think get_compiled_class_hash_v2 is the one that is already cached in the state-reader-and-class-manager

Code quote:

self.get_compiled_class_hash

Copy link
Contributor Author

@AvivYossef-starkware AvivYossef-starkware left a comment

Choose a reason for hiding this comment

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

@AvivYossef-starkware resolved 2 discussions.
Reviewable status: 1 of 5 files reviewed, 1 unresolved discussion (waiting on @Yoni-Starkware).

Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

@Yoni-Starkware reviewed 1 file.
Reviewable status: 2 of 5 files reviewed, 3 unresolved discussions.

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/classes_provider_using_class_manager branch from 818a21b to b32a537 Compare December 28, 2025 09:55
Copy link
Contributor Author

@AvivYossef-starkware AvivYossef-starkware left a comment

Choose a reason for hiding this comment

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

@AvivYossef-starkware made 1 comment and resolved 1 discussion.
Reviewable status: 2 of 5 files reviewed, 2 unresolved discussions (waiting on @Yoni-Starkware).


crates/starknet_os_runner/src/classes_provider.rs line 90 at r5 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

I think get_compiled_class_hash_v2 is the one that is already cached in the state-reader-and-class-manager

right, notice that right now it return dummy value

@AvivYossef-starkware AvivYossef-starkware changed the base branch from aviv/convert_back_entry_points_ to main December 28, 2025 10:11
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@Yoni-Starkware reviewed 6 files and all commit messages, made 1 comment, and resolved 2 discussions.
Reviewable status: 6 of 7 files reviewed, all discussions resolved.

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/classes_provider_using_class_manager branch from b32a537 to 01cc778 Compare December 28, 2025 11:05
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

@Yoni-Starkware reviewed 3 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @AvivYossef-starkware).

@AvivYossef-starkware AvivYossef-starkware added this pull request to the merge queue Dec 30, 2025
Merged via the queue into main with commit b312146 Dec 30, 2025
29 of 32 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants