From 2e60cd8413d14fb6bdfd8b3830c57d2955077929 Mon Sep 17 00:00:00 2001 From: panos Date: Thu, 26 Mar 2026 11:26:35 +0800 Subject: [PATCH] fix(primitives): return baseFee as effectiveGasPrice for L1 messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit L1 message transactions are prepaid on L1 and carry no gas price. Previously, `TxL1Msg::effective_gas_price()` unconditionally returned 0, causing `eth_getTransactionReceipt` to report `effectiveGasPrice: "0x0"` for L1 messages. go-ethereum returns `baseFee` instead. Change `effective_gas_price(base_fee)` to return `base_fee.unwrap_or(0)`. This only affects the RPC receipt display — the execution layer passes `None` via `TxEnv` construction (`tx.effective_gas_price(None)` in `crates/revm/src/tx.rs`), so gas accounting remains unchanged. --- crates/primitives/src/transaction/l1_transaction.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/primitives/src/transaction/l1_transaction.rs b/crates/primitives/src/transaction/l1_transaction.rs index 76ac676..869b619 100644 --- a/crates/primitives/src/transaction/l1_transaction.rs +++ b/crates/primitives/src/transaction/l1_transaction.rs @@ -176,8 +176,10 @@ impl Transaction for TxL1Msg { 0 } - fn effective_gas_price(&self, _base_fee: Option) -> u128 { - 0 + fn effective_gas_price(&self, base_fee: Option) -> u128 { + // L1 messages are prepaid on L1 and have no gas price themselves. + // Return baseFee as the effective gas price to match go-ethereum behavior. + base_fee.unwrap_or(0) as u128 } fn is_dynamic_fee(&self) -> bool { @@ -366,7 +368,8 @@ mod tests { assert_eq!(tx.max_priority_fee_per_gas(), None); assert_eq!(tx.max_fee_per_blob_gas(), None); assert_eq!(tx.priority_fee_or_price(), 0); - assert_eq!(tx.effective_gas_price(Some(100)), 0); + assert_eq!(tx.effective_gas_price(Some(100)), 100); // returns baseFee for receipts + assert_eq!(tx.effective_gas_price(None), 0); // no baseFee → 0 (execution path) assert!(!tx.is_dynamic_fee()); assert!(!tx.is_create()); // L1 messages can never create contracts assert_eq!(