Skip to content

feat: add eth_baseFee rpc method#7028

Open
wjmelements wants to merge 2 commits intoChainSafe:mainfrom
wjmelements:eth-base-fee
Open

feat: add eth_baseFee rpc method#7028
wjmelements wants to merge 2 commits intoChainSafe:mainfrom
wjmelements:eth-base-fee

Conversation

@wjmelements
Copy link
Copy Markdown

@wjmelements wjmelements commented May 9, 2026

Adds the nonstandard eth_baseFee eth jsonrpc method.
This method returns the calculated base fee of the next epoch.
See filecoin-project/lotus#13615

Changes

  • add eth_baseFee
  • regenerate snapshots

Summary by CodeRabbit

  • New Features
    • Added eth_baseFee JSON-RPC method (also accessible as Filecoin.EthBaseFee) for Ethereum compatibility, allowing applications to query the network's current base fee.
    • Method is now included in the RPC method registry/OpenRPC spec so it’s discoverable via the API.

Review Change Stack

Assisted-by: Claude:claude-sonnet-4-6
@wjmelements wjmelements requested a review from a team as a code owner May 9, 2026 10:31
@wjmelements wjmelements requested review from LesnyRumcajs and hanabi1224 and removed request for a team May 9, 2026 10:31
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 9, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 080ecc52-cc5a-4ca6-8639-845ca2823dcb

📥 Commits

Reviewing files that changed from the base of the PR and between d7f773c and bbd1e5f.

📒 Files selected for processing (1)
  • src/rpc/methods/eth.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/rpc/methods/eth.rs

Walkthrough

This PR introduces a new Ethereum-compatible JSON-RPC method eth_baseFee (Filecoin.EthBaseFee) that computes and returns the base fee for the heaviest tipset. The implementation adds required imports, implements the handler logic using chain configuration height epochs, and registers the method in the RPC macro system.

Changes

Ethereum Base Fee RPC Method

Layer / File(s) Summary
Imports & Dependencies
src/rpc/methods/eth.rs
Added imports for compute_base_fee and ResolveNullTipset from crate::chain, and Height from crate::networks to support base fee calculation.
RPC Method Handler
src/rpc/methods/eth.rs
Implemented EthBaseFee as a new RpcMethod<0> that derives Smoke and FireHorse epochs from ctx.chain_config().height_infos, computes base fee for the heaviest tipset via compute_base_fee, and returns the result as EthBigInt.
RPC Registration
src/rpc/mod.rs
Registered the new EthBaseFee method in the for_each_rpc_method! macro's eth vertical registration list.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • ChainSafe/forest#6702: Updates to compute_base_fee signature and call sites that directly relate to the base fee computation introduced in this RPC method.

Suggested labels

RPC

Suggested reviewers

  • LesnyRumcajs
  • akaladarshi
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding the eth_baseFee RPC method. It is specific, concise, and directly reflects the primary objective of the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Contributor

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/rpc/methods/eth.rs`:
- Line 835: The call to compute_base_fee(...) can fail without contextual
information; wrap the call with .context(...) to add an explanatory message for
RPC diagnostics so errors include that compute_base_fee failed and the relevant
inputs (e.g., timestamp ts and heights smoke_height/firehorse_height) — locate
the call to compute_base_fee in eth.rs and change the invocation so the returned
Result is propagated with .context("compute_base_fee failed for ts/
smoke_height/ firehorse_height") (or similar) to satisfy the anyhow::Result
guideline.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 22c12b5e-0961-4079-9ad9-415b69b9ab92

📥 Commits

Reviewing files that changed from the base of the PR and between e2becd7 and d7f773c.

⛔ Files ignored due to path filters (3)
  • src/rpc/snapshots/forest__rpc__tests__rpc__v0.snap is excluded by !**/*.snap
  • src/rpc/snapshots/forest__rpc__tests__rpc__v1.snap is excluded by !**/*.snap
  • src/rpc/snapshots/forest__rpc__tests__rpc__v2.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/rpc/methods/eth.rs
  • src/rpc/mod.rs

Comment thread src/rpc/methods/eth.rs Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2040 1 2039 0
View the top 1 failed test(s) by shortest run time
forest-filecoin::tool::subcommands::api_cmd::test_snapshot::tests::rpc_regression_tests_print_uncovered
Stack Traces | 0.019s run time
thread 'tool::subcommands::api_cmd::test_snapshot::tests::rpc_regression_tests_print_uncovered' (62234) panicked at .../subcommands/api_cmd/test_snapshot.rs:284:9:
either ignore or upload test snapshots for uncovered RPC methods
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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