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
6 changes: 5 additions & 1 deletion crates/op-revm/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ where
let mut balance = caller_account.info.balance;

if !cfg.is_fee_charge_disabled() {
let additional_cost = chain.tx_cost_with_tx(tx, spec);
let Some(additional_cost) = chain.tx_cost_with_tx(tx, spec) else {
return Err(ERROR::from_string(
"[OPTIMISM] Failed to load enveloped transaction.".into(),
));
};
let Some(new_balance) = balance.checked_sub(additional_cost) else {
return Err(InvalidTransaction::LackOfFundForMaxFee {
fee: Box::new(additional_cost),
Expand Down
10 changes: 3 additions & 7 deletions crates/op-revm/src/l1block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,11 @@ impl L1BlockInfo {
/// Calculate additional transaction cost with OpTxTr.
///
/// Internally calls [`L1BlockInfo::tx_cost`].
#[track_caller]
pub fn tx_cost_with_tx(&mut self, tx: impl OpTxTr, spec: OpSpecId) -> U256 {
pub fn tx_cost_with_tx(&mut self, tx: impl OpTxTr, spec: OpSpecId) -> Option<U256> {
// account for additional cost of l1 fee and operator fee
let enveloped_tx = tx
.enveloped_tx()
.expect("all not deposit tx have enveloped tx")
.clone();
let enveloped_tx = tx.enveloped_tx()?;
let gas_limit = U256::from(tx.gas_limit());
self.tx_cost(&enveloped_tx, gas_limit, spec)
Some(self.tx_cost(enveloped_tx, gas_limit, spec))
}

/// Calculate additional transaction cost.
Expand Down
Loading