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

Commit

Permalink
fix: remove unnecessary recomputation of total gas field (#1971)
Browse files Browse the repository at this point in the history
  • Loading branch information
AvivYossef-starkware authored Jun 9, 2024
1 parent d179561 commit c5ee585
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
7 changes: 1 addition & 6 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ impl<U: UpdatableState> ExecutableTransaction<U> for AccountTransaction {
fee: final_fee,
da_gas: final_da_gas,
resources: final_resources,
..
gas: total_gas,
},
} = self.run_or_revert(
state,
Expand All @@ -670,11 +670,6 @@ impl<U: UpdatableState> ExecutableTransaction<U> for AccountTransaction {
)?;
let fee_transfer_call_info = self.handle_fee(state, tx_context, final_fee, charge_fee)?;

let total_gas = final_resources.to_gas_vector(
&block_context.versioned_constants,
block_context.block_info.use_kzg_da,
)?;

let tx_execution_info = TransactionExecutionInfo {
validate_call_info,
execute_call_info,
Expand Down
25 changes: 12 additions & 13 deletions crates/blockifier/src/transaction/transaction_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,18 @@ impl<U: UpdatableState> ExecutableTransaction<U> for L1HandlerTransaction {
self.run_execute(state, &mut execution_resources, &mut context, &mut remaining_gas)?;
let l1_handler_payload_size = self.payload_size();

let TransactionReceipt { fee: actual_fee, da_gas, resources: actual_resources, .. } =
TransactionReceipt::from_l1_handler(
&tx_context,
l1_handler_payload_size,
execute_call_info.iter(),
&state.get_actual_state_changes()?,
&execution_resources,
)?;
let TransactionReceipt {
fee: actual_fee,
da_gas,
resources: actual_resources,
gas: total_gas,
} = TransactionReceipt::from_l1_handler(
&tx_context,
l1_handler_payload_size,
execute_call_info.iter(),
&state.get_actual_state_changes()?,
&execution_resources,
)?;

let paid_fee = self.paid_fee_on_l1;
// For now, assert only that any amount of fee was paid.
Expand All @@ -132,11 +136,6 @@ impl<U: UpdatableState> ExecutableTransaction<U> for L1HandlerTransaction {
return Err(TransactionFeeError::InsufficientL1Fee { paid_fee, actual_fee })?;
}

let total_gas = actual_resources.to_gas_vector(
&block_context.versioned_constants,
block_context.block_info.use_kzg_da,
)?;

Ok(TransactionExecutionInfo {
validate_call_info: None,
execute_call_info,
Expand Down

0 comments on commit c5ee585

Please sign in to comment.