Skip to content

Commit

Permalink
refactor(blockifier): remove enforce fee from actual fee
Browse files Browse the repository at this point in the history
  • Loading branch information
avivg-starkware committed Oct 15, 2024
1 parent 3c6fe63 commit 88e2fa5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
8 changes: 3 additions & 5 deletions crates/blockifier/src/concurrency/fee_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ pub fn complete_fee_transfer_flow(
sequencer_balance,
);
} else {
assert_eq!(
tx_execution_info.receipt.fee,
Fee(0),
"Transaction with no fee transfer info must have zero fee."
)
// Assumes we set the charge fee flag to the transaction enforce fee value.
let charge_fee = tx_context.tx_info.enforce_fee();
assert!(!charge_fee, "Transaction with no fee transfer info must not enforce a fee charge.")
}
}

Expand Down
10 changes: 5 additions & 5 deletions crates/blockifier/src/fee/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ impl TransactionReceipt {
tx_context.block_context.block_info.use_kzg_da,
&tx_context.get_gas_vector_computation_mode(),
);

// L1 handler transactions are not charged an L2 fee but it is compared to the L1 fee.
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 {
// Backward-compatibility.
let fee = if tx_type == TransactionType::Declare && tx_context.tx_info.is_v0() {
Fee(0)
} else {
tx_context.tx_info.get_fee_by_gas_vector(&tx_context.block_context.block_info, gas)
};

let da_gas = tx_resources
.starknet_resources
.state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ use crate::transaction::constants::TRANSFER_ENTRY_POINT_NAME;
use crate::transaction::objects::{FeeType, HasRelatedFeeType, TransactionInfoCreator};
use crate::transaction::test_utils::{
account_invoke_tx,
all_resource_bounds,
block_context,
calculate_class_info_for_testing,
create_account_tx_for_validate_test_nonce_0,
Expand Down Expand Up @@ -557,6 +558,7 @@ fn test_recursion_depth_exceeded(
fn test_revert_invoke(
block_context: BlockContext,
max_fee: Fee,
all_resource_bounds: ValidResourceBounds,
#[case] transaction_version: TransactionVersion,
#[case] fee_type: FeeType,
) {
Expand All @@ -575,6 +577,7 @@ fn test_revert_invoke(
&block_context,
invoke_tx_args! {
max_fee,
resource_bounds: all_resource_bounds,
sender_address: account_address,
calldata: create_calldata(
test_contract_address,
Expand Down
18 changes: 11 additions & 7 deletions crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,6 @@ fn test_declare_tx(
None,
ExecutionSummary::default(),
);

let account_tx = declare_tx(
declare_tx_args! {
max_fee: MAX_FEE,
Expand Down Expand Up @@ -1409,12 +1408,17 @@ fn test_declare_tx(

// Build expected fee transfer call info.
let expected_actual_fee = actual_execution_info.receipt.fee;
let expected_fee_transfer_call_info = expected_fee_transfer_call_info(
tx_context,
sender_address,
expected_actual_fee,
FeatureContract::ERC20(CairoVersion::Cairo0).get_class_hash(),
);
// V0 transactions do not handle fee.
let expected_fee_transfer_call_info = if tx_version == TransactionVersion::ZERO {
None
} else {
expected_fee_transfer_call_info(
tx_context,
sender_address,
expected_actual_fee,
FeatureContract::ERC20(CairoVersion::Cairo0).get_class_hash(),
)
};

let da_gas = starknet_resources.state.to_gas_vector(use_kzg_da);
let expected_cairo_resources = get_expected_cairo_resources(
Expand Down

0 comments on commit 88e2fa5

Please sign in to comment.