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

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/get_versioned_class_to_feature_contract branch from 83b7b5a to ab56dd1 Compare December 15, 2024 19:05
@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
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/get_versioned_class_to_feature_contract branch from ab56dd1 to 82253b3 Compare December 15, 2024 19:35
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/compile_sierra__to_versioned_contract_class_in_reexecution branch from 13950e4 to deeb020 Compare December 15, 2024 19:36
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/get_versioned_class_to_feature_contract branch from 82253b3 to 53465de Compare December 15, 2024 20:08
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/compile_sierra__to_versioned_contract_class_in_reexecution branch from deeb020 to 84d38fd Compare December 15, 2024 20:08
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/get_versioned_class_to_feature_contract branch from 53465de to 6e1354f Compare December 15, 2024 20:21
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/compile_sierra__to_versioned_contract_class_in_reexecution branch from 84d38fd to d1f338f Compare December 16, 2024 08:20
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 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @amosStarkware and @AvivYossef-starkware)

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/get_versioned_class_to_feature_contract branch from 6e1354f to 9979a99 Compare December 17, 2024 09:17
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/compile_sierra__to_versioned_contract_class_in_reexecution branch from d1f338f to bb9d37c Compare December 17, 2024 09:17
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.

Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @amosStarkware and @dorimedini-starkware)


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

Previously, dorimedini-starkware wrote…

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

No, I can define a new one but its in use only here

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.

:lgtm:

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @amosStarkware)


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

Previously, AvivYossef-starkware wrote…

No, I can define a new one but its in use only here

nvm then

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/get_versioned_class_to_feature_contract branch from 9979a99 to b073f78 Compare December 17, 2024 12:10
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/compile_sierra__to_versioned_contract_class_in_reexecution branch from bb9d37c to 4fbece4 Compare December 17, 2024 12:10
Copy link
Contributor Author

AvivYossef-starkware commented Dec 17, 2024

Merge activity

  • Dec 17, 3:08 PM EST: A user started a stack merge that includes this pull request via Graphite.
  • Dec 17, 3:45 PM EST: Graphite rebased this pull request as part of a merge.
  • Dec 17, 4:01 PM EST: A user merged this pull request with Graphite.

@AvivYossef-starkware AvivYossef-starkware changed the base branch from aviv/get_versioned_class_to_feature_contract to graphite-base/2679 December 17, 2024 20:27
@AvivYossef-starkware AvivYossef-starkware changed the base branch from graphite-base/2679 to main December 17, 2024 20:43
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/compile_sierra__to_versioned_contract_class_in_reexecution branch from 4fbece4 to 98f2e9c Compare December 17, 2024 20:44
Copy link

Artifacts upload workflows:

@AvivYossef-starkware AvivYossef-starkware merged commit 97b0f33 into main Dec 17, 2024
9 checks passed
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