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: refactor deploy account as wrapper #92

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Jul 25, 2024

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

For internal deploy account transaction, the data is inseparable from the implementation.
The data of IntrnalDeployAccountTransaction and of DeployAccountTransaction (on the blockifier) is duplicated.

What is the new behavior?

  • Refactor DeployAccountTransaction as a wrapper of IntrnalDeployAccountTransaction while keeping the implementation.

Does this introduce a breaking change?

  • Yes
  • No

Other information


This change is Reviewable

Copy link
Contributor Author

ArniStarkware commented Jul 25, 2024

@ArniStarkware ArniStarkware marked this pull request as ready for review July 25, 2024 10:38
@ArniStarkware ArniStarkware force-pushed the arni/refactor/account_tx_wrapper/deploy_account branch from ff1164f to a491474 Compare July 31, 2024 09:43
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: 0 of 9 files reviewed, all discussions resolved (waiting on @dafnamatsry and @MohammadNassar1)


crates/blockifier/src/transaction/account_transaction.rs line 77 at r2 (raw file):

        match self {
            Self::Declare(tx) => tx.tx.version(),
            Self::DeployAccount(tx) => tx.tx.tx.version(),

Yuck.

Code quote:

            Self::DeployAccount(tx) => tx.tx.tx.version(),

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


crates/blockifier/src/transaction/account_transaction.rs line 77 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Yuck.

OMG!


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

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

Can we use Deref here?
So, we don't need to add tx in all the place?

Code quote:

pub struct DeployAccountTransaction {
    pub tx: starknet_api::executable_transaction::DeployAccountTransaction,
    // Indicates the presence of the only_query bit in the version.
    pub only_query: bool,
}

@ArniStarkware
Copy link
Contributor Author

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

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Can we use Deref here?
So, we don't need to add tx in all the place?

I am unfamiliar with this design pattern ( I assume this is what you mean).
Please elaborate.

@ArniStarkware
Copy link
Contributor Author

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

Previously, ArniStarkware (Arnon Hod) wrote…

I am unfamiliar with this design pattern ( I assume this is what you mean).
Please elaborate.

Upon further reading - I think I understand.

@ArniStarkware ArniStarkware force-pushed the arni/refactor/account_tx_wrapper/deploy_account branch from a491474 to e90a275 Compare July 31, 2024 12:28
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: 0 of 10 files reviewed, all discussions resolved (waiting on @dafnamatsry and @MohammadNassar1)


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

Previously, ArniStarkware (Arnon Hod) wrote…

Upon further reading - I think I understand.

Done.

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 10 of 10 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ArniStarkware and @dafnamatsry)


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

Previously, ArniStarkware (Arnon Hod) wrote…

Done.

Nice!


crates/blockifier/src/transaction/transactions.rs line 383 at r3 (raw file):

        };

        match &self.tx.tx {

Deref cannot work here?

Code quote:

&self.tx.tx 

crates/starknet_api/src/executable_transaction.rs line 71 at r3 (raw file):

}

impl std::ops::Deref for DeployAccountTransaction {

Suggestion:

Deref

@ArniStarkware ArniStarkware force-pushed the arni/refactor/account_tx_wrapper/deploy_account branch from e90a275 to 8d26abe Compare August 1, 2024 06:24
@ArniStarkware ArniStarkware changed the base branch from main to arni/refactor/account_tx_wrapper/deref_in_account_txs August 1, 2024 06:25
@ArniStarkware ArniStarkware force-pushed the arni/refactor/account_tx_wrapper/deploy_account branch from 8d26abe to 100b093 Compare August 1, 2024 14:04
@ArniStarkware ArniStarkware changed the base branch from arni/refactor/account_tx_wrapper/deref_in_account_txs to main August 1, 2024 14:04
@ArniStarkware
Copy link
Contributor Author

crates/starknet_api/src/executable_transaction.rs line 71 at r3 (raw file):

}

impl std::ops::Deref for DeployAccountTransaction {

No longer relevant.

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: 0 of 10 files reviewed, 1 unresolved discussion (waiting on @dafnamatsry and @MohammadNassar1)


crates/blockifier/src/transaction/transactions.rs line 383 at r3 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Deref cannot work here?

Used a different approch.

Copy link

codecov bot commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 78.37838% with 8 lines in your changes missing coverage. Please review.

Project coverage is 76.83%. Comparing base (495b403) to head (100b093).
Report is 1 commits behind head on main.

Files Patch % Lines
crates/blockifier/src/transaction/transactions.rs 66.66% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #92      +/-   ##
==========================================
+ Coverage   76.81%   76.83%   +0.02%     
==========================================
  Files         312      312              
  Lines       34446    34480      +34     
  Branches    34446    34480      +34     
==========================================
+ Hits        26458    26494      +36     
+ Misses       5702     5701       -1     
+ Partials     2286     2285       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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


crates/starknet_api/src/executable_transaction.rs line 106 at r4 (raw file):

    pub fn contract_address(&self) -> ContractAddress {
        self.contract_address
    }

What do you think about using a macro instead?

Code quote:

    pub fn tx(&self) -> &crate::transaction::DeployAccountTransaction {
        &self.tx
    }

    pub fn tx_hash(&self) -> TransactionHash {
        self.tx_hash
    }

    pub fn contract_address(&self) -> ContractAddress {
        self.contract_address
    }

@ArniStarkware ArniStarkware force-pushed the arni/refactor/account_tx_wrapper/deploy_account branch from 100b093 to fe6f0a3 Compare August 4, 2024 06:43
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: 9 of 10 files reviewed, 1 unresolved discussion (waiting on @dafnamatsry and @MohammadNassar1)


crates/starknet_api/src/executable_transaction.rs line 106 at r4 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

What do you think about using a macro instead?

Done.
I did not create a macro just for the ref for tx, as this is just one line. (It will repeat 3 times eventually - we can add it then if we wish).

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.

:lgtm:

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry)

@ArniStarkware ArniStarkware force-pushed the arni/refactor/account_tx_wrapper/deploy_account branch 2 times, most recently from dd0da5e to bdc47af Compare August 14, 2024 08:04
@ArniStarkware ArniStarkware force-pushed the arni/refactor/account_tx_wrapper/deploy_account branch 2 times, most recently from cfb3c39 to 78b45af Compare August 20, 2024 07:22
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 4 of 10 files at r4, 5 of 5 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArniStarkware)

@ArniStarkware ArniStarkware force-pushed the arni/refactor/account_tx_wrapper/deploy_account branch from 78b45af to 0fe0829 Compare August 20, 2024 11:35
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 2 of 2 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArniStarkware)

Copy link
Contributor Author

ArniStarkware commented Aug 20, 2024

Merge activity

@ArniStarkware ArniStarkware merged commit f6d3b2e into main Aug 20, 2024
13 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2024
@ArniStarkware ArniStarkware deleted the arni/refactor/account_tx_wrapper/deploy_account branch September 22, 2024 11:36
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