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): refactor feature contract path getters for different paths #179

Conversation

dorimedini-starkware
Copy link
Collaborator

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

This change is Reviewable

@aner-starkware
Copy link
Contributor

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

// ERC20 contract is in a unique location.
const ERC20_BASE_NAME: &str = "ERC20";

Why are you adding this, if it's never used?

Code quote:

const ERC20_BASE_NAME: &str = "ERC20";

@aner-starkware
Copy link
Contributor

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

            Self::SecurityTests => SECURITY_TEST_CONTRACT_NAME,
            Self::TestContract(_) => TEST_CONTRACT_NAME,
            Self::ERC20(_) => ERC20_BASE_NAME,

The above question

Code quote:

Self::ERC20(_) => ERC20_BASE_NAME,

Copy link
Contributor

@aner-starkware aner-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 all commit messages.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @AvivYossef-starkware, @dorimedini-starkware, @meship-starkware, and @noaov1)


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

        let contract_name = match self {
            // ERC20 is a special case - not in the feature_contracts directory.
            Self::ERC20(cairo_version) => {

This is a bit confusing - you're over

Code quote:

        let cairo_version = self.cairo_version();
        let contract_name = match self {
            // ERC20 is a special case - not in the feature_contracts directory.
            Self::ERC20(cairo_version) => {

@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch 3 times, most recently from bf5e760 to a32af92 Compare July 31, 2024 16:51
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 1 files reviewed, 3 unresolved discussions (waiting on @aner-starkware, @AvivYossef-starkware, @meship-starkware, and @noaov1)


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

Previously, aner-starkware wrote…

Why are you adding this, if it's never used?

Done.


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

Previously, aner-starkware wrote…

The above question

Done.


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

Previously, aner-starkware wrote…

This is a bit confusing - you're over

what am I over?

@aner-starkware
Copy link
Contributor

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

Previously, dorimedini-starkware wrote…

what am I over?

Sorry, I forgot to complete the sentence 😅
You're overriding cairo_version before ever using it. Maybe consider postponing the first let statement, or using a different variable name (e.g., if you want to assert_eq)?

@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
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 1 files reviewed, 3 unresolved discussions (waiting on @aner-starkware, @AvivYossef-starkware, @meship-starkware, and @noaov1)


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

Previously, aner-starkware wrote…

Sorry, I forgot to complete the sentence 😅
You're overriding cairo_version before ever using it. Maybe consider postponing the first let statement, or using a different variable name (e.g., if you want to assert_eq)?

Right! Done.

@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
Copy link
Contributor

@aner-starkware aner-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 1 files reviewed, 1 unresolved discussion (waiting on @AvivYossef-starkware, @dorimedini-starkware, @meship-starkware, and @noaov1)


crates/blockifier/src/test_utils/contracts.rs line 236 at r3 (raw file):

            let base_name = Path::new(&source_path)
                .file_name()
                .unwrap()

Are we cool with all these unwraps?

Code quote:

.unwrap()

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 1 files reviewed, 1 unresolved discussion (waiting on @aner-starkware, @AvivYossef-starkware, @meship-starkware, and @noaov1)


crates/blockifier/src/test_utils/contracts.rs line 236 at r3 (raw file):

Previously, aner-starkware wrote…

Are we cool with all these unwraps?

in a test util? I'd say yes, would you prefer some be expects?

@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
Copy link
Contributor

@aner-starkware aner-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 1 files reviewed, all discussions resolved (waiting on @AvivYossef-starkware, @meship-starkware, and @noaov1)


crates/blockifier/src/test_utils/contracts.rs line 236 at r3 (raw file):

Previously, dorimedini-starkware wrote…

in a test util? I'd say yes, would you prefer some be expects?

OK, just checking.

Copy link
Contributor

@aner-starkware aner-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 1 files reviewed, all discussions resolved (waiting on @AvivYossef-starkware, @meship-starkware, and @noaov1)

@dorimedini-starkware dorimedini-starkware force-pushed the 07-29-chore_blockifier_refactor_feature_contract_path_getters_for_different_paths branch 4 times, most recently from 7d707f6 to 3da45df Compare August 7, 2024 16:16
@dorimedini-starkware dorimedini-starkware marked this pull request as ready for review August 8, 2024 09:52
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 r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @AvivYossef-starkware, @dorimedini-starkware, @meship-starkware, and @noaov1)


crates/blockifier/src/test_utils/contracts.rs line 240 at r3 (raw file):

                .unwrap()
                .strip_suffix(".cairo")
                .unwrap();

Your choice, but it seems easier to define a private func for the match mapping and just call it here and in the above, than to do this processing.

Code quote:

            let base_name = Path::new(&source_path)
                .file_name()
                .unwrap()
                .to_str()
                .unwrap()
                .strip_suffix(".cairo")
                .unwrap();

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, @noaov1, and @TzahiTaub)


crates/blockifier/src/test_utils/contracts.rs line 240 at r3 (raw file):

Previously, TzahiTaub (Tzahi) wrote…

Your choice, but it seems easier to define a private func for the match mapping and just call it here and in the above, than to do this processing.

wdym?
not that ERC20_CAIRO0_CONTRACT_SOURCE_PATH and ERC20_CAIRO0_CONTRACT_PATH are not the same

@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
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, @noaov1, and @TzahiTaub)


crates/blockifier/src/test_utils/contracts.rs line 240 at r3 (raw file):

Previously, dorimedini-starkware wrote…

wdym?
not that ERC20_CAIRO0_CONTRACT_SOURCE_PATH and ERC20_CAIRO0_CONTRACT_PATH are not the same

*note that

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.

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


crates/blockifier/src/test_utils/contracts.rs line 240 at r3 (raw file):

Previously, dorimedini-starkware wrote…

*note that

In "in the above" I meant here (in the else clause) and in the else of get_source_path. I.e., something like

fn get_non_erc20_base_filename(&self)) -> String:
      match self {
                    Self::AccountWithLongValidate(_) => ACCOUNT_LONG_VALIDATE_NAME,
                    Self::AccountWithoutValidations(_) => ACCOUNT_WITHOUT_VALIDATIONS_NAME,
                    Self::Empty(_) => EMPTY_CONTRACT_NAME,
                    Self::FaultyAccount(_) => FAULTY_ACCOUNT_NAME,
                    Self::LegacyTestContract => LEGACY_CONTRACT_NAME,
                    Self::SecurityTests => SECURITY_TEST_CONTRACT_NAME,
                    Self::TestContract(_) => TEST_CONTRACT_NAME,
                    Self::ERC20(_) => unreachable!(),
                }
 pub fn get_source_path(&self) -> String {
...
    else {
        let base_name = self.get_non_erc20_base_filename()
...
 pub fn get_compiled_path(&self) -> String {
...
    else {
        let base_name = self.get_non_erc20_base_filename()



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

:lgtm:

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @AvivYossef-starkware, @meship-starkware, and @noaov1)

Copy link
Collaborator Author

dorimedini-starkware commented Aug 11, 2024

Merge activity

@dorimedini-starkware dorimedini-starkware merged commit 6e385c9 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