diff --git a/crates/op-revm/src/handler.rs b/crates/op-revm/src/handler.rs index 5f4f4ed16d..cb3dd27764 100644 --- a/crates/op-revm/src/handler.rs +++ b/crates/op-revm/src/handler.rs @@ -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), diff --git a/crates/op-revm/src/l1block.rs b/crates/op-revm/src/l1block.rs index 67f52b6b60..3912a789ab 100644 --- a/crates/op-revm/src/l1block.rs +++ b/crates/op-revm/src/l1block.rs @@ -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 { // 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.