Skip to content

feat: add support for ethaccount actor in state decode params API #5995

Merged
akaladarshi merged 14 commits intomainfrom
akaladarshi/add-eth-account-state-decode-params
Sep 2, 2025
Merged

feat: add support for ethaccount actor in state decode params API #5995
akaladarshi merged 14 commits intomainfrom
akaladarshi/add-eth-account-state-decode-params

Conversation

@akaladarshi
Copy link
Copy Markdown
Collaborator

@akaladarshi akaladarshi commented Aug 26, 2025

Summary of changes

Changes introduced in this pull request:

  • Adds support for the ethaccount actor in state decode params API

Reference issue to close (if applicable)

Closes #5993

Other information and links

File Name Method Name Method Number
filecoin_ethaccount_statedecodeparams_1756186350854913.rpcsnap.json.zst Constructor 1

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 RPC support for the EthAccount actor, enabling parameter decoding for its Constructor across supported versions.
    • Registry now recognizes EthAccount for method/parameter deserialization and decoding via delegated Ethereum account addresses.
  • Tests

    • Added an API comparison test for EthAccount state parameter decoding.
    • Added corresponding test snapshot.
  • Chores

    • Added a new dependency to support EthAccount state handling.

@akaladarshi akaladarshi requested a review from a team as a code owner August 26, 2025 05:49
@akaladarshi akaladarshi requested review from elmattic and hanabi1224 and removed request for a team August 26, 2025 05:49
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 26, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

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

Walkthrough

Adds EthAccount actor support to the RPC method registry: new version-aware eth_account registration module (v10–v16), wiring into the registry match on BuiltinActor::EthAccount, dependency fil_actor_ethaccount_state = { version = "23" }, and a state-decode test plus snapshot for the Constructor with empty params.

Changes

Cohort / File(s) Summary
Dependency update
Cargo.toml
Adds dependency fil_actor_ethaccount_state = { version = "23" }.
EthAccount actor registration
src/rpc/registry/actors/eth_account.rs, src/rpc/registry/actors/mod.rs
New module eth_account with macro-driven per-state-version registration (v10–v16); registers Constructor as having no params; exported from actors mod.
Registry wiring
src/rpc/registry/methods_reg.rs
Imports eth_account and adds BuiltinActor::EthAccount match arm to call eth_account::register_actor_methods(self, cid, version).
Tests & snapshots
src/tool/subcommands/api_cmd/api_compare_tests.rs, src/tool/subcommands/api_cmd/test_snapshots.txt
Adds a test decoding EthAccount Constructor (empty params) via delegated address and adds corresponding snapshot entry.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Registry as MethodRegistry
  participant Matcher as BuiltinActor matcher
  participant EthAcc as eth_account::register_actor_methods
  participant StateMod as fil_actor_ethaccount_state (v10..v16)

  Client->>Registry: request registration(cid, version, builtin)
  Registry->>Matcher: match builtin actor
  Matcher-->>Registry: EthAccount
  Registry->>EthAcc: register_actor_methods(registry, cid, version)
  alt version in 10..16
    EthAcc->>StateMod: select v{version} module
    Note over EthAcc,StateMod #D6EAF8: register Constructor (no params)
    EthAcc-->>Registry: methods registered
  else unsupported version
    EthAcc-->>Registry: no-op
  end
  Registry-->>Client: registration complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Support EthAccount StateDecodeParams for V10–V16 (#5993)

Possibly related issues

Possibly related PRs

Suggested reviewers

  • hanabi1224
  • elmattic
  • LesnyRumcajs
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch akaladarshi/add-eth-account-state-decode-params

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@akaladarshi akaladarshi added the RPC requires calibnet RPC checks to run on CI label Aug 26, 2025
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

🧹 Nitpick comments (6)
src/tool/subcommands/api_cmd/api_compare_tests.rs (1)

1868-1874: Add EthAccount Constructor decode-params test via delegated address

Good addition; this exercises the new registry path using a delegated address in the EAM namespace and empty params. Minor nit: replace unwrap with expect for clearer failure context.

-        RpcTest::identity(StateDecodeParams::request((
-            Address::new_delegated(Address::ETHEREUM_ACCOUNT_MANAGER_ACTOR.id()?, &[0; 20])
-                .unwrap(),
+        RpcTest::identity(StateDecodeParams::request((
+            Address::new_delegated(
+                Address::ETHEREUM_ACCOUNT_MANAGER_ACTOR.id()?,
+                &[0; 20],
+            )
+            .expect("failed to construct delegated EAM address"),
             fil_actor_ethaccount_state::v16::Method::Constructor as u64,
             vec![],
             tipset.key().into(),
         ))?),
src/rpc/registry/actors/eth_account.rs (3)

4-7: Avoid name ambiguity and drop unused import

  • The local function is named register_actor_methods, and the macro used is also named register_actor_methods!. While different namespaces prevent a hard conflict, aliasing the macro improves readability and avoids confusion during navigation and tooling.
  • MethodNum is imported but unused.
-use crate::rpc::registry::methods_reg::{MethodRegistry, register_actor_methods};
-use crate::shim::message::MethodNum;
+use crate::rpc::registry::methods_reg::{
+    MethodRegistry,
+    register_actor_methods as register_actor_methods_macro,
+};

8-15: Macro naming and invocation consistency

The macro name register_eth_account_reg_version! is slightly awkward and inconsistent with similar modules (e.g., account’s register_account_version!). Consider renaming for consistency and updating the invocation of the aliased register_actor_methods macro for clarity.

-macro_rules! register_eth_account_reg_version {
+macro_rules! register_eth_account_version {
     ($registry:expr, $code_cid:expr, $state_version:path) => {{
         use $state_version::*;
 
         // Constructor has no parameters
-        register_actor_methods!($registry, $code_cid, [(Method::Constructor, empty),]);
+        register_actor_methods_macro!($registry, $code_cid, [(Method::Constructor, empty),]);
     }};
 }

Note: If you keep the current macro name, still prefer the aliased invocation:

-        register_actor_methods!($registry, $code_cid, [(Method::Constructor, empty),]);
+        register_actor_methods_macro!($registry, $code_cid, [(Method::Constructor, empty),]);

17-28: Version dispatch covers v10–v16; Constructor-only mapping is fine

The version switch is complete for the supported range and correctly registers Constructor with empty params. No issues spotted. If you rename the macro as suggested, update the calls accordingly.

-    match version {
-        10 => register_eth_account_reg_version!(registry, cid, fil_actor_ethaccount_state::v10),
-        11 => register_eth_account_reg_version!(registry, cid, fil_actor_ethaccount_state::v11),
-        12 => register_eth_account_reg_version!(registry, cid, fil_actor_ethaccount_state::v12),
-        13 => register_eth_account_reg_version!(registry, cid, fil_actor_ethaccount_state::v13),
-        14 => register_eth_account_reg_version!(registry, cid, fil_actor_ethaccount_state::v14),
-        15 => register_eth_account_reg_version!(registry, cid, fil_actor_ethaccount_state::v15),
-        16 => register_eth_account_reg_version!(registry, cid, fil_actor_ethaccount_state::v16),
+    match version {
+        10 => register_eth_account_version!(registry, cid, fil_actor_ethaccount_state::v10),
+        11 => register_eth_account_version!(registry, cid, fil_actor_ethaccount_state::v11),
+        12 => register_eth_account_version!(registry, cid, fil_actor_ethaccount_state::v12),
+        13 => register_eth_account_version!(registry, cid, fil_actor_ethaccount_state::v13),
+        14 => register_eth_account_version!(registry, cid, fil_actor_ethaccount_state::v14),
+        15 => register_eth_account_version!(registry, cid, fil_actor_ethaccount_state::v15),
+        16 => register_eth_account_version!(registry, cid, fil_actor_ethaccount_state::v16),
         _ => {}
     }
src/rpc/registry/methods_reg.rs (2)

128-131: Minor: avoid an extra String allocation when base64-encoding bytes.

BASE64_STANDARD.encode(bytes).as_str() builds a String and then converts to &str, which serde_json::json! will re-allocate into a String again. Passing the String directly avoids the extra copy.

Apply this diff:

-                        use base64::{Engine as _, prelude::BASE64_STANDARD};
-                        // Return bytes as base64 string, matching Lotus behavior
-                        Ok(serde_json::json!(BASE64_STANDARD.encode(bytes).as_str()))
+                        use base64::{Engine as _, prelude::BASE64_STANDARD};
+                        // Return bytes as base64 string, matching Lotus behavior
+                        Ok(serde_json::json!(BASE64_STANDARD.encode(bytes)))

293-356: Add a targeted test to assert EthAccount Constructor is registered when present.

You added EthAccount support, but the local test that checks “supported actors” doesn’t include EthAccount. To prevent regressions (e.g., missing registrations for some versions), add a conditional test that exercises the EthAccount Constructor only when the actor CID exists in the registry.

Add this test near the bottom of the test module:

#[test]
fn test_eth_account_constructor_registered_when_present() {
    if let Some(eth_cid) = get_real_actor_cid(BuiltinActor::EthAccount, V16) {
        // Constructor is method 1
        let result = deserialize_params(&eth_cid, 1, &[]);
        if let Err(e) = result {
            let msg = e.to_string();
            assert!(
                !msg.contains("No deserializer registered"),
                "EthAccount present in registry but Constructor not registered: {msg}"
            );
        }
    }
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 81115f8 and bef197d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • Cargo.toml (1 hunks)
  • src/rpc/registry/actors/eth_account.rs (1 hunks)
  • src/rpc/registry/actors/mod.rs (1 hunks)
  • src/rpc/registry/methods_reg.rs (2 hunks)
  • src/tool/subcommands/api_cmd/api_compare_tests.rs (1 hunks)
  • src/tool/subcommands/api_cmd/test_snapshots.txt (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/tool/subcommands/api_cmd/api_compare_tests.rs (2)
src/shim/address.rs (1)
  • new_delegated (158-160)
src/blocks/tipset.rs (2)
  • key (336-339)
  • key (530-533)
src/rpc/registry/actors/eth_account.rs (1)
src/rpc/registry/actors/account.rs (1)
  • register_account_actor_methods (46-60)
src/rpc/registry/methods_reg.rs (1)
src/rpc/registry/actors/eth_account.rs (1)
  • register_actor_methods (17-28)
⏰ 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: cargo-publish-dry-run
  • GitHub Check: Build MacOS
  • GitHub Check: Build Ubuntu
  • GitHub Check: All lint checks
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: tests
  • GitHub Check: tests-release
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (rust)
🔇 Additional comments (4)
Cargo.toml (1)

75-75: Dependency added for fil_actor_ethaccount_state v22.4 — consistent with the actors set

Version aligns with the rest of the actors crates (22.4). No feature flags required for this use. LGTM.

src/rpc/registry/actors/mod.rs (1)

7-7: Expose eth_account module in the registry

Module wiring looks correct and consistent with the surrounding modules.

src/rpc/registry/methods_reg.rs (2)

77-79: EthAccount module import is correctly wired into the registry.

Bringing eth_account into scope alongside the existing actor modules is the right hook for method registration.


100-101: Match arm for EthAccount registration looks correct.

Delegating to eth_account::register_actor_methods(self, cid, version) mirrors the pattern used by other actors and enables version-aware registration through the new module.

filecoin_verified_reg_statedecodeparams_1754401651147091.rpcsnap.json.zst
filecoin_verified_reg_statedecodeparams_1754401651147157.rpcsnap.json.zst
filecoin_verified_reg_statedecodeparams_1754401651147231.rpcsnap.json.zst
filecoin_ethaccount_statedecodeparams_1756186350854913.rpcsnap.json.zst
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.

💡 Verification agent

❓ Verification inconclusive

Add EthAccount state_decodeparams snapshot — looks good

The new snapshot file entry is correctly appended next to other state_decodeparams snapshots and before statereplay. No issues spotted.

If helpful, verify that the referenced snapshot file exists in the repo:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
fd -a --exact-depth 1 'filecoin_ethaccount_statedecodeparams_*.rpcsnap.json.zst' src/tool/subcommands/api_cmd

Length of output: 131


🏁 Script executed:

#!/bin/bash
set -euo pipefail
# Search the entire repository for the new EthAccount state_decodeparams snapshot file
fd --type f 'filecoin_ethaccount_statedecodeparams_.*\.rpcsnap\.json\.zst'

Length of output: 96


Missing Snapshot File Reference
The test snapshot list references filecoin_ethaccount_statedecodeparams_1756186350854913.rpcsnap.json.zst, but I was unable to locate this file anywhere in the repository. Please ensure that the new snapshot file is added under src/tool/subcommands/api_cmd/ (or the appropriate snapshots directory) before approving this change.

• Affected location:

  • src/tool/subcommands/api_cmd/test_snapshots.txt (line 204)

Action required:

  • Add the actual filecoin_ethaccount_statedecodeparams_1756186350854913.rpcsnap.json.zst snapshot file to the repository so that the test can locate it.
  • Re-run the snapshot discovery (e.g., fd -a --exact-depth 1 'filecoin_ethaccount_statedecodeparams_*.rpcsnap.json.zst' src/tool/subcommands/api_cmd) to confirm its presence before merging.
🤖 Prompt for AI Agents
In src/tool/subcommands/api_cmd/test_snapshots.txt around line 204, the snapshot
list references
filecoin_ethaccount_statedecodeparams_1756186350854913.rpcsnap.json.zst which is
missing from the repo; add the actual snapshot file under
src/tool/subcommands/api_cmd/ (or the designated snapshots directory) with that
exact filename, commit it, and re-run snapshot discovery (e.g., fd -a
--exact-depth 1 'filecoin_ethaccount_statedecodeparams_*.rpcsnap.json.zst'
src/tool/subcommands/api_cmd) to verify the file is present before merging.

@elmattic
Copy link
Copy Markdown
Contributor

No green checkmark, no review!

Comment thread Cargo.toml
fil_actor_cron_state = { version = "23" }
fil_actor_datacap_state = { version = "23" }
fil_actor_eam_state = { version = "23" }
fil_actor_ethaccount_state = { version = "23" }
Copy link
Copy Markdown
Contributor

@hanabi1224 hanabi1224 Sep 2, 2025

Choose a reason for hiding this comment

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

Could you create an issue to track updating https://github.com/ChainSafe/fil-actor-states/blob/main/Makefile#L55 in fil-actor-states for fil_actor_ethaccount_state crate?

@akaladarshi akaladarshi added this pull request to the merge queue Sep 2, 2025
Merged via the queue into main with commit c74cfdf Sep 2, 2025
44 checks passed
@akaladarshi akaladarshi deleted the akaladarshi/add-eth-account-state-decode-params branch September 2, 2025 14:12
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.

Add support for the EthAccount Actor state in Filecoin.StateDecodeParams API

4 participants