Skip to content

Add support for cron actor in StateDecodeParams API#5804

Merged
elmattic merged 23 commits intomainfrom
shashank/cron-state-decode-params
Aug 14, 2025
Merged

Add support for cron actor in StateDecodeParams API#5804
elmattic merged 23 commits intomainfrom
shashank/cron-state-decode-params

Conversation

@sudo-shashank
Copy link
Copy Markdown
Contributor

@sudo-shashank sudo-shashank commented Jul 3, 2025

Summary of changes

Changes introduced in this pull request:

  • Adds support for the cron actor in Filecoin.StateDecodeParams API.

Reference issue to close (if applicable)

Closes #5725

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 Cron actor support in the API, including constructor and EpochTick method registration across versions.
    • Added cross-version Lotus JSON support for Cron constructor parameters (v8–v16) with round-trip encode/decode.
  • Tests
    • Added API comparison tests and a snapshot for Cron EpochTick; constructor test scaffolding prepared.
  • Chores
    • Upgraded Filecoin actor state dependencies to version 22.4.

@sudo-shashank
Copy link
Copy Markdown
Contributor Author

No parity test yet for this as lotus is missing support for cron actor ConstructorParams, I have raised this to them and an issue has been opened to track this impl filecoin-project/go-state-types#396

@sudo-shashank sudo-shashank force-pushed the shashank/cron-state-decode-params branch from a5c7ce3 to 631ce0b Compare August 6, 2025 06:46
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 6, 2025

Walkthrough

Adds Cron actor support across versions v8–v16: bumps fil_actor_* and fil_actors_shared dependencies to 22.4, introduces Lotus JSON constructor params for Cron, registers Cron actor methods (Constructor, EpochTick) in the RPC method registry, wires actor dispatch, and adds corresponding API tests and a snapshot.

Changes

Cohort / File(s) Summary
Dependencies
Cargo.toml
Bump fil_actor_*_state and fil_actors_shared from 22.2 → 22.4; preserve fil_actors_shared json feature.
Lotus JSON: Cron constructor params
src/lotus_json/actor_states/methods/cron_actor_params.rs, src/lotus_json/actor_states/methods/mod.rs
Add CronConstructorParamsLotusJson type and HasLotusJson impls for cron ConstructorParams v8–v16; export new cron_actor_params module.
RPC actor: Cron registration
src/rpc/registry/actors/cron.rs, src/rpc/registry/actors/mod.rs
New cron module; macro registers Constructor (with params) and EpochTick (empty) for versions v8–v16; export module from actors mod.
Method registry wiring
src/rpc/registry/methods_reg.rs
Import and register Cron in method registry dispatch for BuiltinActor::Cron; update tests to include Cron.
API tests and snapshots
src/tool/subcommands/api_cmd/api_compare_tests.rs, src/tool/subcommands/api_cmd/test_snapshots.txt
Add Cron EpochTick state-decode test insertion points (Constructor placeholders commented) and add corresponding snapshot file entry.

Sequence Diagram(s)

sequenceDiagram
  participant Init as Init Code
  participant Registry as MethodRegistry
  participant CronMod as cron module

  Init->>Registry: create registry
  Registry->>CronMod: register_actor_methods(cid, version)
  CronMod-->>Registry: register Constructor(params v8–v16)
  CronMod-->>Registry: register EpochTick(empty)
  Registry-->>Init: registry populated
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Add support for Cron actor in Filecoin.StateDecodeParams API across v8–v16 (#5725)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Dependency version bumps for multiple fil_actor_*_state crates and fil_actors_shared (Cargo.toml) Version bumps are broader repository changes not explicitly requested by #5725; likely to support newer actor versions but not part of the stated API-only objective.

Possibly related PRs

Suggested reviewers

  • akaladarshi
  • LesnyRumcajs

📜 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 10bd13f and b289ad5.

📒 Files selected for processing (5)
  • src/lotus_json/actor_states/methods/mod.rs (1 hunks)
  • src/rpc/registry/actors/mod.rs (1 hunks)
  • src/rpc/registry/methods_reg.rs (3 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 (5)
  • src/tool/subcommands/api_cmd/test_snapshots.txt
  • src/rpc/registry/methods_reg.rs
  • src/rpc/registry/actors/mod.rs
  • src/lotus_json/actor_states/methods/mod.rs
  • src/tool/subcommands/api_cmd/api_compare_tests.rs
⏰ 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: Build forest binaries on Linux AMD64
  • GitHub Check: All lint checks
  • GitHub Check: tests-release
  • GitHub Check: tests
  • GitHub Check: Analyze (rust)
  • GitHub Check: Analyze (go)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch shashank/cron-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 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.

@sudo-shashank sudo-shashank force-pushed the shashank/cron-state-decode-params branch from 631ce0b to 5faf793 Compare August 6, 2025 12:35
@sudo-shashank sudo-shashank added the RPC requires calibnet RPC checks to run on CI label Aug 6, 2025
@sudo-shashank sudo-shashank marked this pull request as ready for review August 7, 2025 07:01
@sudo-shashank sudo-shashank requested a review from a team as a code owner August 7, 2025 07:01
@sudo-shashank sudo-shashank requested review from akaladarshi and elmattic and removed request for a team August 7, 2025 07:01
@akaladarshi
Copy link
Copy Markdown
Collaborator

@sudo-shashank CI is failing

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

🧹 Nitpick comments (3)
src/rpc/registry/methods_reg.rs (1)

256-263: Add Cron to unit test coverage for registered methods

To exercise the new Cron registration path and prevent regressions, include Cron in test_supported_actor_methods_registered()’s supported actors.

Apply this diff:

-        let supported_actors = vec![
-            BuiltinActor::Account,
-            BuiltinActor::Miner,
-            BuiltinActor::EVM,
-        ];
+        let supported_actors = vec![
+            BuiltinActor::Account,
+            BuiltinActor::Miner,
+            BuiltinActor::EVM,
+            BuiltinActor::Cron,
+        ];
src/tool/subcommands/api_cmd/api_compare_tests.rs (2)

1900-1908: Prefer keeping Cron constructor test compiled but ignored (to avoid bit-rot)

Instead of commenting out the Cron constructor params and test, define them and add the test with .ignore("blocked by go-state-types #396"). This keeps types exercised by CI and eases future enablement.

Apply this diff:

-    // TODO(go-state-types): https://github.com/filecoin-project/go-state-types/issues/396
-    // Enable this test when lotus supports it in go-state-types.
-    // let cron_constructor_params = fil_actor_cron_state::v16::ConstructorParams {
-    //     entries: vec![fil_actor_cron_state::v16::Entry {
-    //         receiver: Address::new_id(1000).into(),
-    //         method_num: fil_actor_cron_state::v16::Method::EpochTick as u64,
-    //     }],
-    // };
+    // TODO(go-state-types): https://github.com/filecoin-project/go-state-types/issues/396
+    // Keep compiled but ignored so CI catches type drift; un-ignore when Lotus supports it.
+    let cron_constructor_params = fil_actor_cron_state::v16::ConstructorParams {
+        entries: vec![fil_actor_cron_state::v16::Entry {
+            receiver: Address::new_id(1000).into(),
+            method_num: fil_actor_cron_state::v16::Method::EpochTick as u64,
+        }],
+    };

And add the ignored test in the list below (see next suggestion).


2030-2043: Cron EpochTick test addition looks good; also add ignored constructor test

EpochTick is an empty-params method; the identity test is appropriate. Additionally, include an ignored constructor test to be enabled once Lotus parity lands.

Apply this diff to insert the ignored constructor test next to EpochTick:

-        // TODO(go-state-types): https://github.com/filecoin-project/go-state-types/issues/396
-        // Enable this test when lotus supports it in go-state-types.
-        // RpcTest::identity(StateDecodeParams::request((
-        //     Address::CRON_ACTOR,
-        //     fil_actor_cron_state::v16::Method::Constructor as u64,
-        //     to_vec(&cron_constructor_params)?,
-        //     tipset.key().into(),
-        // ))?),
+        // Keep this compiled but ignored until Lotus supports Cron Constructor params.
+        RpcTest::identity(StateDecodeParams::request((
+            Address::CRON_ACTOR,
+            fil_actor_cron_state::v16::Method::Constructor as u64,
+            to_vec(&cron_constructor_params)?,
+            tipset.key().into(),
+        ))?)
+        .ignore("Blocked by go-state-types: https://github.com/filecoin-project/go-state-types/issues/396"),
         RpcTest::identity(StateDecodeParams::request((
             Address::CRON_ACTOR,
             fil_actor_cron_state::v16::Method::EpochTick as u64,
             vec![],
             tipset.key().into(),
         ))?),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8738bbf and 2f24606.

📒 Files selected for processing (5)
  • src/lotus_json/actor_states/methods/mod.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 (2 hunks)
  • src/tool/subcommands/api_cmd/test_snapshots.txt (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/tool/subcommands/api_cmd/test_snapshots.txt
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/rpc/registry/actors/mod.rs
  • src/lotus_json/actor_states/methods/mod.rs
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/rpc/registry/methods_reg.rs (2)
src/rpc/registry/actors/cron.rs (1)
  • register_actor_methods (24-37)
src/rpc/registry/actors/system.rs (1)
  • register_actor_methods (22-35)
⏰ 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 forest binaries on Linux AMD64
  • GitHub Check: tests
  • GitHub Check: Build Ubuntu
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: tests-release
  • GitHub Check: All lint checks
  • GitHub Check: Build MacOS
  • GitHub Check: Analyze (rust)
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
src/rpc/registry/methods_reg.rs (2)

77-78: Cron actor module import looks correct

Importing cron alongside existing actor modules is appropriate and consistent with the module structure.


91-92: Registering Cron methods in the actor dispatch is correct

Dispatching BuiltinActor::Cron to cron::register_actor_methods(self, cid, version) aligns with other actors and enables versioned registration for v8–v16.

Copy link
Copy Markdown
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.

@sudo-shashank rename the file cron_construtor_params -> cron_actor_params or cron_actor.

We are planning to keep a single file for all the params of a particular actor.

Edit: lets go with the cron_actor_params.rs, will refactor in other places as well in later PR's

Comment thread src/lotus_json/actor_states/methods/cron_constructor_params.rs Outdated
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 (2)
src/lotus_json/actor_states/methods/cron_actor_params.rs (2)

62-75: Cross-version fallback is pragmatic; consider documenting field-loss semantics

When encountering a mismatched Entry variant, you normalize via entry.into_lotus_json() and reconstruct the v$version type. If a future actor version adds fields to Entry, those will be dropped during this fallback. Today (v8–v16) the shape is stable, so this is fine.

Add a short comment to clarify this intentional lossy conversion for future readers.

                         Self {
                             entries: json.entries.into_iter().map(|entry| match entry {
                                 Entry::[<V $version>](e) => e,
                                 _ => {
+                                    // Note: Fallback normalizes via Lotus JSON; if newer versions add fields,
+                                    // they may be dropped here when constructing v$version::Entry.
                                     let lotus_entry = entry.into_lotus_json();
                                     fil_actor_cron_state::[<v $version>]::Entry {
                                         receiver: lotus_entry.receiver.into(),
                                         method_num: lotus_entry.method_num,
                                     }
                                 }
                             }).collect(),
                         }

12-16: Optional: be strict about unknown fields in JSON

If you want to harden decoding, add deny_unknown_fields to fail fast on unexpected JSON keys. This mirrors patterns used elsewhere when strict Lotus compatibility is desired.

 #[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)]
-#[serde(rename_all = "PascalCase")]
+#[serde(rename_all = "PascalCase", deny_unknown_fields)]
 pub struct CronConstructorParamsLotusJson {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18e8edf and 10bd13f.

📒 Files selected for processing (2)
  • src/lotus_json/actor_states/methods/cron_actor_params.rs (1 hunks)
  • src/lotus_json/actor_states/methods/mod.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lotus_json/actor_states/methods/mod.rs
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/lotus_json/actor_states/methods/cron_actor_params.rs (1)
src/shim/address.rs (1)
  • new_id (142-144)
⏰ 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: tests
  • GitHub Check: All lint checks
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (rust)
🔇 Additional comments (3)
src/lotus_json/actor_states/methods/cron_actor_params.rs (3)

10-16: Serde/schemars wiring looks correct for Lotus JSON shape

Using PascalCase with a custom serde module for Vec<Entry> aligns with existing lotus_json patterns in this codebase. The schema indirection via LotusJson<Vec<Entry>> is also consistent.


56-61: Version-tagging entries on encode is correct and efficient

Wrapping versioned entries with the Entry::V$version variant during into_lotus_json is the right approach for round-trippable, version-aware JSON.


82-82: Coverage for v8–v16 looks complete

The macro invocation registers all required versions per the issue checklist.

Comment thread src/lotus_json/actor_states/methods/cron_actor_params.rs
akaladarshi
akaladarshi previously approved these changes Aug 13, 2025
use super::*;
mod account_authenticate_params;
mod account_constructor_params;
mod cron_actor_params;
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.

We should determine a unique naming convention for our modules:
Right now we have 3:

- <actor-name>_<method>_params
- <actor-name>_actor
- <actor-name>_methods

At least let not invent a forth one. (<actor-name>_actor_params)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@elmattic we choose <actor-name>_actor_params as suggested by @akaladarshi #5804 (review)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@elmattic all the common actor methods will be moved to a single file, earlier all of them were separated, hence the discrepancies.

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.

Sounds good.

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.

@akaladarshi Do we have an issue to track this refactor?

14 => register_cron_version!(registry, cid, fil_actor_cron_state::v14),
15 => register_cron_version!(registry, cid, fil_actor_cron_state::v15),
16 => register_cron_version!(registry, cid, fil_actor_cron_state::v16),
_ => {}
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.

What about version 17?

Copy link
Copy Markdown
Contributor Author

@sudo-shashank sudo-shashank Aug 14, 2025

Choose a reason for hiding this comment

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

latest available is V16

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.

I mean, should we trigger an error instead of performing a no-op?

Copy link
Copy Markdown
Contributor Author

@sudo-shashank sudo-shashank Aug 14, 2025

Choose a reason for hiding this comment

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

@elmattic we should actually match against enum variants and not integer value directly
@akaladarshi has planned to fix this issue in a separate PR #5896 (comment)

Copy link
Copy Markdown
Contributor Author

@sudo-shashank sudo-shashank Aug 14, 2025

Choose a reason for hiding this comment

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

@akaladarshi do we have an issue raised to track these improvements?

@sudo-shashank sudo-shashank requested a review from elmattic August 14, 2025 09:14
@elmattic elmattic added this pull request to the merge queue Aug 14, 2025
Merged via the queue into main with commit e0c3bf9 Aug 14, 2025
43 checks passed
@elmattic elmattic deleted the shashank/cron-state-decode-params branch August 14, 2025 10:15
@coderabbitai coderabbitai Bot mentioned this pull request Apr 8, 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.

Add support for the Cron actor state in Filecoin.StateDecodeParams API

3 participants