Skip to content

Commit 6c8f537

Browse files
Fix gas limit exceeded
1 parent 3eecfa0 commit 6c8f537

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

vm/rust/src/execution.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::error::ExecutionError;
22
use crate::juno_state_reader::JunoStateReader;
33
use blockifier::execution::contract_class::TrackedResource;
44
use blockifier::state::state_api::{StateReader, StateResult, UpdatableState};
5+
use blockifier::transaction::account_transaction::ExecutionFlags;
56
use blockifier::transaction::objects::HasRelatedFeeType;
67
use blockifier::transaction::transaction_execution::Transaction;
78
use blockifier::transaction::transactions::ExecutableTransaction;
@@ -218,7 +219,7 @@ where
218219
// If the computed gas limit exceeds the initial limit, revert the transaction.
219220
// The L2 gas limit is set to zero to prevent the transaction execution from succeeding
220221
// in the case where the user defined gas limit is less than the required gas limit
221-
if l2_gas_limit > initial_gas_limit {
222+
if get_execution_flags(transaction).charge_fee && l2_gas_limit > initial_gas_limit {
222223
tx_state.abort();
223224
set_l2_gas_limit(transaction, GasAmount::ZERO)?;
224225
return execute_transaction(&transaction, state, block_context, error_on_revert);
@@ -232,6 +233,13 @@ where
232233
Ok(exec_info)
233234
}
234235

236+
fn get_execution_flags(tx: &Transaction) -> ExecutionFlags {
237+
match tx {
238+
Transaction::Account(account_transaction) => account_transaction.execution_flags.clone(),
239+
Transaction::L1Handler(_) => Default::default(),
240+
}
241+
}
242+
235243
fn calculate_midpoint(a: GasAmount, b: GasAmount) -> GasAmount {
236244
let GasAmount(a) = a;
237245
let GasAmount(b) = b;

0 commit comments

Comments
 (0)