Skip to content

Add support for the Filecoin.EthGetCode V2#6490

Merged
sudo-shashank merged 10 commits intomainfrom
shashank/EthGetCodeV2
Jan 29, 2026
Merged

Add support for the Filecoin.EthGetCode V2#6490
sudo-shashank merged 10 commits intomainfrom
shashank/EthGetCodeV2

Conversation

@sudo-shashank
Copy link
Copy Markdown
Contributor

@sudo-shashank sudo-shashank commented Jan 28, 2026

Summary of changes

Changes introduced in this pull request:

  • Impl Filecoin.EthGetCode V2 and added test.

Reference issue to close (if applicable)

Closes #6299

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

  • New Features

    • Added an alternative EthGetCode v2 endpoint for Filecoin.EthGetCode with improved block-parameter handling.
  • Tests

    • Added test coverage and snapshot artifacts for the new EthGetCode v2 variant (identity, Safe, Finalized cases).
  • Chores

    • Added a changelog entry documenting the EthGetCode v2 implementation.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 28, 2026

Walkthrough

Adds a v2 RPC endpoint Filecoin.EthGetCode (EthGetCodeV2), centralizes bytecode retrieval into a shared async helper used by both EthGetCode variants, registers the new method in RPC dispatch, and adds tests plus snapshots for the v2 endpoint.

Changes

Cohort / File(s) Summary
RPC methods & core logic
src/rpc/methods/eth.rs, src/rpc/mod.rs
Added EthGetCodeV2 (v2 API path, ExtBlockNumberOrHash block param), extracted common bytecode retrieval into eth_get_code helper, and updated EthGetCode and EthGetCodeV2 to delegate to it. Registered EthGetCodeV2 in RPC method list.
Tests
src/tool/subcommands/api_cmd/api_compare_tests.rs
Added three EthGetCodeV2 test cases: identity (tipset epoch), Safe, and Finalized.
Test snapshots
src/tool/subcommands/api_cmd/test_snapshots.txt
Added three filecoin_ethgetcode_v2_*.rpcsnap.json.zst snapshot entries for the new tests.
Changelog
CHANGELOG.md
Added changelog entry describing PR 6490 / Filecoin.EthGetCode v2 implementation.

Sequence Diagram(s)

sequenceDiagram
    rect rgba(52,152,219,0.5)
    participant Client
    end
    rect rgba(46,204,113,0.5)
    participant RPC
    end
    rect rgba(241,196,15,0.5)
    participant TipsetResolver
    end
    rect rgba(155,89,182,0.5)
    participant MessageSystem
    end
    rect rgba(231,76,60,0.5)
    participant SystemActor
    end

    Client->>RPC: EthGetCodeV2(address, block)
    RPC->>TipsetResolver: resolve block (ExtBlockNumberOrHash)
    TipsetResolver-->>RPC: tipset
    RPC->>MessageSystem: invoke GetByteCode(to: address, tipset)
    MessageSystem->>SystemActor: system.GetByteCode invocation
    SystemActor-->>MessageSystem: return bytecode CID / failure
    MessageSystem-->>RPC: delivery receipt / result
    RPC-->>Client: bytecode (or null / error)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • hanabi1224
  • 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 'Add support for the Filecoin.EthGetCode V2' clearly and concisely summarizes the main change, implementing a V2 endpoint for the EthGetCode RPC method.
Linked Issues check ✅ Passed The pull request successfully implements the Filecoin.EthGetCode V2 RPC method as required by linked issue #6299, including the new EthGetCodeV2 endpoint, shared helper logic, and comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing EthGetCodeV2: new RPC variant definition, refactored shared logic, RPC method registration, test cases, and CHANGELOG entry. No unrelated modifications detected.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

@sudo-shashank sudo-shashank added the RPC requires calibnet RPC checks to run on CI label Jan 28, 2026
@sudo-shashank sudo-shashank marked this pull request as ready for review January 28, 2026 21:09
@sudo-shashank sudo-shashank requested a review from a team as a code owner January 28, 2026 21:09
@sudo-shashank sudo-shashank requested review from akaladarshi and hanabi1224 and removed request for a team January 28, 2026 21:09
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

🤖 Fix all issues with AI agents
In `@src/rpc/methods/eth.rs`:
- Around line 2443-2497: In eth_get_code: before attempting to decode
msg_rct.return_data() (and before calling fvm_ipld_encoding::from_slice /
constructing GetBytecodeReturn), explicitly check msg_rct.exit_code() for
success (e.g., ExitCode::OK) and return an error if it indicates failure; this
mirrors the EthGetStorageAt pattern and prevents decoding invalid return data
from api_invoc_result/msg_rct when the receipt failed despite
api_invoc_result.error being empty.

Comment thread src/rpc/methods/eth.rs
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 28, 2026

Codecov Report

❌ Patch coverage is 70.90909% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.74%. Comparing base (7254a42) to head (6c37967).

Files with missing lines Patch % Lines
src/rpc/methods/eth.rs 70.90% 11 Missing and 5 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/rpc/mod.rs 24.47% <ø> (ø)
src/rpc/methods/eth.rs 69.23% <70.90%> (+0.01%) ⬆️

... and 4 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 7254a42...6c37967. 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
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

🤖 Fix all issues with AI agents
In `@src/rpc/methods/eth.rs`:
- Around line 2451-2472: The code currently calls
ctx.state_manager.get_required_actor(&to_address, *ts.parent_state()) which
fails for non-existent addresses and misses actors created in the tipset;
instead, first obtain the post-state using the existing
ctx.state_manager.tipset_state(ts, StateLookupPolicy::Enabled).await? result
(the state variable), then resolve the actor from that post-state (use the state
lookup API instead of get_required_actor) and treat a missing actor as “no code”
by returning Ok(Default::default()). Only call is_evm_actor(&actor.code) when
the actor exists. Ensure the actor lookup and the empty-code return replace the
current get_required_actor call so EthGetCode uses the same post-state as
call_on_state.
🧹 Nitpick comments (1)
src/rpc/methods/eth.rs (1)

2419-2441: Add rustdoc for the new public RPC type.
EthGetCodeV2 is public but undocumented—please add a brief rustdoc comment.

♻️ Suggested doc comment
+/// Returns the contract code at a given address for the v2 API.
 pub enum EthGetCodeV2 {}

As per coding guidelines: Document all public functions and structs with rustdoc comments.

Comment thread src/rpc/methods/eth.rs Outdated
@sudo-shashank sudo-shashank added this pull request to the merge queue Jan 29, 2026
Merged via the queue into main with commit 8117383 Jan 29, 2026
41 of 45 checks passed
@sudo-shashank sudo-shashank deleted the shashank/EthGetCodeV2 branch January 29, 2026 08:24
@coderabbitai coderabbitai Bot mentioned this pull request Feb 5, 2026
6 tasks
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.EthGetCode

2 participants