Skip to content

fix(rpc): Update expensive migration check#7128

Open
sudo-shashank wants to merge 15 commits into
mainfrom
shashank/update-expensive-migration-check
Open

fix(rpc): Update expensive migration check#7128
sudo-shashank wants to merge 15 commits into
mainfrom
shashank/update-expensive-migration-check

Conversation

@sudo-shashank

@sudo-shashank sudo-shashank commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary of changes

Changes introduced in this pull request:

Reference issue to close (if applicable)

Follow up PR #7192

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved eth_call, eth_estimateGas, eth_getCode, and eth_getStorageAt behavior during expensive network-upgrade migrations: requests are refused only at the upgrade epoch, and eth_getCode/eth_getStorageAt now retry on expensive-fork conditions.
    • Enhanced eth_estimateGas to re-execute the call after a gas estimation failure to surface accurate revert details when applicable.
    • Standardized expensive-fork JSON-RPC errors with code -32002, including the fork epoch in the response data.

@sudo-shashank sudo-shashank added the RPC requires calibnet RPC checks to run on CI label Jun 2, 2026
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)

Walkthrough

Error::ExpensiveFork is changed from a unit variant to a struct variant carrying epoch: ChainEpoch. ChainConfig gains expensive_fork_between returning the lowest matching fork epoch in a half-open interval. call_raw, apply_message, eth_getCode, eth_getStorageAt, and StateCall::run are updated to use the new epoch-carrying variant, and the JSON-RPC layer maps it to error code -32002 with the epoch in the data field.

Changes

Expensive Fork Epoch Payload and ETH RPC Retry

Layer / File(s) Summary
Error::ExpensiveFork epoch payload and ChainConfig::expensive_fork_between
src/state_manager/errors.rs, src/networks/mod.rs
Error::ExpensiveFork gains epoch: ChainEpoch payload. ChainConfig adds expensive_fork_between(parent, height) -> Option<ChainEpoch> returning the minimum matching fork epoch in [parent, height), and has_expensive_fork_between delegates to it. Unit tests verify the new method on calibnet.
JSON-RPC -32002 error code and ServerError mapping
src/rpc/error.rs
Adds EXPENSIVE_FORK_CODE = -32002 constant. Extends From<anyhow::Error> for ServerError to downcast ExpensiveFork { epoch } and produce a ServerError with the new code and epoch as JSON data.
call_raw expensive-fork detection
src/state_manager/message_simulation.rs
Replaces parent-tipset-load + has_expensive_fork_between with a fork_floor/fork_height range derived from whether state_cid is provided, then returns Error::ExpensiveFork { epoch } when chain_config.expensive_fork_between finds a match.
ETH RPC apply_message guard, retry loops, and eth_estimateGas
src/rpc/methods/eth.rs
apply_message guard switches to ts.epoch()-based check returning ExpensiveFork { epoch: ts.epoch() }. eth_getCode and get_storage_at replace iteration-based retries with loops that hold state_root fixed and rewind ts to its parent on ExpensiveFork. eth_estimateGas error path retries via apply_message to surface ExecutionReverted errors.
StateCall::run pattern match update
src/rpc/methods/state.rs
Updates the ExpensiveFork match arm to Error::ExpensiveFork { .. } for the new struct variant; refines comments describing the parent→tipset window.
CHANGELOG and API filter list updates
CHANGELOG.md, scripts/tests/api_compare/filter-list*
CHANGELOG documents updated refusal behavior and the -32002 error code. API comparison filter lists exclude StateGetNetworkParams, EthGetBlockByHash, EthGetBlockByNumber, and EthGetTransactionByHashLimited.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ChainSafe/forest#7061: Directly modifies StateManager::call_raw in src/state_manager/message_simulation.rs to return an ExpensiveFork refusal that drives higher-level RPC retry/error behavior, the same code path updated in this PR.

Suggested reviewers

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.67% 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 'fix(rpc): Update expensive migration check' directly and clearly describes the main change across the PR—updating the expensive migration/fork check logic in the RPC layer.
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
  • Commit unit tests in branch shashank/update-expensive-migration-check
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch shashank/update-expensive-migration-check

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

@sudo-shashank sudo-shashank changed the title Fix expensive migration check Update expensive migration check Jun 5, 2026
@sudo-shashank sudo-shashank force-pushed the shashank/update-expensive-migration-check branch from 2c661a5 to 2d3ab7c Compare June 5, 2026 09:06
@sudo-shashank sudo-shashank marked this pull request as ready for review June 18, 2026 09:57
@sudo-shashank sudo-shashank requested a review from a team as a code owner June 18, 2026 09:57
@sudo-shashank sudo-shashank requested review from akaladarshi and hanabi1224 and removed request for a team June 18, 2026 09:57
@sudo-shashank sudo-shashank marked this pull request as draft June 18, 2026 10:08
@sudo-shashank sudo-shashank force-pushed the shashank/update-expensive-migration-check branch from 3acda30 to 0ac22c3 Compare June 18, 2026 15:35
@sudo-shashank sudo-shashank force-pushed the shashank/update-expensive-migration-check branch from 7a9e81e to df63051 Compare June 18, 2026 15:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
scripts/tests/api_compare/filter-list (1)

4-6: ⚡ Quick win

Add upstream references for new ignored RPCs.

Please add short comments (issue/PR links) next to these new exclusions to make re-enabling trackable and avoid permanent blind spots.

Suggested update
 !Filecoin.StateGetNetworkParams
 !Filecoin.EthGetBlockByHash
 !Filecoin.EthGetBlockByNumber
+# https://github.com/filecoin-project/lotus/pull/13640
+!Filecoin.StateGetNetworkParams
+# https://github.com/filecoin-project/lotus/pull/13618
+!Filecoin.EthGetBlockByHash
+!Filecoin.EthGetBlockByNumber
🤖 Prompt for 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.

In `@scripts/tests/api_compare/filter-list` around lines 4 - 6, The three newly
ignored RPC methods (Filecoin.StateGetNetworkParams, Filecoin.EthGetBlockByHash,
and Filecoin.EthGetBlockByNumber) in the filter-list file are missing upstream
reference comments. Add short comments with issue or PR links next to each of
these three exclusions to document why they are being ignored and make it
possible to track when they can be re-enabled in the future, ensuring these are
not permanently blindspotted.
🤖 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.

Nitpick comments:
In `@scripts/tests/api_compare/filter-list`:
- Around line 4-6: The three newly ignored RPC methods
(Filecoin.StateGetNetworkParams, Filecoin.EthGetBlockByHash, and
Filecoin.EthGetBlockByNumber) in the filter-list file are missing upstream
reference comments. Add short comments with issue or PR links next to each of
these three exclusions to document why they are being ignored and make it
possible to track when they can be re-enabled in the future, ensuring these are
not permanently blindspotted.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 08983cce-b48e-4e93-87f7-acc3394e68e6

📥 Commits

Reviewing files that changed from the base of the PR and between 31d6ec3 and d065adf.

📒 Files selected for processing (7)
  • scripts/devnet/.env
  • scripts/tests/api_compare/filter-list
  • scripts/tests/api_compare/filter-list-gateway
  • scripts/tests/api_compare/filter-list-offline
  • scripts/tests/bootstrapper/.env
  • scripts/tests/snapshot_parity/.env
  • src/rpc/methods/state.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)
✅ Files skipped from review due to trivial changes (3)
  • scripts/tests/snapshot_parity/.env
  • scripts/tests/api_compare/filter-list-offline
  • scripts/tests/bootstrapper/.env
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/rpc/methods/state.rs

@sudo-shashank sudo-shashank changed the title Update expensive migration check fix(rpc): Update expensive migration check Jun 18, 2026
@sudo-shashank sudo-shashank marked this pull request as ready for review June 19, 2026 16:28
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.37%. Comparing base (d1cb4f8) to head (5e97c29).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/rpc/methods/eth.rs 41.17% 20 Missing ⚠️
src/rpc/error.rs 33.33% 4 Missing ⚠️
src/state_manager/message_simulation.rs 66.66% 1 Missing and 2 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/networks/mod.rs 89.84% <100.00%> (+0.58%) ⬆️
src/rpc/methods/state.rs 44.40% <ø> (ø)
src/state_manager/errors.rs 40.00% <ø> (ø)
src/state_manager/message_simulation.rs 77.59% <66.66%> (-0.19%) ⬇️
src/rpc/error.rs 37.83% <33.33%> (-0.40%) ⬇️
src/rpc/methods/eth.rs 64.95% <41.17%> (-0.15%) ⬇️

... and 9 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d1cb4f8...5e97c29. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RPC requires calibnet RPC checks to run on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant