Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/blockifier/src/fee/fee_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl FeeCheckReport {
) -> TransactionExecutionResult<()> {
let TransactionReceipt { fee, .. } = *tx_receipt;
let (balance_low, balance_high, can_pay) =
get_balance_and_if_covers_fee(state, tx_context, fee)?;
get_balance_and_if_covers_fee(state, tx_context, fee).map_err(Box::new)?;
if can_pay {
return Ok(());
}
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ impl AccountTransaction {

Ok(fee_transfer_call
.execute(state, &mut context, &mut remaining_gas_for_fee_transfer)
.map_err(TransactionFeeError::ExecuteFeeTransferError)?)
.map_err(|error| Box::new(TransactionFeeError::ExecuteFeeTransferError(error)))?)
}

/// Handles fee transfer in concurrent execution.
Expand Down Expand Up @@ -799,7 +799,7 @@ impl<U: UpdatableState> ExecutableTransaction<U> for AccountTransaction {
}

// Nonce and fee check should be done before running user code.
self.perform_pre_validation_stage(state, &tx_context)?;
self.perform_pre_validation_stage(state, &tx_context).map_err(Box::new)?;

// Run validation and execution.
let initial_gas = tx_context.initial_sierra_gas();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,11 @@ fn test_fee_enforcement(
if enforce_fee {
assert_matches!(
result,
Err(TransactionExecutionError::TransactionPreValidationError(
Err(TransactionExecutionError::TransactionPreValidationError(boxed_error))
if matches!(
*boxed_error,
TransactionPreValidationError::TransactionFeeError(_)
))
)
);
} else {
assert!(result.is_ok());
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/transaction/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ pub enum TransactionExecutionError {
#[error(transparent)]
StateError(#[from] StateError),
#[error(transparent)]
TransactionFeeError(#[from] TransactionFeeError),
TransactionFeeError(#[from] Box<TransactionFeeError>),
#[error(transparent)]
TransactionPreValidationError(#[from] TransactionPreValidationError),
TransactionPreValidationError(#[from] Box<TransactionPreValidationError>),
#[error(transparent)]
TryFromIntError(#[from] std::num::TryFromIntError),
#[error(
Expand Down
50 changes: 31 additions & 19 deletions crates/blockifier/src/transaction/execution_flavors_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,15 @@ fn test_invalid_nonce_pre_validate(
let result = account_tx.execute(&mut state, &block_context);
assert_matches!(
result.unwrap_err(),
TransactionExecutionError::TransactionPreValidationError(
TransactionExecutionError::TransactionPreValidationError(boxed_error)
if matches!(
*boxed_error,
TransactionPreValidationError::InvalidNonce {
address, account_nonce: expected_nonce, incoming_tx_nonce
}
if (address, expected_nonce, incoming_tx_nonce) ==
(account_address, account_nonce, invalid_nonce)
)
if (address, expected_nonce, incoming_tx_nonce) ==
(account_address, account_nonce, invalid_nonce)
);
}
// Pre-validation scenarios.
Expand Down Expand Up @@ -277,7 +279,9 @@ fn test_simulate_validate_pre_validate_with_charge_fee(
if is_deprecated {
assert_matches!(
err,
TransactionExecutionError::TransactionPreValidationError(
TransactionExecutionError::TransactionPreValidationError(boxed_error)
if matches!(
*boxed_error,
TransactionPreValidationError::TransactionFeeError(
TransactionFeeError::MaxFeeTooLow { .. }
)
Expand All @@ -286,15 +290,17 @@ fn test_simulate_validate_pre_validate_with_charge_fee(
} else {
assert_matches!(
err,
TransactionExecutionError::TransactionPreValidationError(
TransactionExecutionError::TransactionPreValidationError(boxed_error)
=> assert_matches!(
*boxed_error,
TransactionPreValidationError::TransactionFeeError(
TransactionFeeError::InsufficientResourceBounds { errors }
)
) =>
assert_matches!(
errors[0],
ResourceBoundsError::MaxGasAmountTooLow { resource , .. }
if resource == Resource::L1Gas
=> assert_matches!(
errors[0],
ResourceBoundsError::MaxGasAmountTooLow { resource , .. }
if resource == Resource::L1Gas
)
)
);
}
Expand Down Expand Up @@ -327,7 +333,9 @@ fn test_simulate_validate_pre_validate_with_charge_fee(
if is_deprecated {
assert_matches!(
result.unwrap_err(),
TransactionExecutionError::TransactionPreValidationError(
TransactionExecutionError::TransactionPreValidationError(boxed_error)
if matches!(
*boxed_error,
TransactionPreValidationError::TransactionFeeError(
TransactionFeeError::MaxFeeExceedsBalance { .. }
)
Expand All @@ -336,12 +344,14 @@ fn test_simulate_validate_pre_validate_with_charge_fee(
} else {
assert_matches!(
result.unwrap_err(),
TransactionExecutionError::TransactionPreValidationError(
TransactionExecutionError::TransactionPreValidationError(boxed_error)
if matches!(
*boxed_error,
TransactionPreValidationError::TransactionFeeError(
TransactionFeeError::GasBoundsExceedBalance {resource, .. }
)
if resource == Resource::L1Gas
)
if resource == Resource::L1Gas
);
}

Expand All @@ -367,15 +377,17 @@ fn test_simulate_validate_pre_validate_with_charge_fee(
nonce_manager.rollback(account_address);
assert_matches!(
err,
TransactionExecutionError::TransactionPreValidationError(
TransactionExecutionError::TransactionPreValidationError(boxed_error)
=> assert_matches!(
*boxed_error,
TransactionPreValidationError::TransactionFeeError(
TransactionFeeError::InsufficientResourceBounds{ errors }
)
) =>
assert_matches!(
errors[0],
ResourceBoundsError::MaxGasPriceTooLow { resource, .. }
if resource == Resource::L1Gas
=> assert_matches!(
errors[0],
ResourceBoundsError::MaxGasPriceTooLow { resource, .. }
if resource == Resource::L1Gas
)
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/transaction/l1_handler_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ impl<U: UpdatableState> ExecutableTransaction<U> for L1HandlerTransaction {
// For now, assert only that any amount of fee was paid.
// The error message still indicates the required fee.
if paid_fee == Fee(0) {
return Err(TransactionExecutionError::TransactionFeeError(
return Err(TransactionExecutionError::TransactionFeeError(Box::new(
TransactionFeeError::InsufficientFee {
paid_fee,
actual_fee: receipt.fee,
},
));
)));
}

Ok(l1_handler_tx_execution_info(execute_call_info, receipt, None))
Expand Down
Loading
Loading