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): move contract compilation logic to separate module + contracts.rs #180

Conversation

dorimedini-starkware
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware commented Jul 29, 2024

This change is Reviewable

Copy link
Contributor

@nimrod-starkware nimrod-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 4 files reviewed, 2 unresolved discussions (waiting on @AvivYossef-starkware, @dorimedini-starkware, @meship-starkware, and @TzahiTaub)


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

/// Compiles a Cairo0 program using the deprecated compiler.
pub fn cairo0_compile(path: String, extra_arg: Option<String>, debug_info: bool) -> Vec<u8> {
    let mut command = Command::new("starknet-compile-deprecated");

Consider defining it as a constant

Code quote:

"starknet-compile-deprecated"

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

                    FeatureContract::ERC20(_) => unreachable!(),
                };
                cairo0_compile(self.get_source_path(), extra_arg, false)

Shouldn't that be configurable by whoever calls compile?

Code quote:

 false

Copy link
Collaborator Author

@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.

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @AvivYossef-starkware, @meship-starkware, @nimrod-starkware, and @TzahiTaub)


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

Previously, nimrod-starkware wrote…

Consider defining it as a constant

why? this is the only usage of this string


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

Previously, nimrod-starkware wrote…

Shouldn't that be configurable by whoever calls compile?

yes, but this is only a preparation; we currently have no use case for the true case (this is not a callable script, it's just part of tests ATM)

Copy link
Contributor

@nimrod-starkware nimrod-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:

Reviewable status: 0 of 4 files reviewed, all discussions resolved (waiting on @AvivYossef-starkware, @meship-starkware, and @TzahiTaub)

@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from 75b59bb to 31a691f Compare July 31, 2024 16:33
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from 244da0c to fe4e14c Compare July 31, 2024 16:34
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from 31a691f to bf5e760 Compare July 31, 2024 16:42
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from fe4e14c to 271de7a Compare July 31, 2024 16:42
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from bf5e760 to a32af92 Compare July 31, 2024 16:51
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from 271de7a to c3e54f4 Compare July 31, 2024 16:51
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from a32af92 to 62d0c0e Compare August 1, 2024 08:49
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from c3e54f4 to 0dad397 Compare August 1, 2024 08:49
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from 62d0c0e to dca7a29 Compare August 1, 2024 08:52
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from 0dad397 to e7bfa0d Compare August 1, 2024 08:52
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from dca7a29 to 033708e Compare August 1, 2024 15:57
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from e7bfa0d to 123fa4f Compare August 1, 2024 15:57
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from 033708e to 5faa4dc Compare August 6, 2024 12:15
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from 123fa4f to eb425e0 Compare August 6, 2024 12:15
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from 5faa4dc to 5c5be6b Compare August 6, 2024 12:28
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from eb425e0 to 125e131 Compare August 6, 2024 12:28
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from 5c5be6b to 7d707f6 Compare August 7, 2024 14:51
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from 125e131 to 73757fe Compare August 7, 2024 14:51
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from 7d707f6 to 3da45df Compare August 7, 2024 16:16
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from 73757fe to bcc5aef Compare August 7, 2024 16:16
@dorimedini-starkware dorimedini-starkware marked this pull request as ready for review August 8, 2024 09:52
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from 3da45df to e4fc399 Compare August 11, 2024 07:45
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from bcc5aef to 11f058a Compare August 11, 2024 07:45
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch from e4fc399 to d9c41fa Compare August 11, 2024 08:54
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from 11f058a to 0c52d60 Compare August 11, 2024 08:54
Copy link
Contributor

@TzahiTaub TzahiTaub left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 4 files at r1, 1 of 1 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @AvivYossef-starkware, @dorimedini-starkware, and @meship-starkware)


crates/blockifier/tests/feature_contracts_compatibility_test.rs line 48 at r3 (raw file):

        let mut command = Command::new("starknet-compile-deprecated");
        command.args([&path_str, "--no_debug_info"]);
        if file_name.starts_with("account") {

FaultyAccount didn't fulfill this condition in the past, and now it does—is this the desired behavior? (I assume so; I'm just verifying.)

Code quote:

file_name.starts_with("account")

crates/blockifier/tests/feature_contracts_compatibility_test.rs line 59 at r3 (raw file):

            panic!(
                "{} does not compile to {existing_compiled_path}.\nRun `{FIX_COMMAND}` to fix the \
                 expected test according to locally installed `starknet-compile-deprecated`.\n",

?

Suggestion:

               existing file according

crates/blockifier/tests/feature_contracts_compatibility_test.rs line 116 at r3 (raw file):

        .map(|contract| contract.get_compiled_path())
        .collect();
    let mut compiled_paths_on_filesystem: Vec<String> = verify_and_get_files(CairoVersion::Cairo0)

Do we really need to enforce the dir hierarchy?
Can't we be satisfied with verifying the contracts we get by all_feature_contracts and the source/compiled_path functions exist in the dir, and that's it? (I think it'll be nice if we can remove that function).

Code quote:

verify_and_get_files

Copy link
Collaborator Author

@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.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @AvivYossef-starkware, @meship-starkware, and @TzahiTaub)


crates/blockifier/tests/feature_contracts_compatibility_test.rs line 48 at r3 (raw file):

Previously, TzahiTaub (Tzahi) wrote…

FaultyAccount didn't fulfill this condition in the past, and now it does—is this the desired behavior? (I assume so; I'm just verifying.)

it should be compiled as an account, yes


crates/blockifier/tests/feature_contracts_compatibility_test.rs line 116 at r3 (raw file):

Previously, TzahiTaub (Tzahi) wrote…

Do we really need to enforce the dir hierarchy?
Can't we be satisfied with verifying the contracts we get by all_feature_contracts and the source/compiled_path functions exist in the dir, and that's it? (I think it'll be nice if we can remove that function).

I want to prevent the case where an untracked contract is manually added. it's possible to miss adding it to the enum; why not enforce it?

@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from 0c52d60 to 7d376aa Compare August 11, 2024 09:34
Copy link
Contributor

@TzahiTaub TzahiTaub 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 @AvivYossef-starkware and @meship-starkware)


crates/blockifier/tests/feature_contracts_compatibility_test.rs line 116 at r3 (raw file):

Previously, dorimedini-starkware wrote…

I want to prevent the case where an untracked contract is manually added. it's possible to miss adding it to the enum; why not enforce it?

OK, 👍

Copy link
Collaborator Author

dorimedini-starkware commented Aug 11, 2024

Merge activity

@dorimedini-starkware dorimedini-starkware changed the base branch from 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths to graphite-base/180 August 11, 2024 15:29
@dorimedini-starkware dorimedini-starkware changed the base branch from graphite-base/180 to main August 11, 2024 15:29
@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_move_contract_compilation_logic_to_separate_module_contracts.rs branch from 7d376aa to 4045c19 Compare August 11, 2024 15:30
@dorimedini-starkware dorimedini-starkware merged commit 1731db3 into main Aug 11, 2024
14 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 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