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: add casm contract class struct compatible for executable transaction #357

Merged
merged 3 commits into from
Aug 12, 2024

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Aug 8, 2024

This is a draft. A PR composed of multiple commits, which show the process handled one step at a time.

refactor: add casm contract class struct compatible for executable transaction

refactor: use casm contract class for executable transaction

refactor: add try from executable declare tx to account tx

chore: remove handle of impossible scenarios


This change is Reviewable

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @ArniStarkware and the rest of your teammates on Graphite Graphite

@ArniStarkware ArniStarkware marked this pull request as ready for review August 8, 2024 07:00
Copy link
Collaborator

@dafnamatsry dafnamatsry left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 3 files at r1, 1 of 2 files at r2, 2 of 4 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware)


crates/blockifier/src/transaction/transactions.rs line 177 at r4 (raw file):

    }

    pub fn create_from_executable_tx(

Do we need both this and TryFrom?
You can either implement only TryFrom or make this method private.

Code quote:

pub fn create_from_executable_tx(

crates/blockifier/src/transaction/transactions.rs line 185 at r4 (raw file):

        let class_info: ClassInfo = class_info.try_into()?;

        // Assert that the ContractClass matches the TransactionVersion, and return the result.

Do you mean the ContractClassVersionMismatch error?
Self::create can also return other errors.

Also, I'm not sure what do you mean by "In this flow"?


crates/starknet_api/src/contract_class.rs line 1 at r4 (raw file):

use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;

Please add documentation for all of the new types.

@ArniStarkware ArniStarkware force-pushed the arni/refactor/tx_wrapper/class_info_in_snapi branch from fc926d3 to 5c954f4 Compare August 8, 2024 12:51
Copy link
Contributor Author

@ArniStarkware ArniStarkware 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: 3 of 6 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry)


crates/blockifier/src/transaction/transactions.rs line 177 at r4 (raw file):

Previously, dafnamatsry wrote…

Do we need both this and TryFrom?
You can either implement only TryFrom or make this method private.

Done.

(This fix assumes we are never going to call create_from_executable_tx with only_query = true. The only_query flow is deprecated anyway IIUC).


crates/blockifier/src/transaction/transactions.rs line 185 at r4 (raw file):

Previously, dafnamatsry wrote…

Do you mean the ContractClassVersionMismatch error?
Self::create can also return other errors.

Also, I'm not sure what do you mean by "In this flow"?

Removed. I was mistaken.
The PR is now comprised of 3 commits only.

(For the record: I do mean the ContractClassVersionMismatch error.
IIUC, Self::create can return only this error. The only possible fail is on verify_contract_class_version, which can only fail on ContractClassVersionMismatch - or am I missing something?
The issue is - that this method can indeed fail in "In this flow". There are inputs for this function that may cause it to fail.)


crates/starknet_api/src/contract_class.rs line 1 at r4 (raw file):

Previously, dafnamatsry wrote…

Please add documentation for all of the new types.

Done.

@ArniStarkware ArniStarkware force-pushed the arni/refactor/tx_wrapper/class_info_in_snapi branch from 5c954f4 to 19f98a9 Compare August 8, 2024 12:59
Copy link
Collaborator

@dafnamatsry dafnamatsry 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 3 of 3 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware)

Copy link
Contributor

@MohammadNassar1 MohammadNassar1 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: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware and @dafnamatsry)


crates/blockifier/src/execution/contract_class.rs line 504 at r5 (raw file):

    type Error = ProgramError;

    fn try_from(value: starknet_api::contract_class::ClassInfo) -> Result<Self, Self::Error> {

Suggestion:

class_info

crates/blockifier/src/transaction/transactions.rs line 142 at r5 (raw file):

    fn try_from(
        value: starknet_api::executable_transaction::DeclareTransaction,

Suggestion:

declare_tx

@ArniStarkware ArniStarkware force-pushed the arni/refactor/tx_wrapper/class_info_in_snapi branch from 19f98a9 to fdd1323 Compare August 11, 2024 14:40
Copy link
Contributor Author

@ArniStarkware ArniStarkware 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: 4 of 6 files reviewed, 1 unresolved discussion (waiting on @dafnamatsry)


crates/blockifier/src/execution/contract_class.rs line 504 at r5 (raw file):

    type Error = ProgramError;

    fn try_from(value: starknet_api::contract_class::ClassInfo) -> Result<Self, Self::Error> {

Done.


crates/blockifier/src/transaction/transactions.rs line 142 at r5 (raw file):

    fn try_from(
        value: starknet_api::executable_transaction::DeclareTransaction,

Done.

Copy link
Collaborator

@dafnamatsry dafnamatsry left a comment

Choose a reason for hiding this comment

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

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

@ArniStarkware ArniStarkware merged commit a4ced95 into main Aug 12, 2024
14 checks passed
@ArniStarkware ArniStarkware deleted the arni/refactor/tx_wrapper/class_info_in_snapi branch August 12, 2024 06:43
@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