Skip to content

Conversation

@sudo-shashank
Copy link
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 snapshots 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
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, and adds tests plus snapshots for the new 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) and extracted common bytecode retrieval into eth_get_code helper; both EthGetCode and EthGetCodeV2 delegate to it.
Tests
src/tool/subcommands/api_cmd/api_compare_tests.rs
Added three EthGetCodeV2 test cases (identity, Safe, Finalized).
Test snapshots
src/tool/subcommands/api_cmd/test_snapshots.txt
Added three filecoin_ethgetcode_v2_*.rpcsnap.json.zst snapshot entries.
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

Possibly related PRs

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 clearly and concisely describes the main change: adding support for Filecoin.EthGetCode V2 API endpoint.
Linked Issues check ✅ Passed The PR successfully implements the Filecoin.EthGetCode V2 RPC method as required by issue #6299, including tests and documentation updates.
Out of Scope Changes check ✅ Passed All changes directly support the implementation of EthGetCodeV2: RPC method definition, helper logic refactoring, test coverage, and changelog documentation.

✏️ 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
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.

@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

❌ Patch coverage is 78.84615% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.72%. Comparing base (7254a42) to head (84384a7).

Files with missing lines Patch % Lines
src/rpc/methods/eth.rs 78.84% 6 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.38% <78.84%> (+0.17%) ⬆️

... and 7 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...84384a7. 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: 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.

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