fix(primitives): return baseFee as effectiveGasPrice for L1 messages#60
fix(primitives): return baseFee as effectiveGasPrice for L1 messages#60
Conversation
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.
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/primitives/src/transaction/l1_transaction.rs (1)
371-372: Add a regression test for L1 fee-accounting invariants (not only method output).At Line 371 and Line 372, this test validates the new return values but doesn’t verify that L1 messages still incur zero execution-fee accounting in handler flows. Please add a cross-module regression test that asserts no beneficiary/token-fee charging regression for type
0x7E.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/primitives/src/transaction/l1_transaction.rs` around lines 371 - 372, Add a cross-module regression test that, beyond asserting the returned values of tx.effective_gas_price(Some(100)) and tx.effective_gas_price(None), verifies that L1 messages of type 0x7E are still exempt from execution-fee accounting in handler flows: create a test that constructs an L1 transaction/message of type 0x7E, executes the handler path that would normally charge beneficiary or token fees, and asserts that beneficiary balances and token-fee accounting remain unchanged (no beneficiary credit and no token fee deducted); reference the effective_gas_price method and the L1 message handling code paths (handler flow) to ensure the test checks both the method return values and the invariant that type 0x7E incurs zero execution-fee accounting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/primitives/src/transaction/l1_transaction.rs`:
- Around line 371-372: Add a cross-module regression test that, beyond asserting
the returned values of tx.effective_gas_price(Some(100)) and
tx.effective_gas_price(None), verifies that L1 messages of type 0x7E are still
exempt from execution-fee accounting in handler flows: create a test that
constructs an L1 transaction/message of type 0x7E, executes the handler path
that would normally charge beneficiary or token fees, and asserts that
beneficiary balances and token-fee accounting remain unchanged (no beneficiary
credit and no token fee deducted); reference the effective_gas_price method and
the L1 message handling code paths (handler flow) to ensure the test checks both
the method return values and the invariant that type 0x7E incurs zero
execution-fee accounting.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 52961b98-7d87-40c8-b446-1ec1b6bef01f
📒 Files selected for processing (1)
crates/primitives/src/transaction/l1_transaction.rs
Summary
0x7E) previously reportedeffectiveGasPrice: "0x0"ineth_getTransactionReceipt, while go-ethereum returns the block'sbaseFeeTxL1Msg::effective_gas_price(base_fee)from returning0to returningbase_fee.unwrap_or(0)NoneviaTxEnvconstruction (tx.effective_gas_price(None)incrates/revm/src/tx.rs), so gas accounting is unchangedTest plan
test_l1_transaction_trait_methodsupdated and passestest_rpc_fields.py): L1 message receipteffectiveGasPricenow matches between morph-geth and morph-rethSummary by CodeRabbit
Bug Fixes