Skip to content

Conversation

@sudo-shashank
Copy link
Contributor

@sudo-shashank sudo-shashank commented Dec 15, 2025

Summary of changes

Changes introduced in this pull request:

  • Add Filecoin.EthCall V2 API and test snapshots.

Reference issue to close (if applicable)

Closes #6290

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.

Summary by CodeRabbit

  • New Features

    • Added Filecoin.EthCall (v2) RPC endpoint to support eth_call-style requests with v2 block parameter handling.
  • Tests

    • Added v2 test variants for predefined and epoch/block cases and updated snapshots.
  • Chores

    • Added changelog entry and three new API snapshot files.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Walkthrough

Added a V2 variant of the Filecoin.EthCall RPC (EthCallV2) that accepts ExtBlockNumberOrHash, resolves tipsets via v2 tipset helpers (ChainGetTipSetV2 / tipset_by_block_number_or_hash_v2 / resolve_predefined_tipset_v2), registers the method under API v2, and adds corresponding tests and snapshots.

Changes

Cohort / File(s) Summary
RPC Method Implementation
src/rpc/methods/eth.rs
Added public EthCallV2 and impl RpcMethod<2> for Filecoin.EthCall/eth_call; switched params to (EthCallMessage, ExtBlockNumberOrHash); added tipset_by_block_number_or_hash_v2 and resolve_predefined_tipset_v2 helpers; imported ChainGetTipSetV2 and enumflags2::make_bitflags.
RPC Registration
src/rpc/mod.rs
Registered EthCallV2 in the ETH vertical within the for_each_rpc_method macro.
Tests / Test Harness
src/tool/subcommands/api_cmd/api_compare_tests.rs
Added EthCallV2 test variants (predefined Latest/Safe/Finalized and epoch/block variants), consolidated EthCall message construction, and appended V2 cases alongside existing tests.
Test Snapshots
src/tool/subcommands/api_cmd/test_snapshots.txt
Added three new v2 snapshots: filecoin_ethcall_v2_1765790311230200.rpcsnap.json.zst, filecoin_ethcall_v2_1765790311230270.rpcsnap.json.zst, filecoin_ethcall_v2_1765790311230334.rpcsnap.json.zst.
Changelog
CHANGELOG.md
Added entry documenting implementation of Filecoin.EthCall for API v2 (#6339).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to RpcMethod<2> constants (NAME, NAME_ALIAS, PARAM_NAMES, API_PATHS) for correctness.
  • Review v2 tipset resolution helpers and their async flows (ChainGetTipSetV2, tipset_by_block_number_or_hash_v2, resolve_predefined_tipset_v2) for correct integration and error handling.
  • Verify tests and new snapshots align with v2 behavior and do not duplicate or regress existing eth_call behavior.

Possibly related issues

  • Filecoin V2 APIs #5636 — Introduces Filecoin V2 EthCall and v2 tipset-resolution helpers; aligns with this PR's additions of EthCallV2 and ChainGetTipSetV2 usage.

Possibly related PRs

Suggested reviewers

  • akaladarshi
  • LesnyRumcajs
  • hanabi1224

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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: implementing Filecoin.EthCall V2 API support, which is clearly reflected in the code changes adding EthCallV2 method.
Linked Issues check ✅ Passed The PR successfully implements Filecoin.EthCall V2 API support as required by issue #6290, with code changes, tests, and CHANGELOG updates all present.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing EthCallV2: new RPC method, v2 tipset helpers, test cases, snapshots, and CHANGELOG entry—no out-of-scope modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch shashank/impl-ethcall_v2

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bdee2cb and cb43ea6.

📒 Files selected for processing (1)
  • src/rpc/mod.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Build Ubuntu
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: Build MacOS
  • GitHub Check: tests-release
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: Coverage
  • GitHub Check: tests
  • GitHub Check: All lint checks
  • GitHub Check: Check
🔇 Additional comments (1)
src/rpc/mod.rs (1)

105-105: LGTM.

The EthCallV2 registration follows the correct pattern and is properly integrated. The implementation in src/rpc/methods/eth.rs is complete, with all required trait members (NAME, NAME_ALIAS, API_PATHS, handle method) properly implemented and restricted to V2 API paths only.


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

@sudo-shashank sudo-shashank changed the title Add support for the Filecoin.EthCall V2 RPC Add support for the Filecoin.EthCall V2 Dec 15, 2025
@sudo-shashank sudo-shashank added the RPC requires calibnet RPC checks to run on CI label Dec 15, 2025
@sudo-shashank sudo-shashank marked this pull request as ready for review December 15, 2025 10:50
@sudo-shashank sudo-shashank requested a review from a team as a code owner December 15, 2025 10:50
@sudo-shashank sudo-shashank requested review from LesnyRumcajs and akaladarshi and removed request for a team December 15, 2025 10:50
Copy link
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: 0

🧹 Nitpick comments (2)
CHANGELOG.md (1)

54-55: Place the new EthCall v2 entry under “Forest unreleased → Added” instead of v0.30.5

The description and link are fine, but the guide at the top says new entries should go into the Forest unreleased section. Unless you’re intentionally backfilling the 0.30.5 release notes, this should live under Forest unreleased / Added and be removed from the 0.30.5 list to avoid confusion about when the feature ships.

@@
 ## Forest unreleased
 
 ### Breaking
 
 ### Added
+
+- [#6339](https://github.com/ChainSafe/forest/pull/6339) Implemented `Filecoin.EthCall` for API v2.
@@
-## Forest v0.30.5 "Dulce de Leche"
+## Forest v0.30.5 "Dulce de Leche"
@@
-- [#6323](https://github.com/ChainSafe/forest/pull/6323) Implemented `Filecoin.FilecoinAddressToEthAddress` for API v1 and v2.
-
-- [#6339](https://github.com/ChainSafe/forest/pull/6339) Implemented `Filecoin.EthCall` for API v2.
+- [#6323](https://github.com/ChainSafe/forest/pull/6323) Implemented `Filecoin.FilecoinAddressToEthAddress` for API v1 and v2.
src/rpc/methods/eth.rs (1)

907-927: V2 predefined tipset resolution correctly integrates F3 safe/finalized, but finalized fallback could be refined

The new resolve_predefined_tipset_v2 / tipset_by_block_number_or_hash_v2 pair cleanly reuses existing logic for Earliest/Pending/Latest while routing Safe/Finalized through ChainGetTipSetV2::{get_latest_safe_tipset,get_latest_finalized_tipset}, which is the right direction for v2 semantics.

One nuance: when get_latest_finalized_tipset returns None, the fallback currently resolves to height 0 via tipset_by_height(0, head, ResolveNullTipset::TakeOlder). That’s very conservative and effectively treats "finalized" as “genesis” on nodes without F3 finality, which may surprise callers and diverges from the height‑based approximation used in resolve_ext_predefined_tipset (which subtracts chain_finality from the latest height).

Consider instead reusing the existing finalized‐height logic (e.g., via resolve_ext_predefined_tipset or by computing latest_height - chain_finality) as a fallback so that "finalized" behaves consistently across v1/v2 call sites when F3 data is unavailable.

Also applies to: 1019-1042

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a89c05 and 5826ce2.

📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • src/rpc/methods/eth.rs (5 hunks)
  • src/rpc/mod.rs (1 hunks)
  • src/tool/subcommands/api_cmd/api_compare_tests.rs (2 hunks)
  • src/tool/subcommands/api_cmd/test_snapshots.txt (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-02T14:23:53.808Z
Learnt from: akaladarshi
Repo: ChainSafe/forest PR: 5923
File: src/tool/subcommands/api_cmd/test_snapshots.txt:206-252
Timestamp: 2025-09-02T14:23:53.808Z
Learning: In the Forest project, .rpcsnap.json.zst snapshot files listed in src/tool/subcommands/api_cmd/test_snapshots.txt are not stored in the repository itself but are downloaded from a DigitalOcean (DO) bucket when needed. The manifest file serves as an index/catalog of available snapshots.

Applied to files:

  • src/tool/subcommands/api_cmd/test_snapshots.txt
📚 Learning: 2025-09-02T10:05:34.350Z
Learnt from: akaladarshi
Repo: ChainSafe/forest PR: 5923
File: src/rpc/registry/actors/miner.rs:221-223
Timestamp: 2025-09-02T10:05:34.350Z
Learning: For miner actor ChangeOwnerAddress and ChangeOwnerAddressExported methods: versions 8-10 use bare Address as parameter type, while versions 11+ use ChangeOwnerAddressParams. This reflects the evolution of the Filecoin miner actor parameter structures across versions.

Applied to files:

  • CHANGELOG.md
  • src/rpc/methods/eth.rs
🧬 Code graph analysis (1)
src/tool/subcommands/api_cmd/api_compare_tests.rs (2)
src/rpc/methods/eth.rs (7)
  • from_predefined (362-364)
  • from_predefined (422-424)
  • from_str (285-287)
  • from_str (393-404)
  • from_str (453-472)
  • from_block_number (366-368)
  • from_block_number (426-428)
src/rpc/reflect/mod.rs (2)
  • request_with_alias (322-340)
  • request (288-298)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: Coverage
  • GitHub Check: Build MacOS
  • GitHub Check: All lint checks
  • GitHub Check: Build Ubuntu
  • GitHub Check: cargo-publish-dry-run
🔇 Additional comments (5)
src/tool/subcommands/api_cmd/test_snapshots.txt (1)

54-56: EthCallV2 snapshots are well‑placed; just confirm remote artifacts exist

The three filecoin_ethcall_v2_*.rpcsnap.json.zst entries follow the existing naming pattern and are grouped correctly with the existing filecoin_ethcall_* snapshots. Since this file is just a manifest and the actual .rpcsnap files are pulled from the DO bucket, please double‑check that the corresponding objects have been uploaded and that any new api_compare_tests cases reference these exact filenames. Based on learnings, the manifest is only an index for remote snapshots.

src/rpc/mod.rs (1)

103-105: Correctly wiring EthCallV2 into the RPC method registry

Registering $crate::rpc::eth::EthCallV2 in for_each_rpc_method! is consistent with how other v2 variants (e.g., StateGetActorV2, ChainGetTipSetV2) are exposed. This ensures EthCallV2 is included in module registration, OpenRPC generation, and the prelude without any extra boilerplate.

src/tool/subcommands/api_cmd/api_compare_tests.rs (2)

1445-1474: EthCall/EthCallV2 shared message construction and new v2 tag coverage look good

Reusing a single EthCallMessage per (to, data) case and driving both EthCall and EthCallV2 tests from it keeps the two methods in lock‑step. The added ExtPredefined::{Latest, Safe, Finalized} variants exercise the new v2 resolver without changing existing v1 behaviour. No issues spotted here.


1549-1580: Extending eth_call API error coverage to EthCallV2 is consistent

The loop now creates paired tests for EthCall and EthCallV2 against the same bytecode and epoch, with identical PolicyOnRejected::PassWithIdenticalError. This preserves the original v1 semantics and adds symmetric v2 coverage for error cases; implementation looks correct.

src/rpc/methods/eth.rs (1)

36-36: EthCallV2 wiring matches EthCall semantics and is correctly scoped to v2

Introducing EthCallV2 with:

  • type Params = (EthCallMessage, ExtBlockNumberOrHash),
  • API_PATHS = make_bitflags!(ApiPaths::{ V2 }), and
  • resolution via tipset_by_block_number_or_hash_v2,

ensures v2 requests hit the new resolver while reusing the exact same execution and decoding path as EthCall (same Message::try_from, apply_message, and return‑data handling, including the EAM special case). The added imports for ChainGetTipSetV2 and enumflags2::{BitFlags, make_bitflags} are consistent with this usage. This looks correct and non‑breaking with respect to existing v1 callers.

Also applies to: 66-66, 2661-2693

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 0% with 101 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (08b2e2c) to head (e01d6d5).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/rpc/methods/eth.rs 0.00% 54 Missing ⚠️
src/tool/subcommands/api_cmd/api_compare_tests.rs 0.00% 47 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (08b2e2c) and HEAD (e01d6d5). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (08b2e2c) HEAD (e01d6d5)
2 1
Additional details and impacted files
Files with missing lines Coverage Δ
src/rpc/mod.rs 0.00% <ø> (-24.48%) ⬇️
src/tool/subcommands/api_cmd/api_compare_tests.rs 0.00% <0.00%> (ø)
src/rpc/methods/eth.rs 0.00% <0.00%> (-66.31%) ⬇️

... and 387 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
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: 0

🧹 Nitpick comments (1)
src/rpc/methods/eth.rs (1)

907-927: EthCallV2 wiring and v2 tipset resolution look consistent and safe

  • resolve_predefined_tipset_v2 correctly reuses Predefined::try_from for earliest / pending / latest and delegates safe / finalized to ChainGetTipSetV2::get_latest_safe_tipset and get_latest_finalized_tipset, aligning EthCallV2’s semantics with the newer v2 chain helpers instead of the older SAFE_EPOCH_DELAY heuristics.
  • The finalized branch’s unwrap_or(ctx.chain_index().tipset_by_height(0, head, ResolveNullTipset::TakeOlder)?) fallback is a reasonable “no finalized tipset yet” behavior; if you ever want that case to fail loudly instead of silently using genesis, consider turning it into an explicit error, but it’s not required for correctness.
  • tipset_by_block_number_or_hash_v2 mirrors tipset_by_ext_block_number_or_hash for numeric and hash variants and only diverges on PredefinedBlock by calling the v2 resolver, which keeps behavior consistent for non‑predefined selectors.
  • EthCallV2’s RpcMethod<2> impl is a near‑clone of EthCall: same method name and alias, same params/return types except for ExtBlockNumberOrHash, and identical execution / decoding logic. Restricting API_PATHS to V2 via make_bitflags!(ApiPaths::{ V2 }) ensures v1 behavior is untouched while exposing the new v2 semantics on the dedicated path.

Overall this is a clean, low‑risk extension that keeps the call semantics aligned between v1 and v2 while letting v2 benefit from the improved safe/finalized resolution.

Also applies to: 1019-1042, 2660-2692

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73d3bf4 and bdee2cb.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • src/rpc/methods/eth.rs (5 hunks)
  • src/tool/subcommands/api_cmd/api_compare_tests.rs (2 hunks)
  • src/tool/subcommands/api_cmd/test_snapshots.txt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/tool/subcommands/api_cmd/test_snapshots.txt
  • CHANGELOG.md
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-02T10:05:34.350Z
Learnt from: akaladarshi
Repo: ChainSafe/forest PR: 5923
File: src/rpc/registry/actors/miner.rs:221-223
Timestamp: 2025-09-02T10:05:34.350Z
Learning: For miner actor ChangeOwnerAddress and ChangeOwnerAddressExported methods: versions 8-10 use bare Address as parameter type, while versions 11+ use ChangeOwnerAddressParams. This reflects the evolution of the Filecoin miner actor parameter structures across versions.

Applied to files:

  • src/rpc/methods/eth.rs
🧬 Code graph analysis (2)
src/tool/subcommands/api_cmd/api_compare_tests.rs (1)
src/rpc/methods/eth.rs (7)
  • from_predefined (362-364)
  • from_predefined (422-424)
  • from_str (285-287)
  • from_str (393-404)
  • from_str (453-472)
  • from_block_number (366-368)
  • from_block_number (426-428)
src/rpc/methods/eth.rs (3)
src/rpc/methods/chain.rs (4)
  • chain (447-447)
  • chain (485-485)
  • get_latest_safe_tipset (1045-1062)
  • get_latest_finalized_tipset (1064-1091)
src/rpc/methods/eth/types.rs (9)
  • try_from (235-242)
  • try_from (248-250)
  • try_from (256-258)
  • try_from (270-272)
  • try_from (278-280)
  • try_from (353-393)
  • default (483-485)
  • default (629-631)
  • default (657-659)
src/rpc/methods/eth/utils.rs (1)
  • decode_payload (63-76)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: Build MacOS
  • GitHub Check: tests-release
  • GitHub Check: Coverage
  • GitHub Check: tests
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: All lint checks
  • GitHub Check: Build Ubuntu
🔇 Additional comments (3)
src/tool/subcommands/api_cmd/api_compare_tests.rs (2)

1444-1474: EthCall / EthCallV2 happy‑path tests look correct and cover new tags

Reusing a single EthCallMessage per (to, data) case and feeding it to both EthCall (with BlockNumberOrHash::from_predefined(Predefined::Latest)) and EthCallV2 (with ExtBlockNumberOrHash::PredefinedBlock for Latest, Safe, and Finalized) matches the respective RPC parameter types and ensures v2 coverage of the new predefined tags without changing existing v1 behavior. No issues here.


1535-1581: Error‑path coverage for EthCall and EthCallV2 is symmetric and well‑structured

The refactored eth_call_api_err_tests builds a single EthCallMessage per contract bytecode and then issues both EthCall and EthCallV2 requests at the same epoch (via from_block_number for BlockNumberOrHash and ExtBlockNumberOrHash). Using RpcTest::identity(...).policy_on_rejected(PolicyOnRejected::PassWithIdenticalError) ensures that v1 and v2 surface identical error text for these failing contracts. This is a good, explicit expansion of coverage with clear construction of inputs.

src/rpc/methods/eth.rs (1)

36-36: New imports are minimal and scoped to the EthCallV2 implementation

Bringing in ChainGetTipSetV2 and BitFlags/make_bitflags is appropriate for the new v2 tipset resolution and API_PATHS definition; no unused or overly broad imports introduced.

Also applies to: 66-66

Copy link
Collaborator

@akaladarshi akaladarshi left a comment

Choose a reason for hiding this comment

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

I have couple of points here:

1 - The changes are getting duplicated now, we need a change in the implementation where we can have two different resolvers which handles everything related to V1 and V2 separately and can use common functions if needed. As more V2 API are added we might have more duplicate logic.

  • This is just a suggestion but we can do something like: V1 and V2 types which
    implements the a common interface and resolve things separately. I would like to avoid having code duplication in both V1 and V2 if possible.

2 - We should move the V2 API's to eth_v2 file or something similar, the eth.rs is already quite big and adding V2 API's there will bloat it.

@sudo-shashank sudo-shashank added this pull request to the merge queue Dec 18, 2025
Merged via the queue into main with commit 150b367 Dec 18, 2025
54 checks passed
@sudo-shashank sudo-shashank deleted the shashank/impl-ethcall_v2 branch December 18, 2025 05:45
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.

[RPC v2] Filecoin.EthCall

4 participants