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(fee): sn_resources depend on resource bounds signature #454

Conversation

nimrod-starkware
Copy link
Contributor

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

This change is Reviewable

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 r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @nimrod-starkware and @TzahiTaub)


crates/blockifier/src/fee/actual_cost_test.rs line 0 at r1 (raw file):
I would prefer the include_l2_gas flag be a "parametrized fixture"
TAL at rstest_reuse, so you can define something like:

#[template]
#[rstest]
fn include_l2_gas_param(#[values(false)] include_l2_gas: bool) {}

and use it in tests like this:

#[apply(include_l2_gas_param)]
fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool, include_l2_gas: bool) {
   ...

not sure if it works, but if it does, you'll be able to edit include_l2_gas_param by adding , true to #[values] and get test coverage for free


crates/blockifier/src/fee/gas_usage_test.rs line 0 at r1 (raw file):
ditto on the parametrization comment above


crates/blockifier/src/transaction/objects.rs line 320 at r1 (raw file):

            + self.get_messages_cost()
            + self.get_events_cost(versioned_constants, include_l2_gas)
    }

wouldn't this be cleaner?
then you wouldn't need to propagate this flag everywhere

Suggestion:

        versioned_constants: &VersionedConstants,
        use_kzg_da: bool,
        include_l2_gas: bool,
    ) -> GasVector {
        if include_l2_gas {
            todo!();
        } else {
            self.get_calldata_and_signature_cost(versioned_constants, include_l2_gas)
                + self.get_code_cost(versioned_constants, include_l2_gas)
                + self.get_state_changes_cost(use_kzg_da)
                + self.get_messages_cost()
                + self.get_events_cost(versioned_constants, include_l2_gas)
        }
    }

Copy link
Contributor Author

@nimrod-starkware nimrod-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, 3 unresolved discussions (waiting on @dorimedini-starkware and @TzahiTaub)


crates/blockifier/src/fee/actual_cost_test.rs line at r1 (raw file):

Previously, dorimedini-starkware wrote…

I would prefer the include_l2_gas flag be a "parametrized fixture"
TAL at rstest_reuse, so you can define something like:

#[template]
#[rstest]
fn include_l2_gas_param(#[values(false)] include_l2_gas: bool) {}

and use it in tests like this:

#[apply(include_l2_gas_param)]
fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool, include_l2_gas: bool) {
   ...

not sure if it works, but if it does, you'll be able to edit include_l2_gas_param by adding , true to #[values] and get test coverage for free

Nice!
I'll add it to tests that I think are independent of l1/l2 gas calculation (that don't compare hard coded gas vectors for example)


crates/blockifier/src/transaction/objects.rs line 320 at r1 (raw file):

Previously, dorimedini-starkware wrote…

wouldn't this be cleaner?
then you wouldn't need to propagate this flag everywhere

it's cleaner but get_calldata_and_signature_cost needs to know whether to calculate as l1 or l2... no?

Copy link
Contributor Author

@nimrod-starkware nimrod-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, 3 unresolved discussions (waiting on @dorimedini-starkware and @TzahiTaub)


crates/blockifier/src/fee/actual_cost_test.rs line at r1 (raw file):

Previously, nimrod-starkware wrote…

Nice!
I'll add it to tests that I think are independent of l1/l2 gas calculation (that don't compare hard coded gas vectors for example)

added it to test_calculate_tx_gas_usage


crates/blockifier/src/fee/gas_usage_test.rs line at r1 (raw file):

Previously, dorimedini-starkware wrote…

ditto on the parametrization comment above

Done

@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 614086d to 855c361 Compare August 15, 2024 08:31
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 5 of 5 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @nimrod-starkware and @TzahiTaub)


crates/blockifier/Cargo.toml line 68 at r2 (raw file):

regex.workspace = true
rstest.workspace = true
test-case.workspace = true

to pass machete I think you'll need to do this (rstest_reuse isn't used in non-testing code)

Suggestion:

rand = { workspace = true, optional = true }
rstest = { workspace = true, optional = true }
rstest_reuse = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["arbitrary_precision"] }
sha2.workspace = true
sha3.workspace = true
starknet-types-core.workspace = true
starknet_api = { workspace = true, features = ["testing"] }
strum.workspace = true
strum_macros.workspace = true
tempfile.workspace = true
thiserror.workspace = true
tikv-jemallocator = { workspace = true, optional = true }
toml.workspace = true

[dev-dependencies]
assert_matches.workspace = true
criterion = { workspace = true, features = ["html_reports"] }
glob.workspace = true
pretty_assertions.workspace = true
rand.workspace = true
regex.workspace = true
rstest.workspace = true
rstest_reuse.workspace = true
test-case.workspace = true

crates/blockifier/src/fee/actual_cost_test.rs line 36 at r2 (raw file):

#[rstest]
// TODO(Nimrod): Add true as a case.
fn include_l2_gas(#[values(false)] has_l2_gas: bool) {}

since this is used on other tests, please move it to a test utils module

Code quote:

#[rstest_reuse::template]
#[rstest]
// TODO(Nimrod): Add true as a case.
fn include_l2_gas(#[values(false)] has_l2_gas: bool) {}

crates/blockifier/src/transaction/objects.rs line 320 at r1 (raw file):

Previously, nimrod-starkware wrote…

it's cleaner but get_calldata_and_signature_cost needs to know whether to calculate as l1 or l2... no?

won't there be a completely different function to compute L2 gas cost? I guess not... unblocking

Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 4 lines in your changes missing coverage. Please review.

Project coverage is 75.82%. Comparing base (f357376) to head (35201a3).

Files with missing lines Patch % Lines
crates/blockifier/src/transaction/objects.rs 90.90% 4 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                           @@
##           nimrod/resources_enum/impl_methods     #454      +/-   ##
======================================================================
+ Coverage                               75.72%   75.82%   +0.09%     
======================================================================
  Files                                      85      352     +267     
  Lines                                   10984    37507   +26523     
  Branches                                10984    37507   +26523     
======================================================================
+ Hits                                     8318    28440   +20122     
- Misses                                   2242     6746    +4504     
- Partials                                  424     2321    +1897     

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

Copy link
Contributor Author

@nimrod-starkware nimrod-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 @dorimedini-starkware and @TzahiTaub)


crates/blockifier/Cargo.toml line 68 at r2 (raw file):

Previously, dorimedini-starkware wrote…

to pass machete I think you'll need to do this (rstest_reuse isn't used in non-testing code)

machete passed, but added it anyway


crates/blockifier/src/fee/actual_cost_test.rs line 36 at r2 (raw file):

Previously, dorimedini-starkware wrote…

since this is used on other tests, please move it to a test utils module

Done

@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 855c361 to 991209e Compare August 15, 2024 10:18
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [65.358 ms 65.410 ms 65.469 ms]
change: [-10.741% -6.6969% -3.0873%] (p = 0.00 < 0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe

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:

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @nimrod-starkware and @TzahiTaub)


crates/blockifier/src/test_utils.rs line 446 at r3 (raw file):

}

#[cfg(test)]

why is this needed...? in case feature = "testing" causes this module to compile, in non-test mode?

Code quote:

#[cfg(test)]

Copy link
Contributor Author

@nimrod-starkware nimrod-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, 1 unresolved discussion (waiting on @dorimedini-starkware and @TzahiTaub)


crates/blockifier/src/test_utils.rs line 446 at r3 (raw file):

Previously, dorimedini-starkware wrote…

why is this needed...? in case feature = "testing" causes this module to compile, in non-test mode?

without this, i get a clippy warning for unused macros.
I think it's because it's only being used in tests (under cfg(test)) but not declared in a test module.
For some weird reason annotating #[allow(unused_macros)] didn't solve it...

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

@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 991209e to 85b439a Compare August 28, 2024 09:09
@nimrod-starkware nimrod-starkware changed the base branch from main to nimrod/resources_enum/impl_methods August 28, 2024 09:09
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [65.117 ms 65.215 ms 65.318 ms]
change: [-8.1215% -4.8397% -1.9984%] (p = 0.00 < 0.05)
Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild

@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch from 43c559a to 3b621e3 Compare August 28, 2024 13:21
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 85b439a to 45f3fbe Compare August 28, 2024 13:21
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [65.521 ms 65.589 ms 65.659 ms]
change: [-9.5738% -6.3590% -3.5581%] (p = 0.00 < 0.05)
Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
1 (1.00%) low mild
3 (3.00%) high mild
1 (1.00%) high severe

@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch from 3b621e3 to a60c744 Compare September 1, 2024 05:31
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 45f3fbe to e0533bb Compare September 1, 2024 05:31
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 338fe8c to 60e4881 Compare September 3, 2024 13:45
@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch from fa26d2d to 74b7e19 Compare September 3, 2024 13:52
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 60e4881 to 324e884 Compare September 3, 2024 13:52
Copy link

github-actions bot commented Sep 3, 2024

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [66.019 ms 66.089 ms 66.167 ms]
change: [-9.1579% -5.8972% -3.1875%] (p = 0.00 < 0.05)
Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high severe

full_committer_flow performance improved 😺
full_committer_flow time: [47.410 ms 47.519 ms 47.653 ms]
change: [-3.4517% -3.1901% -2.8712%] (p = 0.00 < 0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) high mild
2 (2.00%) high severe

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

@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch from 74b7e19 to b8e6fb8 Compare September 3, 2024 15:17
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 324e884 to 10a6f72 Compare September 3, 2024 15:18
Copy link

github-actions bot commented Sep 3, 2024

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [65.648 ms 65.747 ms 65.854 ms]
change: [-3.6650% -2.3668% -1.3176%] (p = 0.00 < 0.05)
Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) high mild
1 (1.00%) high severe

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

@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch from b8e6fb8 to 5a131b2 Compare September 4, 2024 06:39
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 10a6f72 to e396522 Compare September 4, 2024 06:39
@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch from 5a131b2 to 2b2bf85 Compare September 4, 2024 07:05
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from e396522 to b3581ba Compare September 4, 2024 07:05
Copy link

github-actions bot commented Sep 4, 2024

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [65.295 ms 65.362 ms 65.437 ms]
change: [-9.6371% -5.5857% -2.3856%] (p = 0.00 < 0.05)
Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
4 (4.00%) high mild
1 (1.00%) high severe

@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch from 2b2bf85 to badb3d6 Compare September 4, 2024 11:07
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from b3581ba to 0e755c4 Compare September 4, 2024 11:07
@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch from badb3d6 to 104b7ad Compare September 4, 2024 11:09
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 0e755c4 to 427a81a Compare September 4, 2024 11:10
@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch from 104b7ad to 29d9f97 Compare September 4, 2024 13:36
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from 427a81a to ae18c8f Compare September 4, 2024 13:36
Copy link

github-actions bot commented Sep 4, 2024

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [65.833 ms 66.347 ms 67.102 ms]
change: [-9.1572% -5.4957% -2.0675%] (p = 0.00 < 0.05)
Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
4 (4.00%) high mild
4 (4.00%) high severe

@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch from 29d9f97 to be7a1da Compare September 5, 2024 07:18
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from ae18c8f to b1a68c1 Compare September 5, 2024 07:18
@nimrod-starkware nimrod-starkware force-pushed the nimrod/resources_enum/impl_methods branch 2 times, most recently from 1a33a5f to f357376 Compare September 5, 2024 11:08
@nimrod-starkware nimrod-starkware force-pushed the nimrod/l2_gas/starknet_resources branch from b1a68c1 to 35201a3 Compare September 5, 2024 11:08
Copy link

github-actions bot commented Sep 5, 2024

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [65.415 ms 65.482 ms 65.554 ms]
change: [-9.6852% -6.2758% -3.2844%] (p = 0.00 < 0.05)
Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
5 (5.00%) high mild

@github-actions github-actions bot locked and limited conversation to collaborators Sep 9, 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.

2 participants