Skip to content

fix(rpc): use L2 gas price oracle and treat tip=0 without maxFee as zero-priced - #245

Open
panos-xyz wants to merge 1 commit into
mainfrom
fix/rpc-gas-oracle-and-zero-tip-estimate
Open

panos-xyz wants to merge 1 commit into
mainfrom
fix/rpc-gas-oracle-and-zero-tip-estimate

Conversation

@panos-xyz

Copy link
Copy Markdown
Contributor

Summary

Fixes two RPC fee-suggestion / gas-estimation issues observed on live Morph Mainnet and Hoodi testnet morph-reth RPC nodes:

1. LoadFee::suggested_priority_fee (crates/rpc/src/eth/mod.rs)

  • Problem: Upstream GasPriceOracle::suggest_tip_cap pushes U256::ZERO for every empty block and scans up to 2 * max_block_history (2,048) blocks against a 1,024-entry LRU cache. Because Morph L2 blocks are frequently empty (74%+ on mainnet, 90%+ on Hoodi testnet), eth_maxPriorityFeePerGas collapsed to 0x0, eth_gasPrice returned only baseFee (0xf4240), MORPH_DEFAULT_PRIORITY_FEE (0.001 Gwei) became dead code after block 0, and very quiet networks risked 2,048-block LRU thrashing under the global oracle lock.
  • Fix: Overrode LoadFee::suggested_priority_fee on MorphEthApi to use GasPriceOracle::op_suggest_tip_cap with default_suggested_fee.unwrap_or(MORPH_DEFAULT_PRIORITY_FEE) as the minimum floor:
    • Inspects only the latest block (O(1), no 2,048-block back-scan or LRU thrashing).
    • Returns the configured floor (MORPH_DEFAULT_PRIORITY_FEE = 1_000_000 wei by default, honoring --gpo.default-suggested-fee and --gpo.maxprice) whenever the latest block has spare gas capacity.
    • Scales up to 110% of the latest block's median effective tip when the block reaches capacity (gas_used + max_tx_gas_used > gas_limit), safely skipping L1MessageTx via filter_map(effective_tip_per_gas).

2. Zero-tip simulation requests without maxFeePerGas (crates/rpc/src/eth/transaction.rs)

  • Problem: When a caller calls eth_estimateGas / eth_call with maxPriorityFeePerGas: "0x0" and omits maxFeePerGas (with no legacy gasPrice), alloy-evm's CallFees::ensure_fees priced the call at base_fee + 0 instead of 0. For zero-balance callers this triggered caller_gas_allowance and failed with insufficient funds for l1 fee, diverging from morph-geth (ToMessage / DoEstimateGas) and from passing (0, 0) or omitting both fields.
  • Fix: Normalized gas_price: None, max_fee_per_gas: None, max_priority_fee_per_gas: Some(0) in MorphTransactionRequest::try_into_tx_env by setting max_fee_per_gas = Some(0) before delegating to inner.try_into_tx_env, while preserving allowance enforcement for explicit non-zero maxFeePerGas / non-zero maxPriorityFeePerGas and conflict errors when legacy gasPrice is also set.

Tests

  • Added unit test try_into_tx_env_zero_tip_without_max_fee_is_zero_priced in crates/rpc/src/eth/transaction.rs.
  • Added integration tests gas_price_oracle_returns_floor_on_empty_blocks_and_scales_at_capacity and estimate_gas_allows_zero_priority_fee_without_max_fee_for_zero_balance_sender in crates/node/tests/it/rpc.rs.

Verification

  • cargo fmt --all -- --check — pass
  • cargo clippy --workspace --all-targets -- -D warnings — pass
  • cargo test -p morph-rpc — 128/128 passed
  • cargo test -p morph-node --features test-utils --test it rpc — 29/29 passed

@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 28 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3402e76c-b7bd-49ef-9671-80fdd7af6231
Commits

Reviewing files that changed from the base of the PR and between e01b16a and 1919552.

Files selected for processing: 3

  • crates/node/tests/it/rpc.rs
  • crates/rpc/src/eth/mod.rs
  • crates/rpc/src/eth/transaction.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

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

panos-xyz added a commit that referenced this pull request Nov 28, 2026
…develop

# Conflicts:
#	crates/node/tests/it/rpc.rs
#	crates/rpc/src/eth/transaction.rs
panos-xyz added a commit that referenced this pull request Dec 1, 2026
…develop

# Conflicts:
#	crates/node/tests/it/rpc.rs
#	crates/rpc/src/eth/transaction.rs
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.

1 participant