From d73417e07e608d3961e658c62e152a72d0c7c100 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Tue, 12 Nov 2024 10:30:09 +0800 Subject: [PATCH] fix: fix the gas price check for opBNB (#86) Co-authored-by: zoro <296179868@qq.com> --- crates/revm/src/optimism/handler_register.rs | 34 +++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/crates/revm/src/optimism/handler_register.rs b/crates/revm/src/optimism/handler_register.rs index 37f8fec9..59fd885c 100644 --- a/crates/revm/src/optimism/handler_register.rs +++ b/crates/revm/src/optimism/handler_register.rs @@ -234,17 +234,18 @@ pub fn deduct_caller( )); }; - let tx_l1_cost = if context.evm.inner.env.tx.gas_price.is_zero() && SPEC::enabled(WRIGHT) { - U256::ZERO - } else { - context - .evm - .inner - .l1_block_info - .as_ref() - .expect("L1BlockInfo should be loaded") - .calculate_tx_l1_cost(enveloped_tx, SPEC::SPEC_ID) - }; + let tx_l1_cost = + if context.evm.inner.env.effective_gas_price().is_zero() && SPEC::enabled(WRIGHT) { + U256::ZERO + } else { + context + .evm + .inner + .l1_block_info + .as_ref() + .expect("L1BlockInfo should be loaded") + .calculate_tx_l1_cost(enveloped_tx, SPEC::SPEC_ID) + }; if tx_l1_cost.gt(&caller_account.info.balance) { return Err(EVMError::Transaction( @@ -287,11 +288,12 @@ pub fn reward_beneficiary( )); }; - let l1_cost = if context.evm.inner.env.tx.gas_price.is_zero() && SPEC::enabled(WRIGHT) { - U256::ZERO - } else { - l1_block_info.calculate_tx_l1_cost(enveloped_tx, SPEC::SPEC_ID) - }; + let l1_cost = + if context.evm.inner.env.effective_gas_price().is_zero() && SPEC::enabled(WRIGHT) { + U256::ZERO + } else { + l1_block_info.calculate_tx_l1_cost(enveloped_tx, SPEC::SPEC_ID) + }; // Send the L1 cost of the transaction to the L1 Fee Vault. let mut l1_fee_vault_account = context