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

build(blockifier): add l2_gas_price to blockinfo #463

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

aner-starkware
Copy link
Contributor

@aner-starkware aner-starkware commented Aug 14, 2024

This change is Reviewable

@aner-starkware aner-starkware self-assigned this Aug 14, 2024
@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type branch 2 times, most recently from bbd32ad to 208296e Compare August 15, 2024 05:38
@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type_2 branch from cfc41e8 to e7d1170 Compare August 15, 2024 05:44
@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type branch from 208296e to e45b885 Compare August 15, 2024 05:46
@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type_2 branch 2 times, most recently from c9d045a to 5be70be Compare August 15, 2024 06:20
Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 65.38462% with 18 lines in your changes missing coverage. Please review.

Project coverage is 76.40%. Comparing base (72fa342) to head (a03834c).
Report is 4 commits behind head on main.

Files Patch % Lines
crates/native_blockifier/src/py_state_diff.rs 25.00% 14 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #463      +/-   ##
==========================================
- Coverage   76.42%   76.40%   -0.03%     
==========================================
  Files         349      349              
  Lines       36936    36965      +29     
  Branches    36936    36965      +29     
==========================================
+ Hits        28228    28242      +14     
- Misses       6384     6396      +12     
- Partials     2324     2327       +3     

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

@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type_2 branch from 5be70be to 1aa8dd3 Compare August 15, 2024 06:32
Copy link
Contributor

@yair-starkware yair-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 18 files reviewed, 1 unresolved discussion (waiting on @aner-starkware and @ShahakShama)


crates/papyrus_execution/src/lib.rs line 363 at r2 (raw file):

            NonZeroU128::new(l1_data_gas_price.price_in_fri.0).unwrap_or(NonZeroU128::MIN),
            NonZeroU128::MIN,
            NonZeroU128::MIN,

I think these should come from the pending_data/block_header same way the l1 gas is

Code quote:

            NonZeroU128::MIN,
            NonZeroU128::MIN,

@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type_2 branch 2 times, most recently from b4b40bd to 8872156 Compare August 15, 2024 10:17
Copy link
Contributor Author

@aner-starkware aner-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 18 files reviewed, 1 unresolved discussion (waiting on @ShahakShama)


crates/papyrus_execution/src/lib.rs line 363 at r2 (raw file):

Previously, yair-starkware (Yair) wrote…

I think these should come from the pending_data/block_header same way the l1 gas is

@ShahakShama told me to leave a TODO for this for now (see the first revision - it doesn't compile)

Copy link
Collaborator

@dorimedini-starkware dorimedini-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 18 files at r1, 1 of 15 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: 6 of 18 files reviewed, 5 unresolved discussions (waiting on @aner-starkware, @ShahakShama, and @TzahiTaub)


crates/blockifier/src/blockifier/block.rs line 55 at r3 (raw file):

                .expect("L1 to L2 price conversion error (Rust side).")
        {
            warn!("eth_l2_gas_price does not match expected!")

I suggest you output some numbers here: expected price, actual price, and the ratio
X2 (also below)

Code quote:

warn!("eth_l2_gas_price does not match expected!")

crates/gateway/src/rpc_objects.rs line 94 at r3 (raw file):

                parse_gas_price(self.l1_data_gas_price.price_in_fri)?,
                NonZeroU128::MIN,
                NonZeroU128::MIN,

shouldn't this be part of the block header @ShahakShama ?

Code quote:

                parse_gas_price(self.l1_data_gas_price.price_in_fri)?,
                NonZeroU128::MIN,
                NonZeroU128::MIN,

crates/native_blockifier/src/py_state_diff.rs line 216 at r3 (raw file):

                block_info.l2_gas_price.price_in_wei.try_into().map_err(|_| {
                    NativeBlockifierInputError::InvalidNativeBlockifierInputError(
                        InvalidNativeBlockifierInputError::InvalidGasPriceWei(

add a variant for this

Suggestion:

InvalidL2GasPriceWei

crates/native_blockifier/src/py_state_diff.rs line 223 at r3 (raw file):

                block_info.l2_gas_price.price_in_fri.try_into().map_err(|_| {
                    NativeBlockifierInputError::InvalidNativeBlockifierInputError(
                        InvalidNativeBlockifierInputError::InvalidGasPriceFri(

ditto

Suggestion:

InvalidL2GasPriceFri

@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type branch from e45b885 to 61ba588 Compare August 15, 2024 11:06
Copy link
Collaborator

@dorimedini-starkware dorimedini-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 12 of 15 files at r2.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @aner-starkware, @ShahakShama, and @TzahiTaub)

@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type_2 branch 2 times, most recently from 76a6cec to 23e64c1 Compare August 15, 2024 11:44
Copy link
Contributor Author

@aner-starkware aner-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: 14 of 18 files reviewed, 6 unresolved discussions (waiting on @dorimedini-starkware, @ShahakShama, and @TzahiTaub)

a discussion (no related file):
Python side: https://reviewable.io/reviews/starkware-industries/starkware/35733#-



crates/blockifier/src/blockifier/block.rs line 55 at r3 (raw file):

Previously, dorimedini-starkware wrote…

I suggest you output some numbers here: expected price, actual price, and the ratio
X2 (also below)

Why print the ratio? Did the rest.

@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type_2 branch from 23e64c1 to a31426c Compare August 15, 2024 11:48
Copy link
Collaborator

@dorimedini-starkware dorimedini-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 4 of 4 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @aner-starkware, @ShahakShama, and @TzahiTaub)


crates/blockifier/src/blockifier/block.rs line 55 at r5 (raw file):

                max_recursion_depth: 0,
                versioned_constants_base_overrides: None,
            })

why this function...? you are not passing overrides from the caller, why call this overriding method?

Code quote:

            VersionedConstants::get_versioned_constants(VersionedConstantsOverrides {
                validate_max_n_steps: 0,
                max_recursion_depth: 0,
                versioned_constants_base_overrides: None,
            })

crates/blockifier/src/blockifier/block.rs line 60 at r5 (raw file):

            warn!(
                "eth_l2_gas_price does not match expected! eth_l2_gas_price:{}, expected:{}.",
                eth_l2_gas_price, expected_eth_l2_gas_price

can you inline the values? more readable

Suggestion:

                "eth_l2_gas_price does not match expected! eth_l2_gas_price: {eth_l2_gas_price}, expected: {expected}."

crates/blockifier/src/blockifier/block.rs line 68 at r5 (raw file):

                max_recursion_depth: 0,
                versioned_constants_base_overrides: None,
            })

same Q

Code quote:

            VersionedConstants::get_versioned_constants(VersionedConstantsOverrides {
                validate_max_n_steps: 0,
                max_recursion_depth: 0,
                versioned_constants_base_overrides: None,
            })

crates/blockifier/src/blockifier/block.rs line 73 at r5 (raw file):

            warn!(
                "strk_l2_gas_price does not match expected! strk_l2_gas_price:{}, expected:{}.",
                strk_l2_gas_price, expected_strk_l2_gas_price

inline printed values (see above)

Code quote:

                "strk_l2_gas_price does not match expected! strk_l2_gas_price:{}, expected:{}.",
                strk_l2_gas_price, expected_strk_l2_gas_price

crates/blockifier/src/fee/fee_test.rs line 152 at r5 (raw file):

        .try_into()
        .unwrap(),
    );

why use this getter with no overrides, instead of latest_constants or something without args?

Code quote:

        VersionedConstants::get_versioned_constants(VersionedConstantsOverrides {
            validate_max_n_steps: 0,
            max_recursion_depth: 0,
            versioned_constants_base_overrides: None,
        })
        .l1_to_l2_gas_price_conversion(DEFAULT_ETH_L1_GAS_PRICE)
        .try_into()
        .unwrap(),
        VersionedConstants::get_versioned_constants(VersionedConstantsOverrides {
            validate_max_n_steps: 0,
            max_recursion_depth: 0,
            versioned_constants_base_overrides: None,
        })
        .l1_to_l2_gas_price_conversion(gas_price)
        .try_into()
        .unwrap(),
    );

crates/blockifier/src/test_utils/struct_impls.rs line 180 at r5 (raw file):

                    versioned_constants_base_overrides: None,
                })
                .l1_to_l2_gas_price_conversion(DEFAULT_STRK_L1_GAS_PRICE)

use latest_constants - it's equivalent, without the explicit overrides

Code quote:

                VersionedConstants::get_versioned_constants(VersionedConstantsOverrides {
                    validate_max_n_steps: 0,
                    max_recursion_depth: 0,
                    versioned_constants_base_overrides: None,
                })
                .l1_to_l2_gas_price_conversion(DEFAULT_ETH_L1_GAS_PRICE)
                .try_into()
                .unwrap(),
                VersionedConstants::get_versioned_constants(VersionedConstantsOverrides {
                    validate_max_n_steps: 0,
                    max_recursion_depth: 0,
                    versioned_constants_base_overrides: None,
                })
                .l1_to_l2_gas_price_conversion(DEFAULT_STRK_L1_GAS_PRICE)

crates/native_blockifier/src/py_state_diff.rs line 179 at r5 (raw file):

                    },
                )
                .l1_to_l2_gas_price_conversion(DEFAULT_STRK_L1_GAS_PRICE),

use latest_constants

Code quote:

                price_in_wei: VersionedConstants::get_versioned_constants(
                    VersionedConstantsOverrides {
                        validate_max_n_steps: 0,
                        max_recursion_depth: 0,
                        versioned_constants_base_overrides: None,
                    },
                )
                .l1_to_l2_gas_price_conversion(DEFAULT_ETH_L1_GAS_PRICE),
                price_in_fri: VersionedConstants::get_versioned_constants(
                    VersionedConstantsOverrides {
                        validate_max_n_steps: 0,
                        max_recursion_depth: 0,
                        versioned_constants_base_overrides: None,
                    },
                )
                .l1_to_l2_gas_price_conversion(DEFAULT_STRK_L1_GAS_PRICE),

@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type_2 branch from a31426c to f2b3c8b Compare August 15, 2024 14:47
Copy link
Contributor Author

@aner-starkware aner-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: 15 of 19 files reviewed, 11 unresolved discussions (waiting on @dorimedini-starkware, @ShahakShama, and @TzahiTaub)


crates/blockifier/src/blockifier/block.rs line 55 at r5 (raw file):

Previously, dorimedini-starkware wrote…

why this function...? you are not passing overrides from the caller, why call this overriding method?

Sorry, misunderstanding on my part - I thought you asked for this change.


crates/blockifier/src/blockifier/block.rs line 60 at r5 (raw file):

Previously, dorimedini-starkware wrote…

can you inline the values? more readable

Done.


crates/blockifier/src/blockifier/block.rs line 68 at r5 (raw file):

Previously, dorimedini-starkware wrote…

same Q

Done.


crates/blockifier/src/blockifier/block.rs line 73 at r5 (raw file):

Previously, dorimedini-starkware wrote…

inline printed values (see above)

Done.


crates/blockifier/src/fee/fee_test.rs line 152 at r5 (raw file):

Previously, dorimedini-starkware wrote…

why use this getter with no overrides, instead of latest_constants or something without args?

Sorry, misunderstanding on my part - I thought you asked for this change.


crates/blockifier/src/test_utils/struct_impls.rs line 180 at r5 (raw file):

Previously, dorimedini-starkware wrote…

use latest_constants - it's equivalent, without the explicit overrides

Done.


crates/native_blockifier/src/py_state_diff.rs line 216 at r3 (raw file):

Previously, dorimedini-starkware wrote…

add a variant for this

Done.


crates/native_blockifier/src/py_state_diff.rs line 223 at r3 (raw file):

Previously, dorimedini-starkware wrote…

ditto

Done.


crates/native_blockifier/src/py_state_diff.rs line 179 at r5 (raw file):

Previously, dorimedini-starkware wrote…

use latest_constants

Done.

@aner-starkware aner-starkware force-pushed the aner/add_function_l2_gas_price_by_fee_type_2 branch from f2b3c8b to da835c9 Compare August 15, 2024 14:50
Copy link
Collaborator

@dorimedini-starkware dorimedini-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 4 files at r6, 1 of 1 files at r7, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aner-starkware, @ShahakShama, and @TzahiTaub)

Copy link
Collaborator

@dorimedini-starkware dorimedini-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: all files reviewed, 2 unresolved discussions (waiting on @aner-starkware, @ShahakShama, and @TzahiTaub)


crates/gateway/src/rpc_objects.rs line 94 at r3 (raw file):

Previously, dorimedini-starkware wrote…

shouldn't this be part of the block header @ShahakShama ?

add the TODO here as well? (guessing it's related to the below discussion)

@TzahiTaub TzahiTaub changed the base branch from aner/add_function_l2_gas_price_by_fee_type to main August 25, 2024 14:51
@TzahiTaub TzahiTaub force-pushed the aner/add_function_l2_gas_price_by_fee_type_2 branch from da835c9 to a03834c Compare August 25, 2024 14:53
Copy link
Contributor

@TzahiTaub TzahiTaub 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 15 files at r2, 1 of 1 files at r5, 3 of 4 files at r6.
Reviewable status: 15 of 19 files reviewed, 2 unresolved discussions (waiting on @aner-starkware, @dorimedini-starkware, and @ShahakShama)

@TzahiTaub
Copy link
Contributor

crates/gateway/src/rpc_objects.rs line 94 at r3 (raw file):

Previously, dorimedini-starkware wrote…

add the TODO here as well? (guessing it's related to the below discussion)

Added. This is a part of the mempool project. @elintul FYI

Copy link
Collaborator

@dorimedini-starkware dorimedini-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 4 of 4 files at r8, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ShahakShama)

Copy link
Collaborator

@dorimedini-starkware dorimedini-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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)

@TzahiTaub TzahiTaub removed the request for review from ShahakShama August 26, 2024 12:51
@TzahiTaub TzahiTaub marked this pull request as ready for review August 26, 2024 12:51
@TzahiTaub TzahiTaub merged commit 8753678 into main Aug 26, 2024
25 checks passed
@TzahiTaub TzahiTaub deleted the aner/add_function_l2_gas_price_by_fee_type_2 branch August 26, 2024 12:52
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 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.

4 participants