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): add runnable cairo version to the cairo version enum #2503

Merged

Conversation

meship-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

reviewable-StarkWare commented Dec 5, 2024

This change is Reviewable

@meship-starkware meship-starkware force-pushed the meship/contracts/add_runnable_cairo_version_struct branch 2 times, most recently from 7538e8c to 7b28f4a Compare December 5, 2024 17:46
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 3 lines in your changes missing coverage. Please review.

Project coverage is 49.83%. Comparing base (e3165c4) to head (53605f5).
Report is 749 commits behind head on main.

Files with missing lines Patch % Lines
crates/blockifier/src/test_utils/contracts.rs 70.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2503      +/-   ##
==========================================
+ Coverage   40.10%   49.83%   +9.73%     
==========================================
  Files          26      291     +265     
  Lines        1895    33458   +31563     
  Branches     1895    33458   +31563     
==========================================
+ Hits          760    16675   +15915     
- Misses       1100    15652   +14552     
- Partials       35     1131    +1096     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it 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.

Reviewed 33 of 33 files at r1, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @meship-starkware)


crates/blockifier/src/test_utils/contracts.rs line 131 at r1 (raw file):

            Self::SierraExecutionInfoV1Contract => {
                CairoVersion::Cairo1(RunnableCairoVersion::Native)
            }

this will change in the next PR to return the inner runnable cairo1 version?
or will this contract stay "only native"?

Code quote:

            Self::SierraExecutionInfoV1Contract => {
                CairoVersion::Cairo1(RunnableCairoVersion::Native)
            }

crates/blockifier/src/test_utils/contracts.rs line 310 at r1 (raw file):

    pub fn get_sierra_path(&self) -> String {
        assert_ne!(self.cairo_version(), CairoVersion::Cairo0);
        assert_ne!(self, &Self::ERC20(CairoVersion::Cairo1(RunnableCairoVersion::Casm)));

what if the ERC20 is native? this can be constructed, compiler won't protect us

Code quote:

assert_ne!(self, &Self::ERC20(CairoVersion::Cairo1(RunnableCairoVersion::Casm)));

crates/blockifier/src/test_utils.rs line 63 at r1 (raw file):

#[derive(Clone, Hash, PartialEq, Eq, Copy, Debug)]
pub enum RunnableCairoVersion {

please add the 1 for clarity.
I would also drop the Version - it's not a difference in versions, actually, just the execution framework

Suggestion:

RunnableCairo1

crates/blockifier/src/test_utils.rs line 106 at r1 (raw file):

            }
        }
    }

is this deleted in PR 2464? because it should be...
if native feature is active, calling this function should always panic imo, Cairo0.other_version() is not well defined if native exists

Code quote:

    pub fn other(&self) -> Self {
        match self {
            Self::Cairo0 => CairoVersion::Cairo1(RunnableCairoVersion::Casm),
            CairoVersion::Cairo1(RunnableCairoVersion::Casm) => Self::Cairo0,
            #[cfg(feature = "cairo_native")]
            CairoVersion::Cairo1(RunnableCairoVersion::Native) => {
                panic!("There is no other version for native")
            }
        }
    }

crates/blockifier/src/test_utils.rs line 136 at r1 (raw file):

            Self::CairoVersion(CairoVersion::Cairo1(RunnableCairoVersion::Native)) => {
                TrackedResource::SierraGas
            }

less boilerplate :)

Suggestion:

            Self::CairoVersion(CairoVersion::Cairo1(_)) => TrackedResource::SierraGas,

crates/blockifier/src/test_utils.rs line 370 at r1 (raw file):

                    )
                }
            }

this macro should behave the same for all cairo1 contracts regardless of running framework, right?

Suggestion:

            CairoVersion::Cairo1(_) => {
                if let $crate::transaction::errors::TransactionExecutionError::ValidateTransactionError {
                    error, ..
                } = $error {
                    assert_eq!(
                        error.to_string(),
                        "Execution failed. Failure reason: 0x496e76616c6964207363656e6172696f \
                         ('Invalid scenario')."
                    )
                }
            }

@meship-starkware meship-starkware force-pushed the meship/contracts/add_runnable_cairo_version_struct branch from 7b28f4a to 1cd3784 Compare December 8, 2024 09:32
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 11 of 11 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @meship-starkware)

@meship-starkware meship-starkware force-pushed the meship/contracts/add_runnable_cairo_version_struct branch from 1cd3784 to 50f6e95 Compare December 8, 2024 12:23
Copy link
Contributor Author

@meship-starkware meship-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: 0 of 33 files reviewed, 5 unresolved discussions (waiting on @dorimedini-starkware)


crates/blockifier/src/test_utils.rs line 63 at r1 (raw file):

Previously, dorimedini-starkware wrote…

please add the 1 for clarity.
I would also drop the Version - it's not a difference in versions, actually, just the execution framework

Done.


crates/blockifier/src/test_utils.rs line 106 at r1 (raw file):

Previously, dorimedini-starkware wrote…

is this deleted in PR 2464? because it should be...
if native feature is active, calling this function should always panic imo, Cairo0.other_version() is not well defined if native exists

It is deleted in the next PR


crates/blockifier/src/test_utils.rs line 136 at r1 (raw file):

Previously, dorimedini-starkware wrote…

less boilerplate :)

Done.


crates/blockifier/src/test_utils.rs line 370 at r1 (raw file):

Previously, dorimedini-starkware wrote…

this macro should behave the same for all cairo1 contracts regardless of running framework, right?

Done.


crates/blockifier/src/test_utils/contracts.rs line 131 at r1 (raw file):

Previously, dorimedini-starkware wrote…

this will change in the next PR to return the inner runnable cairo1 version?
or will this contract stay "only native"?

I am changing it in the next PR


crates/blockifier/src/test_utils/contracts.rs line 310 at r1 (raw file):

Previously, dorimedini-starkware wrote…

what if the ERC20 is native? this can be constructed, compiler won't protect us

Will fix it, but for now ERC20 cannot be native will be fixed in the near future,

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 33 of 33 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @meship-starkware)

@meship-starkware meship-starkware force-pushed the meship/contracts/add_runnable_cairo_version_struct branch from 50f6e95 to f8fbee1 Compare December 8, 2024 13:45
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 7 of 7 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yoni-Starkware)

@meship-starkware meship-starkware force-pushed the meship/contracts/add_runnable_cairo_version_struct branch from f8fbee1 to cd34971 Compare December 8, 2024 14:28
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 r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yoni-Starkware)

@meship-starkware meship-starkware force-pushed the meship/contracts/add_runnable_cairo_version_struct branch from cd34971 to 53605f5 Compare December 8, 2024 14:32
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 r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yoni-Starkware)

@meship-starkware meship-starkware merged commit 7683084 into main Dec 8, 2024
14 checks passed
@meship-starkware meship-starkware deleted the meship/contracts/add_runnable_cairo_version_struct branch December 8, 2024 15:11
@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 2024
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.

3 participants