Skip to content

Conversation

@akaladarshi
Copy link
Collaborator

@akaladarshi akaladarshi commented Aug 1, 2025

Summary of changes

Changes introduced in this pull request:

  • Adds support for reward actor methods in StateDecodeParams

Reference issue to close (if applicable)

Closes #5719

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 support for Reward actor methods, including parameter serialization and deserialization, across multiple actor versions.
    • Introduced registration and handling for Reward actor methods in the RPC method registry.
  • Tests
    • Added new test cases and snapshots to verify decoding of Reward actor method parameters via the API.
  • Chores
    • Extended internal modules and registry to support the new Reward actor functionality.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 1, 2025

Walkthrough

Support for the Reward actor has been added to the Filecoin.StateDecodeParams API, including serialization/deserialization logic, method registration for all actor versions (8–16), and new tests to validate parameter decoding. Macros and new modules were introduced to streamline trait implementations and registry integration.

Changes

Cohort / File(s) Change Summary
Reward Actor Method Serialization
src/lotus_json/actor_states/methods/reward_methods.rs, src/lotus_json/actor_states/methods/mod.rs
Added a new module and structs for Lotus JSON (de)serialization of Reward actor method parameters; implemented HasLotusJson for all supported actor versions using macros.
BigInt Wrapper Trait Implementations
src/lotus_json/big_int.rs
Introduced a macro to implement HasLotusJson for multiple BigIntDe wrapper types across FVM versions.
Reward Actor Method Registration
src/rpc/registry/actors/reward.rs, src/rpc/registry/actors/mod.rs, src/rpc/registry/methods_reg.rs
Added a new module and macros to register Reward actor methods for versions 8–16; integrated registration into the actor registry and main method registration logic.
API Decode Parameter Tests
src/tool/subcommands/api_cmd/api_compare_tests.rs, src/tool/subcommands/api_cmd/test_snapshots.txt
Added new test cases and snapshots for Reward actor parameter decoding in the API test suite.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant Registry
    participant RewardActor

    Client->>API: StateDecodeParams (Reward, MethodNum, Params)
    API->>Registry: Lookup RewardActor method/version
    Registry->>RewardActor: Deserialize Params via HasLotusJson
    RewardActor-->>Registry: Decoded Params
    Registry-->>API: Decoded Params
    API-->>Client: Decoded Params Result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
Add support for the Reward actor state in Filecoin.StateDecodeParams API (all versions: V8–V16) (#5719)
API compatibility for Reward actor method parameter decoding (#5719)
Test coverage for Reward actor parameter decoding (#5719)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Suggested labels

RPC

Suggested reviewers

  • hanabi1224
  • sudo-shashank
  • LesnyRumcajs

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 f413489 and c945d8a.

📒 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 (3 hunks)
  • src/tool/subcommands/api_cmd/test_snapshots.txt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/lotus_json/actor_states/methods/mod.rs
  • src/tool/subcommands/api_cmd/test_snapshots.txt
  • src/rpc/registry/methods_reg.rs
  • src/rpc/registry/actors/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: Build forest binaries on Linux AMD64
  • GitHub Check: tests-release
  • GitHub Check: Build Ubuntu
  • GitHub Check: All lint checks
  • GitHub Check: tests
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: Build MacOS
  • 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 akaladarshi/add-reward-actor-decod-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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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 force-pushed the akaladarshi/add-reward-actor-decod-params branch from c13302a to 4c1c7bb Compare August 1, 2025 14:56
@akaladarshi akaladarshi marked this pull request as ready for review August 1, 2025 15:04
@akaladarshi akaladarshi requested a review from a team as a code owner August 1, 2025 15:04
@akaladarshi akaladarshi requested review from hanabi1224 and sudo-shashank and removed request for a team August 1, 2025 15:04
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

🧹 Nitpick comments (1)
src/rpc/registry/actors/reward.rs (1)

30-45: Consider renaming the macro for clarity.

The macro name register_reward_version_8_to_9 is misleading since it's also used for version 10 (line 56). Consider renaming it to register_reward_version_8_to_10 to better reflect its usage.

-macro_rules! register_reward_version_8_to_9 {
+macro_rules! register_reward_version_8_to_10 {

Also update the usage sites accordingly.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f61b814 and 4c1c7bb.

📒 Files selected for processing (8)
  • src/lotus_json/actor_states/methods/mod.rs (1 hunks)
  • src/lotus_json/actor_states/methods/reward_methods.rs (1 hunks)
  • src/lotus_json/big_int.rs (1 hunks)
  • src/rpc/registry/actors/mod.rs (1 hunks)
  • src/rpc/registry/actors/reward.rs (1 hunks)
  • src/rpc/registry/methods_reg.rs (2 hunks)
  • src/tool/subcommands/api_cmd/api_compare_tests.rs (3 hunks)
  • src/tool/subcommands/api_cmd/test_snapshots.txt (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). (18)
  • GitHub Check: tests
  • GitHub Check: tests-release
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: Devnet checks
  • GitHub Check: Snapshot export checks
  • GitHub Check: Calibnet kademlia checks
  • GitHub Check: Bootstrap checks - Forest
  • GitHub Check: Bootstrap checks - Lotus
  • GitHub Check: Calibnet eth mapping check
  • GitHub Check: Calibnet no discovery checks
  • GitHub Check: db-migration-checks
  • GitHub Check: Wallet tests
  • GitHub Check: State migrations
  • GitHub Check: Calibnet check
  • GitHub Check: Forest CLI checks
  • GitHub Check: Calibnet stateless mode check
  • GitHub Check: Analyze (rust)
  • GitHub Check: Analyze (go)
🔇 Additional comments (14)
src/lotus_json/big_int.rs (1)

33-61: LGTM! Well-structured macro for DRY implementation.

The macro effectively generates consistent HasLotusJson implementations across multiple BigIntDe wrapper types from different fvm_shared versions. The implementation correctly delegates to the inner BigInt field and maintains consistency with the base BigInt implementation pattern.

src/tool/subcommands/api_cmd/test_snapshots.txt (1)

137-139: LGTM! New test snapshots for reward actor methods.

The snapshot files follow the established naming convention and support the new reward actor method parameter decoding tests mentioned in the PR objectives.

src/lotus_json/actor_states/methods/mod.rs (1)

12-12: LGTM! Proper module integration.

The module declaration follows the established pattern and correctly integrates the new reward methods functionality.

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

8-8: LGTM! Consistent actor module declaration.

The module declaration follows the established pattern and correctly integrates the reward actor into the registry system.

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

77-77: LGTM! Proper import addition.

The reward module is correctly added to the import statement, following the established pattern.


86-86: LGTM! Version-aware reward actor registration.

The reward actor case is properly integrated into the match statement. The inclusion of the _version parameter is appropriate given the PR objective to support reward actor versions 8-16, making this implementation version-aware unlike other actors.

src/rpc/registry/actors/reward.rs (2)

1-28: LGTM!

The imports are appropriate and the macro implementation for versions 11-16 correctly handles method registration with proper parameter types. The separation of parameterized and parameterless methods is well-structured.


47-66: LGTM!

The main registration function correctly handles all required reward actor versions (8-16) as specified in the PR objectives. The version-based dispatch to appropriate macros is well-structured and the default case appropriately handles unsupported versions.

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

55-55: LGTM!

The num_bigint::BigInt import is necessary for the new reward actor parameter definitions and follows the established import patterns.


1920-1937: LGTM!

The new reward actor test cases follow the established patterns and correctly use the reward actor methods and address. The test structure will properly validate parameter decoding for reward actor versions.

src/lotus_json/actor_states/methods/reward_methods.rs (4)

1-41: LGTM!

The JSON wrapper structs are well-designed with proper Serde annotations. The use of #[serde(transparent)] for simple wrappers and #[serde(rename_all = "PascalCase")] for structured data follows Lotus JSON conventions correctly.


44-82: LGTM!

The macro implementation for constructor parameters is well-structured with proper version handling, comprehensive test snapshots, and correct type conversions between BigIntDe wrappers and BigInt types.


85-133: LGTM!

The award block reward parameters macro is correctly implemented with realistic test data and proper field-by-field conversions between native types and their JSON representations.


136-181: LGTM!

The update network KPI parameters macro maintains consistency with the constructor parameters approach. The macro invocations correctly map versions to their corresponding fvm_shared types, with appropriate version ranges for each parameter type based on when features were introduced or structure changes occurred.

@akaladarshi akaladarshi added the RPC requires calibnet RPC checks to run on CI label Aug 1, 2025
@akaladarshi akaladarshi enabled auto-merge August 1, 2025 17:11
@akaladarshi akaladarshi changed the title feat: add support for reward actor in state decode params API [skip ci] feat: add support for reward actor in state decode params API Aug 3, 2025
@akaladarshi akaladarshi added this pull request to the merge queue Aug 4, 2025
Merged via the queue into main with commit baf74e6 Aug 4, 2025
42 checks passed
@akaladarshi akaladarshi deleted the akaladarshi/add-reward-actor-decod-params branch August 4, 2025 12:15
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 Reward actor state in Filecoin.StateDecodeParams API

4 participants