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

refactor(transaction): make the only query field in declare tx public #170

Conversation

meship-starkware
Copy link
Contributor

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

This change is Reviewable

@meship-starkware meship-starkware changed the title refactor(transactions):make the only query field in declare tx public refactor(transactions): make the only query field in declare tx public Jul 29, 2024
@meship-starkware meship-starkware force-pushed the meship/blockifier/make_declare_tx_only_query_public branch from ebb40ea to 03cc397 Compare July 29, 2024 11:16
@meship-starkware meship-starkware changed the title refactor(transactions): make the only query field in declare tx public refactor(transaction): make the only query field in declare tx public Jul 29, 2024
@meship-starkware meship-starkware force-pushed the meship/blockifier/make_declare_tx_only_query_public branch from 03cc397 to 906d838 Compare July 29, 2024 11:17
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 1 files reviewed, 1 unresolved discussion (waiting on @noaov1)

a discussion (no related file):
@tdelabro


Copy link
Collaborator

@noaov1 noaov1 left a comment

Choose a reason for hiding this comment

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

Doing this allow to create an incorrect declare transaction (we want to enforce calling verify_contract_class_version).

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1)

Copy link
Collaborator

@noaov1 noaov1 left a comment

Choose a reason for hiding this comment

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

You can let the create method be public. We may need to consider the necessity of the method new_for_query (and maybe define new only for tests).

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1)

@noaov1 noaov1 self-requested a review July 30, 2024 11:53
@meship-starkware meship-starkware force-pushed the meship/blockifier/make_declare_tx_only_query_public branch from 906d838 to d8c8b8d Compare July 30, 2024 12:04
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 1 files reviewed, 2 unresolved discussions (waiting on @noaov1)


crates/blockifier/src/transaction/transactions.rs line 136 at r2 (raw file):

    pub tx_hash: TransactionHash,
    // Indicates the presence of the only_query bit in the version.
    only_query: bool,

Changing only query to a pub trait will allow users to create a Declare tx struct without using create. we want to enforce calling verify_contract_class_version so it is problematic.

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 1 files reviewed, 2 unresolved discussions (waiting on @noaov1)


crates/blockifier/src/transaction/transactions.rs line 136 at r2 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

Changing only query to a pub trait will allow users to create a Declare tx struct without using create. we want to enforce calling verify_contract_class_version so it is problematic.

@tdelabro WDYT? Do you have another suggestion?

@tdelabro
Copy link

@meship-starkware
starkware-libs/blockifier#1725 (comment)

You then need to be coherent and make it private for the other transactions types too

@meship-starkware meship-starkware force-pushed the meship/blockifier/make_declare_tx_only_query_public branch from d8c8b8d to f1a6805 Compare July 31, 2024 07:04
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 1 files reviewed, 3 unresolved discussions (waiting on @noaov1)


crates/blockifier/src/transaction/transactions.rs line 292 at r2 (raw file):

    // Indicates the presence of the only_query bit in the version.
    pub only_query: bool,
}

This change means that we will have to create a Deploy Account tx using new and new for query.

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.

After some discussion, we decided that making it private is not a good solution because it is less readable, it is not clear why the only query is private there, and it is a breaking change. A solution that @noaov1 has suggested is making the only query public in declare but making the class info private. This is also a breaking change, but it makes more sense because the declare struct needs to be private because we need to check the class info in the constructor.

Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @noaov1)

Copy link

@tdelabro tdelabro left a comment

Choose a reason for hiding this comment

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

making it private is not a good solution because it is less readable

What about adding a getter? tx.is_query() is not less readable thattx.only_query

making the only query public in declare but making the class info private

@noaov1 has a good point that if we force users to use our create method in order to check for the class_info data, maybe we shouldn't allow users to change it's content afterward.
Note that the create method don't just use the class_info

    fn create(
        declare_tx: starknet_api::transaction::DeclareTransaction,
        tx_hash: TransactionHash,
        class_info: ClassInfo,
        only_query: bool,
    ) -> TransactionExecutionResult<Self> {
        let declare_version = declare_tx.version();
        verify_contract_class_version(&class_info.contract_class(), declare_version)?;
        Ok(Self { tx: declare_tx, tx_hash, class_info, only_query })
    }

It uses data from both declare_tx and class_info to call verify_contract_class_version, so those two fields should be private and only accessible through getters

Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @noaov1)

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.

It will be solved in a future PR.

Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @noaov1)

@meship-starkware meship-starkware deleted the meship/blockifier/make_declare_tx_only_query_public branch September 26, 2024 09:00
@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 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