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

Commit 726d32d

Browse files
authored
Do not revert in case of charge fee flag is false and the actual fee exxeeds the max fee. (#1033)
1 parent 70c9b97 commit 726d32d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

crates/blockifier/src/transaction/account_transaction.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,15 @@ impl AccountTransaction {
453453
))
454454
}
455455

456+
#[allow(clippy::too_many_arguments)]
456457
fn run_revertible<S: StateReader>(
457458
&self,
458459
state: &mut TransactionalState<'_, S>,
459460
resources: &mut ExecutionResources,
460461
remaining_gas: &mut u64,
461462
block_context: &BlockContext,
462463
mut execution_context: EntryPointExecutionContext,
464+
charge_fee: bool,
463465
validate: bool,
464466
) -> TransactionExecutionResult<ValidateExecuteCallInfo> {
465467
let account_tx_context = self.get_account_transaction_context();
@@ -543,7 +545,7 @@ impl AccountTransaction {
543545
!Self::is_sufficient_fee_balance(balance_low, balance_high, actual_fee);
544546
let max_fee = account_tx_context.max_fee;
545547

546-
if actual_fee > max_fee || is_maxed_out {
548+
if charge_fee && (actual_fee > max_fee || is_maxed_out) {
547549
// Insufficient fee. Revert the execution and charge what is available.
548550
let (final_fee, revert_error) = if actual_fee > max_fee {
549551
(
@@ -644,6 +646,7 @@ impl AccountTransaction {
644646
resources: &mut ExecutionResources,
645647
remaining_gas: &mut u64,
646648
block_context: &BlockContext,
649+
charge_fee: bool,
647650
validate: bool,
648651
) -> TransactionExecutionResult<ValidateExecuteCallInfo> {
649652
let account_tx_context = self.get_account_transaction_context();
@@ -672,6 +675,7 @@ impl AccountTransaction {
672675
remaining_gas,
673676
block_context,
674677
execution_context,
678+
charge_fee,
675679
validate,
676680
)
677681
}
@@ -741,8 +745,14 @@ impl<S: StateReader> ExecutableTransaction<S> for AccountTransaction {
741745
revert_error,
742746
final_fee,
743747
final_resources,
744-
} =
745-
self.run_or_revert(state, &mut resources, &mut remaining_gas, block_context, validate)?;
748+
} = self.run_or_revert(
749+
state,
750+
&mut resources,
751+
&mut remaining_gas,
752+
block_context,
753+
charge_fee,
754+
validate,
755+
)?;
746756

747757
let fee_transfer_call_info =
748758
self.handle_fee(state, block_context, final_fee, charge_fee)?;

0 commit comments

Comments
 (0)