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(blockifier): remove enforce fee from actual fee #835

Merged

Conversation

avivg-starkware
Copy link
Contributor

@avivg-starkware avivg-starkware commented Sep 17, 2024

This change is Reviewable

Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 69.13%. Comparing base (e3165c4) to head (8a1bdd4).
Report is 85 commits behind head on main.

Files with missing lines Patch % Lines
crates/blockifier/src/concurrency/fee_utils.rs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #835       +/-   ##
===========================================
+ Coverage   40.10%   69.13%   +29.02%     
===========================================
  Files          26      100       +74     
  Lines        1895    13447    +11552     
  Branches     1895    13447    +11552     
===========================================
+ Hits          760     9296     +8536     
- Misses       1100     3749     +2649     
- Partials       35      402      +367     

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

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 3867e46 to 0e790d8 Compare September 17, 2024 08:15
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources branch from 843da5d to 6c9a32d Compare September 17, 2024 08:15
Copy link
Contributor

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

Reviewed 3 of 3 files at r1, 1 of 8 files at r2, 9 of 9 files at r3, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @avivg-starkware and @noaov1)


crates/blockifier/src/concurrency/fee_utils.rs line 66 at r3 (raw file):

        //     // Fee(0),
        //     "Transaction with no fee transfer info must have zero fee."
        // )

Remove this code.

Code quote:

        // assert_eq!(
        //     //aviv: changes:
        //     // tx_execution_info.receipt.fee,
        //     // Fee(0),
        //     "Transaction with no fee transfer info must have zero fee."
        // )

crates/blockifier/src/fee/actual_cost.rs line 107 at r3 (raw file):

        // } else {
        //     Fee(0)
        // };

Remove this code.

Code quote:

        // L1 handler transactions are not charged an L2 fee but it is compared to the L1 fee.
        // PREV:
        // let fee = if tx_context.tx_info.enforce_fee() || tx_type == TransactionType::L1Handler {
        //     tx_context.tx_info.get_fee_by_gas_vector(&tx_context.block_context.block_info, gas)
        // } else {
        //     Fee(0)
        // };

crates/blockifier/src/fee/actual_cost.rs line 108 at r3 (raw file):

        //     Fee(0)
        // };
        let fee = if tx_type == TransactionType::Declare

Please document this line

Suggestion:

// To be backward compatible with the meaning of enforce fee in Declare V0. 
let fee = if tx_type == TransactionType::Declare

crates/blockifier/src/transaction/account_transaction.rs line 362 at r3 (raw file):

        concurrency_mode: bool,
    ) -> TransactionExecutionResult<Option<CallInfo>> {
        // aviv: if !charge_fee || actual_fee == Fee(0) {

Remove all aviv comments.


crates/blockifier/src/transaction/transactions_test.rs line 1281 at r3 (raw file):

                FeatureContract::ERC20(CairoVersion::Cairo0).get_class_hash(),
            )
        };

I think it is a bit cleaner this way

Suggestion:

    let (expected_actual_fee, expected_fee_transfer_call_info) =
        if tx_version == TransactionVersion::ZERO {
            (Fee(0), None)
        } else {
            let expected_actual_fee = actual_execution_info.receipt.resources.calculate_tx_fee(block_context, fee_type).unwrap();
            (
                expected_actual_fee,
                expected_fee_transfer_call_info(
                    tx_context,
                    sender_address,
                    expected_actual_fee,
                    FeatureContract::ERC20(CairoVersion::Cairo0).get_class_hash(),
                ),
            )
        };

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources branch from 6c9a32d to 49d8c5c Compare September 17, 2024 11:54
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 0e790d8 to 0f6d7cd Compare September 17, 2024 12:13
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources branch 2 times, most recently from 03a7b88 to 8cbac73 Compare September 17, 2024 13:10
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 0f6d7cd to 1de7cbc Compare September 17, 2024 13:11
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources branch from 8cbac73 to 3df10e1 Compare September 17, 2024 13:25
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 1de7cbc to 41620d5 Compare September 17, 2024 13:27
Copy link
Contributor

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

Reviewed 1 of 1 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @avivg-starkware and @noaov1)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources branch 2 times, most recently from a4006fc to cf3b295 Compare September 19, 2024 14:40
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 41620d5 to 608770a Compare September 19, 2024 14:58
Copy link
Contributor

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

Reviewed 9 of 9 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avivg-starkware and @noaov1)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources branch 2 times, most recently from 3e17257 to 8491603 Compare September 29, 2024 13:30
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 608770a to 43641ba Compare September 29, 2024 16:01
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources branch 2 times, most recently from 7209bbc to 80313b5 Compare September 29, 2024 16:32
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 43641ba to 35cfca9 Compare September 29, 2024 16:36
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources branch 2 times, most recently from dc71e1f to ccd61ea Compare September 29, 2024 16:48
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch 2 times, most recently from 10ca196 to 5429911 Compare September 30, 2024 08:12
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: 2 of 17 files reviewed, 1 unresolved discussion (waiting on @meship-starkware and @noaov1)


crates/blockifier/src/concurrency/fee_utils.rs line 66 at r3 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

Remove this code.

Done.


crates/blockifier/src/transaction/account_transaction.rs line 362 at r3 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

Remove all aviv comments.

Done


crates/blockifier/src/transaction/transactions_test.rs line 1281 at r3 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

I think it is a bit cleaner this way

Done


crates/blockifier/src/fee/actual_cost.rs line 107 at r3 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

Remove this code.

Done.

Copy link
Contributor

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

Reviewed 6 of 15 files at r7, all commit messages.
Reviewable status: 8 of 17 files reviewed, 2 unresolved discussions (waiting on @avivg-starkware and @noaov1)


crates/starknet_api/src/transaction.rs line 1098 at r8 (raw file):

            l1_data_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 1 },
        };
        Self::AllResources(resource_bounds)

Why is it part of this PR?

Code quote:

        // Self::L1Gas(ResourceBounds { max_amount: 0, max_price_per_unit: 1 })
        // Aviv: suggestion?
        let resource_bounds = AllResourceBounds {
            l1_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 1 },
            l2_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 1 },
            l1_data_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 1 },
        };
        Self::AllResources(resource_bounds)

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: 18 of 20 files reviewed, 2 unresolved discussions (waiting on @meship-starkware and @noaov1)


crates/blockifier/src/transaction/transactions_test.rs line 1395 at r15 (raw file):

Previously, noaov1 (Noa Oved) wrote…

Why is it needed now?

for the case of V0 where charge_fee = false

@avivg-starkware
Copy link
Contributor Author

Copy link
Contributor

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

Reviewed 1 of 1 files at r18, all commit messages.
Reviewable status: 19 of 20 files reviewed, 2 unresolved discussions (waiting on @noaov1)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 6998181 to 3b2428e Compare October 14, 2024 12:11
Copy link
Contributor

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

Reviewed 1 of 1 files at r19, all commit messages.
Reviewable status: 19 of 20 files reviewed, 2 unresolved discussions (waiting on @noaov1)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources branch from b7acb06 to 8408f29 Compare October 14, 2024 13:18
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.

Reviewed 5 of 8 files at r16, 1 of 2 files at r17, 1 of 1 files at r19, all commit messages.
Reviewable status: 19 of 20 files reviewed, 2 unresolved discussions (waiting on @avivg-starkware and @meship-starkware)


crates/blockifier/src/transaction/account_transaction.rs line 468 at r19 (raw file):

        if !charge_fee {
            // Fee charging is not enforced in some tests.
            return Ok(None);

I think we should revert this change. If the actual fee equals 0 there is no need to charge fee.
When can this happen?
Only in declare V0.
(and please leave here the "transaction simulation").

Code quote:

        if !charge_fee {
            // Fee charging is not enforced in some tests.
            return Ok(None);

crates/blockifier/src/transaction/transactions_test.rs line 1395 at r15 (raw file):

Previously, avivg-starkware wrote…

for the case of V0 where charge_fee = false

See my comment above.

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources branch 3 times, most recently from ad89489 to 3c6fe63 Compare October 15, 2024 14:00
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 3b2428e to 88e2fa5 Compare October 15, 2024 14:09
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: 11 of 20 files reviewed, 2 unresolved discussions (waiting on @meship-starkware and @noaov1)


crates/blockifier/src/transaction/transactions_test.rs line 1395 at r15 (raw file):

Previously, noaov1 (Noa Oved) wrote…

See my comment above.

removed


crates/blockifier/src/transaction/account_transaction.rs line 468 at r19 (raw file):

Previously, noaov1 (Noa Oved) wrote…

I think we should revert this change. If the actual fee equals 0 there is no need to charge fee.
When can this happen?
Only in declare V0.
(and please leave here the "transaction simulation").

Done.

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from e4dad9c to 88e2fa5 Compare October 15, 2024 16:17
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.

Reviewed 8 of 8 files at r20, all commit messages.
Reviewable status: 19 of 20 files reviewed, all discussions resolved (waiting on @meship-starkware)

@avivg-starkware avivg-starkware changed the base branch from avivg/blockifier/combine_charge_fee_w_limit_steps_by_resources to main October 21, 2024 14:30
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 88e2fa5 to 5d61ccb Compare October 21, 2024 14:33
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.

Reviewed 3 of 3 files at r21, all commit messages.
Reviewable status: 19 of 20 files reviewed, all discussions resolved (waiting on @meship-starkware)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 5d61ccb to 711b445 Compare October 27, 2024 12:13
Copy link

Artifacts upload triggered. View details here

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from 711b445 to a5cc906 Compare October 28, 2024 09:04
Copy link

Artifacts upload triggered. View details here

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.

:lgtm:

Reviewed 1 of 8 files at r16, 3 of 3 files at r22, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @meship-starkware)

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/remove_enforce_fee_from_actual_fee branch from a5cc906 to 8a1bdd4 Compare October 30, 2024 12:22
Copy link

Artifacts upload triggered. View details here

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.

Reviewed 1 of 9 files at r6, 2 of 15 files at r7, 3 of 17 files at r12, 5 of 10 files at r13, 1 of 8 files at r16, 4 of 8 files at r20, 1 of 3 files at r21, 1 of 3 files at r22, 2 of 2 files at r23, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @meship-starkware)

@avivg-starkware avivg-starkware merged commit 08d998b into main Oct 30, 2024
12 checks passed
@avivg-starkware avivg-starkware deleted the avivg/blockifier/remove_enforce_fee_from_actual_fee branch October 30, 2024 15:28
@github-actions github-actions bot locked and limited conversation to collaborators Nov 2, 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