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): remove dupl tip() and resource_bounds() in AccountTx #2101

Merged

Conversation

avivg-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@avivg-starkware avivg-starkware marked this pull request as ready for review November 17, 2024 10:57
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/refactor_account_tx_tip_resource_bounds branch from 20f4544 to ca92528 Compare November 17, 2024 10:58
Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link

codecov bot commented Nov 17, 2024

Codecov Report

Attention: Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.

Project coverage is 74.43%. Comparing base (e3165c4) to head (855ade9).
Report is 596 commits behind head on main.

Files with missing lines Patch % Lines
.../blockifier/src/transaction/account_transaction.rs 0.00% 3 Missing ⚠️
crates/starknet_api/src/executable_transaction.rs 66.66% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2101       +/-   ##
===========================================
+ Coverage   40.10%   74.43%   +34.33%     
===========================================
  Files          26      129      +103     
  Lines        1895    14904    +13009     
  Branches     1895    14904    +13009     
===========================================
+ Hits          760    11094    +10334     
- Misses       1100     3327     +2227     
- Partials       35      483      +448     

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

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/refactor_account_tx_tip_resource_bounds branch from ca92528 to fae60a0 Compare November 17, 2024 11:17
Copy link

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/refactor_account_tx_tip_resource_bounds branch from fae60a0 to b436fef Compare November 17, 2024 12:34
@avivg-starkware avivg-starkware changed the base branch from main to avivg/blockifier/signature_length_simple_code_cleanup November 17, 2024 12:34
Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link

Benchmark movements:
tree_computation_flow performance regressed!
tree_computation_flow time: [34.838 ms 35.313 ms 35.877 ms]
change: [+1.3293% +2.7762% +4.4491%] (p = 0.00 < 0.05)
Performance has regressed.
Found 10 outliers among 100 measurements (10.00%)
1 (1.00%) high mild
9 (9.00%) high severe

Copy link
Contributor Author

@avivg-starkware avivg-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 3 files reviewed, 1 unresolved discussion


crates/starknet_api/src/executable_transaction.rs line 113 at r1 (raw file):

                _ => None,
            },
        }

looks like this is already being handled as part of the implementation of tx.tx.resource_bounds() (same for tip)

Code snippet (i):

implement_v3_tx_getters!(
        (resource_bounds, ValidResourceBounds),

Code snippet (ii):

macro_rules! implement_v3_tx_getters {
    ($(($field:ident, $field_type:ty)),*) => {
        $(pub fn $field(&self) -> $field_type {
            match self {
                Self::V3(tx) => tx.$field.clone(),
                _ => panic!("{:?} do not support the field {}; they are only available for V3 transactions.", self.version(), stringify!($field)),
            }
        })*
    };
}

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/signature_length_simple_code_cleanup branch from bb05e10 to 8706fa8 Compare November 17, 2024 13:07
Copy link
Collaborator

@Yoni-Starkware Yoni-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 3 files reviewed, 2 unresolved discussions (waiting on @avivg-starkware)


crates/starknet_api/src/executable_transaction.rs line 113 at r1 (raw file):

Previously, avivg-starkware wrote…

looks like this is already being handled as part of the implementation of tx.tx.resource_bounds() (same for tip)

What does it mean?


crates/blockifier/src/transaction/account_transaction.rs line 113 at r1 (raw file):

        })*
    };
}

Is this still needed?

Code quote:

macro_rules! implement_account_tx_inner_getters {
    ($(($field:ident, $field_type:ty)),*) => {
        $(pub fn $field(&self) -> $field_type {
            match &self.tx {
                // TODO(AvivG): Consider moving some of the logic to the Transaction enum.
                Transaction::Declare(tx) => tx.tx.$field().clone(),
                Transaction::DeployAccount(tx) => tx.tx.$field().clone(),
                Transaction::Invoke(tx) => tx.tx.$field().clone(),
            }
        })*
    };
}

@avivg-starkware
Copy link
Contributor Author

crates/starknet_api/src/executable_transaction.rs line 113 at r1 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

What does it mean?

in both funcs above we're making sure that the field 'tx' of the enum AccountTransaction is of version v3.
This 'tx' is either
starknet_api::transaction::InvokeTransaction or
starknet_api::transaction::DeployAccountTransaction or
starknet_api::transaction::DeclareTransaction

However, for each of those, there is a func resource_bounds() which implements the above macro, and thus panicking if version != v3

there was a duplication, as the blockifier's AccountTransaction implementation didn't actually use the api's AccountTransaction's implementation of those funcs, but rather accessed 'directly' the implementation of the starknet_api::transaction.

With that said, the key difference between the 2 implementations I see are: the use of panic vs except (w Option) and clone() vs passing a ref.

Perhaps better to leave things as they were?

@avivg-starkware
Copy link
Contributor Author

crates/blockifier/src/transaction/account_transaction.rs line 113 at r1 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Is this still needed?

Yes as all the below funcs are not implemented by 'Transaction' (= starknet_api::executable_transaction::AccountTransaction)

Code snippet:

        (signature, TransactionSignature),
        (nonce, Nonce),
        (nonce_data_availability_mode, DataAvailabilityMode),
        (fee_data_availability_mode, DataAvailabilityMode),
        (paymaster_data, PaymasterData)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/signature_length_simple_code_cleanup branch from 8706fa8 to 49829be Compare November 17, 2024 13:53
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/refactor_account_tx_tip_resource_bounds branch from b436fef to 17fc2be Compare November 17, 2024 13:53
Copy link

Artifacts upload triggered. View details here

Copy link
Collaborator

@Yoni-Starkware Yoni-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 1 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @avivg-starkware)


crates/blockifier/src/transaction/account_transaction.rs line 113 at r1 (raw file):

Previously, avivg-starkware wrote…

Yes as all the below funcs are not implemented by 'Transaction' (= starknet_api::executable_transaction::AccountTransaction)

Can you use implement_tx_getter_calls! instead of implement_account_tx_inner_getters! now?


crates/starknet_api/src/executable_transaction.rs line 113 at r1 (raw file):

Previously, avivg-starkware wrote…

in both funcs above we're making sure that the field 'tx' of the enum AccountTransaction is of version v3.
This 'tx' is either
starknet_api::transaction::InvokeTransaction or
starknet_api::transaction::DeployAccountTransaction or
starknet_api::transaction::DeclareTransaction

However, for each of those, there is a func resource_bounds() which implements the above macro, and thus panicking if version != v3

there was a duplication, as the blockifier's AccountTransaction implementation didn't actually use the api's AccountTransaction's implementation of those funcs, but rather accessed 'directly' the implementation of the starknet_api::transaction.

With that said, the key difference between the 2 implementations I see are: the use of panic vs except (w Option) and clone() vs passing a ref.

Perhaps better to leave things as they were?

Thanks!

Copy link
Collaborator

@Yoni-Starkware Yoni-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: 2 of 3 files reviewed, all discussions resolved


crates/blockifier/src/transaction/account_transaction.rs line 113 at r1 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Can you use implement_tx_getter_calls! instead of implement_account_tx_inner_getters! now?

Oh you are doing it in a later PR, so LGTM as long as that future PR gets in :)

Copy link
Collaborator

@Yoni-Starkware Yoni-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: 2 of 3 files reviewed, all discussions resolved


crates/blockifier/src/transaction/account_transaction.rs line 113 at r1 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Oh you are doing it in a later PR, so LGTM as long as that future PR gets in :)

(Should have been part of this PR)

@avivg-starkware
Copy link
Contributor Author

crates/blockifier/src/transaction/account_transaction.rs line 113 at r1 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

(Should have been part of this PR)

I see, will know for the next :)

Copy link
Collaborator

@Yoni-Starkware Yoni-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 1 of 3 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @avivg-starkware)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/signature_length_simple_code_cleanup branch from 49829be to 8b701d7 Compare November 20, 2024 16:03
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/refactor_account_tx_tip_resource_bounds branch from 17fc2be to ec2e90c Compare November 20, 2024 16:03
Copy link

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware changed the base branch from avivg/blockifier/signature_length_simple_code_cleanup to graphite-base/2101 November 27, 2024 09:41
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/refactor_account_tx_tip_resource_bounds branch from ec2e90c to 1a73e85 Compare November 27, 2024 09:41
@avivg-starkware avivg-starkware changed the base branch from graphite-base/2101 to main November 27, 2024 09:42
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/refactor_account_tx_tip_resource_bounds branch from 1a73e85 to eb22856 Compare November 27, 2024 09:42
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/refactor_account_tx_tip_resource_bounds branch from 1a73e85 to 855ade9 Compare November 27, 2024 10:18
@avivg-starkware avivg-starkware changed the title chore(blockifier): remove duplicacy tip() and resource_bounds() in AccountTransaction chore(blockifier): remove dupl tip() and resource_bounds() in AccountTx Nov 27, 2024
Copy link
Collaborator

@Yoni-Starkware Yoni-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:

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

@avivg-starkware avivg-starkware merged commit a44a243 into main Nov 27, 2024
16 of 28 checks passed
@avivg-starkware avivg-starkware deleted the avivg/blockifier/refactor_account_tx_tip_resource_bounds branch November 27, 2024 12:43
@github-actions github-actions bot locked and limited conversation to collaborators Nov 29, 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