Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(blockifier_reexecution): compile sierra to versioned runnable class #2679

Open
wants to merge 1 commit into
base: aviv/get_versioned_class_to_feature_contract
Choose a base branch
from

Conversation

AvivYossef-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @amosStarkware and @AvivYossef-starkware)


crates/blockifier_reexecution/src/state_reader/test_state_reader.rs line 138 at r1 (raw file):

            StarknetContractClass::Sierra(sierra) => {
                let (casm, _) = sierra_to_versioned_contract_class_v1(sierra).unwrap();
                let runnable_contract_class: RunnableCompiledClass = casm.try_into().unwrap();

personally prefer to avoid let x: X = y.into() when you can do let x = X::from(y)
non-blocking

Suggestion:

let runnable_contract_class = RunnableCompiledClass::try_from(casm).unwrap();

crates/blockifier_reexecution/src/state_reader/compile.rs line 79 at r1 (raw file):

pub fn sierra_to_versioned_contract_class_v1(
    sierra: FlattenedSierraClass,
) -> StateResult<(ContractClass, SierraVersion)> {

doesn't this tuple type have a name you can use?

Code quote:

(ContractClass, SierraVersion)

crates/blockifier_reexecution/src/state_reader/compile.rs line 100 at r1 (raw file):

        .collect::<Vec<u64>>()
        .try_into()
        .expect("Expected exactly 3 elements.");

this version-from-sierra logic is duplicated, no? is this avoidable? I realize the type of the sierra contract isn't the same but is there something you can reuse?
non-blocking

Code quote:

    let [major, minor, patch] = sierra
        .sierra_program
        .clone()
        .into_iter()
        .take(3)
        .map(|big_uint_as_hex| u64::try_from(big_uint_as_hex.value).unwrap())
        .collect::<Vec<u64>>()
        .try_into()
        .expect("Expected exactly 3 elements.");

crates/blockifier_reexecution/src/state_reader/offline_state_reader.rs line 163 at r1 (raw file):

        match self.get_contract_class(&class_hash)? {
            StarknetContractClass::Sierra(sierra) => {
                let (casm, _) = sierra_to_versioned_contract_class_v1(sierra).unwrap();

why is this line needed...? where is casm used?

Code quote:

let (casm, _) = sierra_to_versioned_contract_class_v1(sierra).unwrap();

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/compile_sierra__to_versioned_contract_class_in_reexecution branch from 484c4f6 to 13950e4 Compare December 15, 2024 19:06
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