Skip to content

fix(primitives): return baseFee as effectiveGasPrice for L1 messages#60

Merged
panos-xyz merged 2 commits intomainfrom
fix/l1-msg-effective-gas-price
Mar 26, 2026
Merged

fix(primitives): return baseFee as effectiveGasPrice for L1 messages#60
panos-xyz merged 2 commits intomainfrom
fix/l1-msg-effective-gas-price

Conversation

@panos-xyz
Copy link
Copy Markdown
Contributor

@panos-xyz panos-xyz commented Mar 26, 2026

Summary

  • L1 message transactions (0x7E) previously reported effectiveGasPrice: "0x0" in eth_getTransactionReceipt, while go-ethereum returns the block's baseFee
  • Changed TxL1Msg::effective_gas_price(base_fee) from returning 0 to returning base_fee.unwrap_or(0)
  • Only affects RPC receipt display — execution layer passes None via TxEnv construction (tx.effective_gas_price(None) in crates/revm/src/tx.rs), so gas accounting is unchanged

Test plan

  • Unit test test_l1_transaction_trait_methods updated and passes
  • Verified via Python equivalence test (test_rpc_fields.py): L1 message receipt effectiveGasPrice now matches between morph-geth and morph-reth

Summary by CodeRabbit

Bug Fixes

  • Fixed Layer 1 transaction gas price calculation to properly utilize base fee information, resulting in more accurate transaction fee estimates instead of defaulting to zero.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

The TxL1Msg implementation's effective_gas_price method was updated to actually use the base_fee parameter instead of ignoring it. The method now returns base_fee.unwrap_or(0) as u128 instead of a hardcoded 0. Unit tests were adjusted accordingly.

Changes

Cohort / File(s) Summary
L1 Transaction Method Update
crates/primitives/src/transaction/l1_transaction.rs
Updated effective_gas_price method to accept and utilize the base_fee parameter, returning its value (or 0 if None) instead of ignoring the parameter and always returning 0. Corresponding unit tests updated to verify the new behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • chengwenxi

Poem

🐰 A parameter once ignored, now takes its place,
No more underscore hiding—the base fee shows its face!
From zero-always to purposeful return,
The rabbit hops with joy—we finally use what we learn! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: returning baseFee as effectiveGasPrice for L1 messages, which aligns with the primary modification in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/l1-msg-effective-gas-price

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between b2275d4 and 2e60cd8.

📒 Files selected for processing (1)
  • crates/primitives/src/transaction/l1_transaction.rs

@panos-xyz panos-xyz merged commit f55a2cd into main Mar 26, 2026
9 checks passed
@panos-xyz panos-xyz deleted the fix/l1-msg-effective-gas-price branch March 26, 2026 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants