Skip to content

Update expensive migration check#7128

Draft
sudo-shashank wants to merge 8 commits into
mainfrom
shashank/update-expensive-migration-check
Draft

Update expensive migration check#7128
sudo-shashank wants to merge 8 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)

Closes

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

  • Bug Fixes

    • Fixed eth_call and eth_estimateGas no longer immediately rejected after expensive network-upgrade migrations; only the upgrade epoch is refused.
    • Expensive-fork rejections now return standardized error code with fork epoch information for improved diagnostics.
  • Tests

    • Updated test environment configurations and expensive-fork error scenarios.

@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

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 53a0158a-918c-41ad-969c-f6fdd6b8b10d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Error::ExpensiveFork is extended from a unit variant to a struct variant carrying epoch: ChainEpoch. ChainConfig gains expensive_fork_between returning the lowest matching epoch in a half-open range. A new JSON-RPC code -32002 is mapped from this error. eth_getCode, eth_getStorageAt, and apply_message are updated with epoch-aware guards and retry loops that rewind the execution-context tipset on expensive-fork, rather than refusing.

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 becomes a struct variant with epoch: ChainEpoch. ChainConfig gains expensive_fork_between(parent, height) -> Option<ChainEpoch> returning the lowest expensive migration epoch in [parent, height), and has_expensive_fork_between delegates to it. Unit tests cover calibnet windows.
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 return the new code with epoch as JSON error data.
call_raw expensive-fork detection refactor
src/state_manager/message_simulation.rs
Replaces parent-tipset-load + has_expensive_fork_between with a fork_floor/fork_height range based on whether state_cid is provided, then queries chain_config.expensive_fork_between and returns Error::ExpensiveFork { epoch }.
ETH RPC apply_message guard, retry loops, and eth_estimateGas
src/rpc/methods/eth.rs
apply_message guard switches to has_expensive_fork_between(ts.epoch(), ts.epoch()+1) returning ExpensiveFork { epoch: ts.epoch() }. eth_getCode and get_storage_at replace iteration attempts with retry loops keeping state_root fixed while rewinding ts to its parent on ExpensiveFork. eth_estimate_gas failure branch retries via apply_message to surface ExecutionReverted errors.
StateCall::run pattern match update
src/rpc/methods/state.rs
Updates the error match arm to Error::ExpensiveFork { .. } for the new struct variant, preserving parent-tipset reload and retry behavior.
API compare test fixes, CHANGELOG, and Lotus image bump
src/tool/subcommands/api_cmd/api_compare_tests.rs, CHANGELOG.md, scripts/tests/api_compare/.env
Test filter tightened to < heaviest_tipset.epoch() and EthCall target moved to expensive_fork_epoch + 1. CHANGELOG documents updated behavior. LOTUS_IMAGE bumped to v1.36.1-rc1-calibnet.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant eth_getCode/eth_getStorageAt
    participant call_raw
    participant ChainConfig

    Client->>eth_getCode/eth_getStorageAt: request at tipset ts
    eth_getCode/eth_getStorageAt->>call_raw: call_on_state(state_root, ts)
    call_raw->>ChainConfig: expensive_fork_between(fork_floor, fork_height)
    ChainConfig-->>call_raw: Some(epoch)
    call_raw-->>eth_getCode/eth_getStorageAt: Err(ExpensiveFork { epoch })
    eth_getCode/eth_getStorageAt->>eth_getCode/eth_getStorageAt: ts = ts.parents()
    eth_getCode/eth_getStorageAt->>call_raw: call_on_state(state_root, parent_ts)
    call_raw->>ChainConfig: expensive_fork_between(...)
    ChainConfig-->>call_raw: None
    call_raw-->>eth_getCode/eth_getStorageAt: Ok(result)
    eth_getCode/eth_getStorageAt-->>Client: result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ChainSafe/forest#7061: Directly modifies StateManager::call_raw and Error::ExpensiveFork handling in src/state_manager/message_simulation.rs, which is the core logic this PR extends.

Suggested reviewers

  • akaladarshi
  • LesnyRumcajs
🚥 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 'Update expensive migration check' clearly and concisely summarizes the main objective of the pull request, which is to port changes that refactor expensive fork/migration checking logic across multiple modules.
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
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