Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

chore: clean fee utils #1968

Merged
merged 1 commit into from
Jun 9, 2024
Merged

chore: clean fee utils #1968

merged 1 commit into from
Jun 9, 2024

Conversation

Yoni-Starkware
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware commented Jun 6, 2024

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.25%. Comparing base (702f401) to head (a5ff62f).
Report is 2 commits behind head on main.

Files Patch % Lines
crates/blockifier/src/fee/actual_cost.rs 80.00% 0 Missing and 1 partial ⚠️
crates/blockifier/src/test_utils/struct_impls.rs 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1968      +/-   ##
==========================================
+ Coverage   78.17%   78.25%   +0.07%     
==========================================
  Files          62       62              
  Lines        8842     8865      +23     
  Branches     8842     8865      +23     
==========================================
+ Hits         6912     6937      +25     
  Misses       1492     1492              
+ Partials      438      436       -2     

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

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 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1 and @Yoni-Starkware)


crates/blockifier/src/test_utils.rs line 455 at r1 (raw file):

        .to_gas_vector(&block_context.versioned_constants, block_context.block_info.use_kzg_da)?;
    Ok(get_fee_by_gas_vector(&block_context.block_info, gas_vector, fee_type))
}

make this a method of TransactionResources please, next to to_gas_vector

Code quote:

pub fn calculate_tx_fee(
    tx_resources: &TransactionResources,
    block_context: &BlockContext,
    fee_type: &FeeType,
) -> TransactionFeeResult<Fee> {
    let gas_vector = tx_resources
        .to_gas_vector(&block_context.versioned_constants, block_context.block_info.use_kzg_da)?;
    Ok(get_fee_by_gas_vector(&block_context.block_info, gas_vector, fee_type))
}

Copy link
Collaborator Author

@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: all files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware and @noaov1)


crates/blockifier/src/test_utils.rs line 455 at r1 (raw file):

Previously, dorimedini-starkware wrote…

make this a method of TransactionResources please, next to to_gas_vector

Why? It is used only in tests.
Or did you mean to put it under test config?

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, 1 unresolved discussion (waiting on @noaov1 and @Yoni-Starkware)


crates/blockifier/src/test_utils.rs line 455 at r1 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Why? It is used only in tests.
Or did you mean to put it under test config?

I would simply like all fee manipulation logic to be encapsulated in one object, instead of many utilities floating around without context.
maybe add an impl TransactionResources block in a test_utils module, with this function?

Copy link
Collaborator Author

@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: 3 of 7 files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware and @noaov1)


crates/blockifier/src/test_utils.rs line 455 at r1 (raw file):

Previously, dorimedini-starkware wrote…

I would simply like all fee manipulation logic to be encapsulated in one object, instead of many utilities floating around without context.
maybe add an impl TransactionResources block in a test_utils module, with this function?

Done.

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 4 of 4 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1)

@Yoni-Starkware Yoni-Starkware merged commit d179561 into main Jun 9, 2024
9 checks passed
@Yoni-Starkware Yoni-Starkware deleted the yoni/fee/clean-fee-utils branch June 9, 2024 08:48
gswirski pushed a commit to reilabs/blockifier that referenced this pull request Jun 26, 2024
…e function (starkware-libs#1968)

# Description

put all the logic that is required for every tx execution (ie building the receipt, exec info, etc) into a single unit of execution (ie `transact`). 

this allow us to simplify testing/benchmarking tx execution, bcs all the necessary steps are now included in a single function that we can easily test, without having to create the entire `BlockExecutor` trait.

## Related issue

<!--
Please link related issues: Fixes #<issue_number>
More info: https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->

## Tests

<!--
Please refer to the CONTRIBUTING.md file to know more about the testing process. Ensure you've tested at least the package you're modifying if running all the tests consumes too much memory on your system.
-->

- [ ] Yes
- [x] No, because they aren't needed
- [ ] No, because I need help

## Added to documentation?

<!--
If the changes are small, code comments are enough, otherwise, the documentation is needed. It
may be a README.md file added to your module/package, a DojoBook PR or both.
-->

- [ ] README.md
- [ ] [Dojo Book](https://github.com/dojoengine/book)
- [x] No documentation needed

## Checklist

- [x] I've formatted my code (`scripts/prettier.sh`, `scripts/rust_fmt.sh`, `scripts/cairo_fmt.sh`)
- [x] I've linted my code (`scripts/clippy.sh`, `scripts/docs.sh`)
- [ ] I've commented my code
- [ ] I've requested a review after addressing the comments
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