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 constant from mid execution test #1070

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

yoavGrs
Copy link
Contributor

@yoavGrs yoavGrs commented Sep 29, 2024

This change is Reviewable

@yoavGrs yoavGrs self-assigned this Sep 29, 2024
Copy link

codecov bot commented Sep 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.58%. Comparing base (b0cfe82) to head (dced5d2).
Report is 148 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1070      +/-   ##
==========================================
- Coverage   74.18%   70.58%   -3.61%     
==========================================
  Files         359       88     -271     
  Lines       36240    11347   -24893     
  Branches    36240    11347   -24893     
==========================================
- Hits        26886     8009   -18877     
+ Misses       7220     2960    -4260     
+ Partials     2134      378    -1756     
Flag Coverage Δ
70.58% <ø> (-3.61%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@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 1 files reviewed, 2 unresolved discussions (waiting on @yoavGrs)


crates/blockifier/src/transaction/execution_flavors_test.rs line 107 at r1 (raw file):

/// Returns the amount of L1 gas and derived fee, given base gas amount and a boolean indicating
/// if validation is to be done.
fn gas_and_fee(base_gas: u64, validation_overhead: bool, fee_type: &FeeType) -> (u64, Fee) {

This name makes more sense for a numeric value. Maybe include_ or add_?

Suggestion:

add_validation_overhead: bool

crates/blockifier/src/transaction/execution_flavors_test.rs line 123 at r1 (raw file):

    tx_execution_info: &TransactionExecutionInfo,
    block_context: &BlockContext,
    validation_overhead: bool,

See above.

Suggestion:

remove_validation_overhead: bool

@yoavGrs yoavGrs force-pushed the yoav/blockifier/remove_constants/mid_execution/01 branch from 8cde0b6 to da7e992 Compare September 29, 2024 08:25
Copy link
Contributor Author

@yoavGrs yoavGrs 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 1 files reviewed, 2 unresolved discussions (waiting on @aner-starkware)


crates/blockifier/src/transaction/execution_flavors_test.rs line 107 at r1 (raw file):

Previously, aner-starkware wrote…

This name makes more sense for a numeric value. Maybe include_ or add_?

Done.


crates/blockifier/src/transaction/execution_flavors_test.rs line 123 at r1 (raw file):

Previously, aner-starkware wrote…

See above.

Done.

Copy link
Contributor

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

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @yoavGrs)


crates/blockifier/src/transaction/execution_flavors_test.rs line 574 at r2 (raw file):

    .unwrap();
    let base_gas: u64 =
        calculate_actual_gas(&tx_execution_info, &block_context, validate).try_into().unwrap();

Maybe consider adding a comment about the offset of the validation overhead between the execute and calculate_actual_gas?

Code quote:

    .execute(&mut state, &block_context, charge_fee, validate)
    .unwrap();
    let base_gas: u64 =
        calculate_actual_gas(&tx_execution_info, &block_context, validate).try_into().unwrap();

Copy link
Contributor

@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 1 files reviewed, 1 unresolved discussion (waiting on @yoavGrs)

a discussion (no related file):
Blocked until reviewed by @dorimedini-starkware.


@yoavGrs yoavGrs force-pushed the yoav/blockifier/remove_constants/mid_execution/01 branch from da7e992 to 2bf465c Compare September 29, 2024 14:45
Copy link
Contributor Author

@yoavGrs yoavGrs 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 1 files reviewed, 1 unresolved discussion


crates/blockifier/src/transaction/execution_flavors_test.rs line 574 at r2 (raw file):

Previously, aner-starkware wrote…

Maybe consider adding a comment about the offset of the validation overhead between the execute and calculate_actual_gas?

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.

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aner-starkware and @yoavGrs)

a discussion (no related file):

Previously, aner-starkware wrote…

Blocked until reviewed by @dorimedini-starkware.

done



crates/blockifier/src/transaction/execution_flavors_test.rs line 137 at r3 (raw file):

        .l1_gas
        - if remove_validation_overhead { VALIDATE_GAS_OVERHEAD.into() } else { 0 }
}

why does one function add validation overhead while the other removes?

Code quote:

fn gas_and_fee(base_gas: u64, add_validation_overhead: bool, fee_type: &FeeType) -> (u64, Fee) {
    // Validation incurs a constant gas overhead.
    let gas = base_gas + if add_validation_overhead { VALIDATE_GAS_OVERHEAD } else { 0 };
    (
        gas,
        get_fee_by_gas_vector(
            &BlockContext::create_for_account_testing().block_info,
            GasVector::from_l1_gas(gas.into()),
            fee_type,
        ),
    )
}

// Calculates the actual gas used by a transaction. Removing the validation overhead if requested,
// as it's already considered in the tx_execution_info.
fn calculate_actual_gas(
    tx_execution_info: &TransactionExecutionInfo,
    block_context: &BlockContext,
    remove_validation_overhead: bool,
) -> u128 {
    tx_execution_info
        .receipt
        .resources
        .to_gas_vector(
            &block_context.versioned_constants,
            block_context.block_info.use_kzg_da,
            &GasVectorComputationMode::NoL2Gas,
        )
        .l1_gas
        - if remove_validation_overhead { VALIDATE_GAS_OVERHEAD.into() } else { 0 }
}

@yoavGrs yoavGrs force-pushed the yoav/blockifier/remove_constants/mid_execution/01 branch from 2bf465c to dced5d2 Compare September 30, 2024 06:49
Copy link
Contributor Author

@yoavGrs yoavGrs 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 1 files reviewed, 2 unresolved discussions (waiting on @aner-starkware and @dorimedini-starkware)


crates/blockifier/src/transaction/execution_flavors_test.rs line 137 at r3 (raw file):

Previously, dorimedini-starkware wrote…

why does one function add validation overhead while the other removes?

It comes from the stage of the failure. There is validation overhead in mid_execution , while it isn't in pre_validate.

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

Copy link
Contributor

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

@yoavGrs yoavGrs merged commit 27fb3f7 into main Sep 30, 2024
12 checks passed
@yoavGrs yoavGrs deleted the yoav/blockifier/remove_constants/mid_execution/01 branch September 30, 2024 10:05
@github-actions github-actions bot locked and limited conversation to collaborators Oct 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