Skip to content

Conversation

@elmattic
Copy link
Contributor

@elmattic elmattic commented Aug 13, 2025

Summary of changes

Changes introduced in this pull request:

  • Add StateDecodeParams tests for market actor
File Name Method Name Method Number
filecoin_market_constructor_statedecodeparams_1757426002270973.rpcsnap.json.zst Constructor 1
filecoin_market_addbalance_statedecodeparams_1757426002278914.rpcsnap.json.zst AddBalance 2
filecoin_market_withdrawbalance_statedecodeparams_1757426002298895.rpcsnap.json.zst WithdrawBalance 3
filecoin_market_publishstoragedeals_statedecodeparams_1757426002306931.rpcsnap.json.zst PublishStorageDeals 4
filecoin_market_crontick_statedecodeparams_1757426002327008.rpcsnap.json.zst CronTick 9
filecoin_market_addbalanceexported_statedecodeparams_1757426002338931.rpcsnap.json.zst AddBalanceExported 822473126
filecoin_market_withdrawbalanceexported_statedecodeparams_1757426002346995.rpcsnap.json.zst WithdrawBalanceExported 2280458852
filecoin_market_publishstoragedealsexported_statedecodeparams_1757426002358906.rpcsnap.json.zst PublishStorageDealsExported 2236929350
filecoin_market_getbalanceexported_statedecodeparams_1757426002362902.rpcsnap.json.zst GetBalanceExported 726108461
filecoin_market_getdealdatacommitmentexported_statedecodeparams_1757426002363106.rpcsnap.json.zst GetDealDataCommitmentExported 1157985802
filecoin_market_getdealclientexported_statedecodeparams_1757426002366899.rpcsnap.json.zst GetDealClientExported 128053329
filecoin_market_getdealproviderexported_statedecodeparams_1757426002375082.rpcsnap.json.zst GetDealProviderExported 935081690
filecoin_market_getdeallabelexported_statedecodeparams_1757426002382966.rpcsnap.json.zst GetDealLabelExported 46363526
filecoin_market_getdealtermexported_statedecodeparams_1757426002394955.rpcsnap.json.zst GetDealTermExported 163777312
filecoin_market_getdealtotalpriceexported_statedecodeparams_1757426002399187.rpcsnap.json.zst GetDealTotalPriceExported 4287162428
filecoin_market_getdealclientcollateralexported_statedecodeparams_1757426002407069.rpcsnap.json.zst GetDealClientCollateralExported 200567895
filecoin_market_getdealprovidercollateralexported_statedecodeparams_1757426002415167.rpcsnap.json.zst GetDealProviderCollateralExported 2986712137
filecoin_market_getdealverifiedexported_statedecodeparams_1757426002419004.rpcsnap.json.zst GetDealVerifiedExported 2627389465
filecoin_market_getdealactivationexported_statedecodeparams_1757426002422988.rpcsnap.json.zst GetDealActivationExported 2567238399
filecoin_market_getdealsectorexported_statedecodeparams_1757426002423094.rpcsnap.json.zst GetDealSectorExported 2611213344
filecoin_market_settledealpaymentsexported_statedecodeparams_1757426002430957.rpcsnap.json.zst SettleDealPaymentsExported 1900091594

Reference issue to close (if applicable)

Closes: #5723

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

    • Multi-version RPC support for the Market actor (v8–v17): balance ops, deal publishing, deal queries, activations, settlements, sector/content updates.
    • Expanded Lotus-JSON serialization for market parameters: deal proposals, per-version client wrappers, sector/data specs, piece/sector change payloads.
    • JSON wrapper for padded piece size and an invalid RegisteredSealProof helper.
  • Tests

    • Added snapshot test macro, expanded decode-params tests and many market-related test snapshots for cross-version verification.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 13, 2025

Walkthrough

Adds Lotus JSON (de)serialization types for Market actor params (v8–v17), a PaddedPieceSize JSON wrapper and test macro, registers Market actor RPC methods across versions, extends API decode-params tests and snapshots for Market methods, and adds a RegisteredSealProof::invalid() shim constructor.

Changes

Cohort / File(s) Summary
Lotus JSON: Market actor params
src/lotus_json/actor_states/methods/market_actor_params.rs
New public LotusJson structs/enums and HasLotusJson impls for Market actor parameters across v8–v17: balance ops, DealProposal, per-version ClientDealProposalV2/V3/V4, per-version PublishStorageDealsParams wrappers, SectorDeals/SectorDataSpec, ComputeDataCommitment/VerifyDealsForActivation/Activate/BatchActivate/OnMinerSectorsTerminate variants, DealQuery/SettleDealPayments, PieceChange/SectorChanges/SectorContentChanged, plus test snapshot hooks.
Lotus JSON: module wiring & test macro
src/lotus_json/actor_states/methods/mod.rs, src/lotus_json/mod.rs
Adds private module market_actor_params; adds padded_piece_size module; exports test_snapshots! macro for generating cross-version snapshot tests.
Lotus JSON: PaddedPieceSize wrapper
src/lotus_json/padded_piece_size.rs
Adds PaddedPieceSizeLotusJson, HasLotusJson impl for PaddedPieceSize, and test snapshots stub.
RPC registry: Market actor
src/rpc/registry/actors/market.rs, src/rpc/registry/actors/mod.rs, src/rpc/registry/methods_reg.rs
New Market actor registry module with version-aware method registration macros and a dispatcher (register_actor_methods) for versions 8–17; integrates Market into the global method registry.
Shim additions
src/shim/sector.rs
Adds pub fn invalid() -> RegisteredSealProof.
Tests and snapshots
src/tool/subcommands/api_cmd/api_compare_tests.rs, src/tool/subcommands/api_cmd/test_snapshots.txt
Adds Market-focused state-decode parameter tests and 21 market-related snapshot entries; introduces test helpers and payload examples exercising many Market methods.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as Client
  participant RPC as RPC Layer
  participant MR as MethodRegistry
  participant Reg as Market Registry
  participant LJ as LotusJson Conversions
  participant State as Versioned State (v8–v17)

  Client->>RPC: send method request (cid, version, params JSON)
  RPC->>MR: dispatch(cid, version, method)
  MR->>Reg: route to market.register_actor_methods
  Reg->>LJ: JSON -> versioned params (v8..v17)
  LJ-->>Reg: typed params
  Reg->>State: invoke versioned handler with params
  State-->>Reg: typed result
  Reg->>LJ: result -> JSON
  LJ-->>Reg: JSON result
  Reg-->>MR: return response
  MR-->>RPC: forward response
  RPC-->>Client: JSON response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60–90 minutes

Possibly related PRs

Suggested reviewers

  • sudo-shashank
  • LesnyRumcajs

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly describes the primary change of enabling support for the market actor within the StateDecodeParams API, accurately reflecting the main purpose of the pull request in a concise and specific manner.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch elmattic/market-decode-params

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

@akaladarshi akaladarshi added the RPC requires calibnet RPC checks to run on CI label Sep 9, 2025
@akaladarshi akaladarshi marked this pull request as draft September 9, 2025 13:41
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: 4

🧹 Nitpick comments (15)
src/shim/sector.rs (1)

138-142: Make invalid() a const (and consider crate-private).

Const enables usage in statics and avoids runtime cost. If this is only for internals/tests, prefer pub(crate) to reduce accidental use.

-impl RegisteredSealProof {
-    pub fn invalid() -> Self {
-        RegisteredSealProof(RegisteredSealProofV4::Invalid(0))
-    }
-}
+impl RegisteredSealProof {
+    pub const fn invalid() -> Self {
+        RegisteredSealProof(RegisteredSealProofV4::Invalid(0))
+    }
+}
src/rpc/registry/methods_reg.rs (1)

97-97: Add Market to the supported-actors test to prevent regressions.

Extend the test matrix so we catch gaps if future refactors miss Market method registration.

         let supported_actors = vec![
             BuiltinActor::Account,
             BuiltinActor::Miner,
             BuiltinActor::EVM,
             BuiltinActor::Cron,
             BuiltinActor::DataCap,
+            BuiltinActor::Market,
         ];
src/lotus_json/padded_piece_size.rs (2)

7-10: Consider marking the wrapper as serde-transparent.

Add #[serde(transparent)] to guarantee newtype passthrough semantics and avoid any accidental nesting if serde derives change in the future.

-#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, JsonSchema)]
+#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, JsonSchema)]
+#[serde(transparent)]
 pub struct PaddedPieceSizeLotusJson(#[schemars(with = "u64")] PaddedPieceSize);

14-17: Add minimal snapshots to lock in JSON as a plain number.

Right now snapshots() returns an empty vec. Add at least one sample (e.g., 2048) to catch regressions in encoding/decoding.

     #[cfg(test)]
     fn snapshots() -> Vec<(serde_json::Value, Self)> {
-        vec![]
+        vec![
+            (json!(0u64), PaddedPieceSize(0)),
+            (json!(2048u64), PaddedPieceSize(2048)),
+        ]
     }
src/rpc/registry/actors/market.rs (1)

177-190: Dispatch covers v8–v16; consider logging for unknown versions.

Match arms look correct. Optionally log a trace on the default branch to aid debugging when encountering unexpected versions.

-        _ => {}
+        _ => {
+            tracing::trace!(version, "market: no methods registered for unknown actor version");
+        }
src/lotus_json/actor_states/methods/miner_actor_params.rs (2)

3713-3741: Optional: add snapshots for PieceChange to validate CID/size/payload.

Providing at least one non-empty example will guard against regressions in PaddedPieceSize mapping and RawBytes handling.

                     #[cfg(test)]
                     fn snapshots() -> Vec<(serde_json::Value, Self)> {
-                        vec![
-                        ]
+                        let cid = Cid::try_from("bafy2bzacedu6q2cpk2t7c6gk7m2wkfpfb4v6qzjvkg3gq6m7k6c3r5h7lxy").unwrap();
+                        vec![(
+                            json!({
+                                "Data": "bafy2bzacedu6q2cpk2t7c6gk7m2wkfpfb4v6qzjvkg3gq6m7k6c3r5h7lxy",
+                                "Size": 2048,
+                                "Payload": "AQID"
+                            }),
+                            Self {
+                                data: cid,
+                                size: fvm_shared4::piece::PaddedPieceSize(2048).into(),
+                                payload: RawBytes::new(vec![1,2,3]),
+                            },
+                        )]
                     }

3766-3790: Optional: add snapshots for SectorChanges/SectorContentChangedParams.

One end-to-end example (with a single added PieceChange) would exercise nested mappings and the new PaddedPieceSize LotusJson wrapper.

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

3432-3434: Rename misleading var: it’s used by both AddBalanceExported and GetBalanceExported.

market_actor_get_balance_exported_params holds a generic Address and is used for AddBalanceExported too. Rename to avoid confusion.

-    let market_actor_get_balance_exported_params = Address::new_id(1000);
+    let market_actor_address_param = Address::new_id(1000);
@@
-            to_vec(&market_actor_get_balance_exported_params)?,
+            to_vec(&market_actor_address_param)?,
@@
-            to_vec(&market_actor_get_balance_exported_params)?,
+            to_vec(&market_actor_address_param)?,

Also applies to: 3508-3512, 3526-3530


3330-3373: Minor: prefer u64 literals for atto amounts to avoid implicit narrowing.

TokenAmount::from_atto(10u8) works but reads odd. Use 10u64 for clarity/consistency across the file.


3471-3494: Document the TODOs with upstream issue links in code comments.

You already reference go-state-types issues—add a brief rationale inline so future readers know why tests are gated.

Also applies to: 3496-3506

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

76-88: Schema/serde consistency: payload uses RawBytes here (vs Vec in market).

Assuming miner PieceChange truly uses RawBytes (and market’s ext uses Vec), this divergence is correct. If intentional, consider a brief comment to prevent future “deduplicate” attempts.

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

674-689: Lotus field naming: DealIDs vs DealIds.

You’ve correctly used DealIDs here (and DealIds elsewhere where Lotus uses that spelling). Add a short comment noting Lotus’ inconsistency to avoid “fixing” it later.


1450-1454: BitField snapshot is inconsistent with constructed value.

Snapshot JSON shows [0] but the constructed BitField::new() is empty. Align them to avoid brittle tests.

-                                serde_json::json!([0]),
-                                Self { deal_ids: BitField::new() }
+                                serde_json::json!([]),
+                                Self { deal_ids: BitField::new() }

Or, if you want [0] in JSON, set the bit:

+                                let mut bf = BitField::new();
+                                bf.set(0);
-                                Self { deal_ids: BitField::new() }
+                                Self { deal_ids: bf }

Also applies to: 1463-1481


301-327: Signature type per version looks right; add a unit snapshot for BLS too.

You cover Secp256k1; consider adding a BLS snapshot to catch cross-version serde differences early.

Also applies to: 328-405


1300-1336: Nit: Consistent JSON keys for SectorDataSpec and ComputeDataCommitmentParams.

You intentionally use “DealIds” here (PascalCase) vs “DealIDs” elsewhere. Add inline comments to document Lotus API expectations to deter accidental renames.

Also applies to: 1354-1398

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e6145e and 0825c59.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • src/lotus_json/actor_states/methods/market_actor_params.rs (1 hunks)
  • src/lotus_json/actor_states/methods/miner_actor_params.rs (3 hunks)
  • src/lotus_json/actor_states/methods/miner_change_worker_params.rs (1 hunks)
  • src/lotus_json/actor_states/methods/mod.rs (1 hunks)
  • src/lotus_json/mod.rs (2 hunks)
  • src/lotus_json/padded_piece_size.rs (1 hunks)
  • src/rpc/registry/actors/market.rs (1 hunks)
  • src/rpc/registry/actors/mod.rs (1 hunks)
  • src/rpc/registry/methods_reg.rs (2 hunks)
  • src/shim/sector.rs (1 hunks)
  • src/tool/subcommands/api_cmd/api_compare_tests.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: akaladarshi
PR: ChainSafe/forest#5996
File: src/lotus_json/actor_states/methods/paych_params.rs:269-277
Timestamp: 2025-09-02T08:46:04.937Z
Learning: In payment channel actor Lotus JSON serialization, empty merges should be serialized as `null` (not an empty array `[]`) to maintain compatibility with Lotus behavior.
📚 Learning: 2025-08-18T12:25:29.183Z
Learnt from: akaladarshi
PR: ChainSafe/forest#5896
File: src/lotus_json/actor_states/methods/verified_reg_actor.rs:133-137
Timestamp: 2025-08-18T12:25:29.183Z
Learning: In Lotus JSON for verified registry actor, the SectorAllocationClaimsLotusJson struct uses "SectorExpiry" as the field name for the expiry field, not "Expiry". The current code with #[serde(rename = "SectorExpiry")] is correct.

Applied to files:

  • src/lotus_json/actor_states/methods/market_actor_params.rs
  • src/lotus_json/actor_states/methods/miner_change_worker_params.rs
  • src/lotus_json/actor_states/methods/miner_actor_params.rs
📚 Learning: 2025-09-02T10:05:34.350Z
Learnt from: akaladarshi
PR: ChainSafe/forest#5923
File: src/rpc/registry/actors/miner.rs:221-223
Timestamp: 2025-09-02T10:05:34.350Z
Learning: For miner actor ChangeOwnerAddress and ChangeOwnerAddressExported methods: versions 8-10 use bare Address as parameter type, while versions 11+ use ChangeOwnerAddressParams. This reflects the evolution of the Filecoin miner actor parameter structures across versions.

Applied to files:

  • src/lotus_json/actor_states/methods/miner_change_worker_params.rs
  • src/lotus_json/actor_states/methods/miner_actor_params.rs
📚 Learning: 2025-08-14T06:46:08.056Z
Learnt from: akaladarshi
PR: ChainSafe/forest#5923
File: src/rpc/registry/actors/miner.rs:0-0
Timestamp: 2025-08-14T06:46:08.056Z
Learning: ProveCommitSectors3 method is available in fil_actor_miner_state::v13 and should be mapped to ProveCommitSectors3Params, not ProveCommitSectorParams.

Applied to files:

  • src/lotus_json/actor_states/methods/miner_actor_params.rs
🧬 Code graph analysis (5)
src/rpc/registry/methods_reg.rs (1)
src/rpc/registry/actors/market.rs (1)
  • register_actor_methods (177-190)
src/lotus_json/padded_piece_size.rs (1)
src/lotus_json/mod.rs (17)
  • snapshots (147-147)
  • snapshots (566-568)
  • snapshots (580-582)
  • snapshots (597-599)
  • snapshots (621-623)
  • serde_json (301-301)
  • serde_json (325-325)
  • into_lotus_json (148-148)
  • into_lotus_json (569-571)
  • into_lotus_json (583-585)
  • into_lotus_json (600-606)
  • into_lotus_json (624-631)
  • from_lotus_json (149-149)
  • from_lotus_json (572-574)
  • from_lotus_json (586-591)
  • from_lotus_json (607-613)
  • from_lotus_json (632-639)
src/tool/subcommands/api_cmd/api_compare_tests.rs (4)
src/shim/address.rs (3)
  • default (122-124)
  • new_id (142-144)
  • new_bls (150-152)
src/shim/econ.rs (1)
  • from_atto (106-108)
src/shim/crypto.rs (1)
  • new_bls (77-82)
src/blocks/tipset.rs (4)
  • new (242-260)
  • new (494-511)
  • key (336-339)
  • key (530-533)
src/lotus_json/actor_states/methods/market_actor_params.rs (4)
src/shim/address.rs (1)
  • new_id (142-144)
src/lotus_json/mod.rs (17)
  • snapshots (147-147)
  • snapshots (566-568)
  • snapshots (580-582)
  • snapshots (597-599)
  • snapshots (621-623)
  • serde_json (301-301)
  • serde_json (325-325)
  • into_lotus_json (148-148)
  • into_lotus_json (569-571)
  • into_lotus_json (583-585)
  • into_lotus_json (600-606)
  • into_lotus_json (624-631)
  • from_lotus_json (149-149)
  • from_lotus_json (572-574)
  • from_lotus_json (586-591)
  • from_lotus_json (607-613)
  • from_lotus_json (632-639)
src/shim/econ.rs (1)
  • from_atto (106-108)
src/shim/sector.rs (13)
  • from (108-110)
  • from (191-197)
  • from (212-214)
  • from (255-257)
  • from (261-264)
  • from (268-271)
  • from (275-277)
  • from (281-284)
  • from (288-291)
  • from (379-384)
  • invalid (139-141)
  • new (170-180)
  • new (362-367)
src/lotus_json/mod.rs (11)
src/rpc/methods/chain.rs (1)
  • assert_all_snapshots (1101-1101)
src/blocks/tipset.rs (1)
  • assert_all_snapshots (689-689)
src/lotus_json/ipld.rs (1)
  • assert_all_snapshots (274-274)
src/lotus_json/allocation.rs (1)
  • assert_all_snapshots (87-87)
src/lotus_json/bit_field.rs (1)
  • assert_all_snapshots (41-41)
src/lotus_json/miner_info.rs (1)
  • assert_all_snapshots (158-158)
src/lotus_json/receipt.rs (1)
  • assert_all_snapshots (90-90)
src/lotus_json/power_claim.rs (1)
  • assert_all_snapshots (55-55)
src/lotus_json/beneficiary_term.rs (1)
  • assert_all_snapshots (58-58)
src/lotus_json/pending_beneficiary_change.rs (1)
  • assert_all_snapshots (70-70)
src/lotus_json/raw_bytes.rs (1)
  • assert_all_snapshots (9-9)
⏰ 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). (7)
  • GitHub Check: Build Ubuntu
  • GitHub Check: Build MacOS
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: tests
  • GitHub Check: tests-release
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: All lint checks
🔇 Additional comments (8)
src/rpc/registry/methods_reg.rs (1)

77-79: LGTM: market module import.

This wires Market actor into the registry surface.

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

11-11: LGTM: expose Market actor registry module.

Module presence matches usage in the central registry.

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

14-14: LGTM: include market_actor_params.

This is the right place to stage Market param Lotus JSON bridges.

src/lotus_json/mod.rs (1)

234-234: No duplicate HasLotusJson impl for PaddedPieceSize. Only one impl HasLotusJson for PaddedPieceSize exists in src/lotus_json/padded_piece_size.rs, so there’s no conflicting implementation.

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

111-126: LGTM: v8–v9 basic method coverage is complete.

AddBalance, WithdrawBalance, PublishStorageDeals, VerifyDealsForActivation, OnMinerSectorsTerminate, plus Constructor/CronTick registration looks correct for pre-exported eras.

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

3699-3711: LGTM: PieceChange Lotus JSON wiring aligns with existing conventions.

Fields use LotusJson for Cid, PaddedPieceSize, and RawBytes; conversions are consistent.

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

1905-1905: Good call: wire Market actor decode-params tests into the suite.

This expands coverage meaningfully and stays consistent with the existing pattern.

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

582-673: Alias resolution suggestion not applicable: no GetDeal*Params types exist in the codebase.

Likely an incorrect or invalid review comment.

@akaladarshi akaladarshi force-pushed the elmattic/market-decode-params branch from bbc1579 to 02b1560 Compare September 9, 2025 17:09
@akaladarshi akaladarshi marked this pull request as ready for review September 9, 2025 17:27
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: 7

🧹 Nitpick comments (3)
src/tool/subcommands/api_cmd/api_compare_tests.rs (2)

3330-3373: Helper builders: OK; minor nit on tiny TokenAmount literals

Using TokenAmount::from_atto(10u8) works but is a bit odd next to other u64 literals. Consider u64 for consistency.

- fvm_shared4::econ::TokenAmount::from_atto(10u8),
+ fvm_shared4::econ::TokenAmount::from_atto(10u64),

3597-3602: BitField setup for SettleDealPaymentsExported

Using a BitField with bit 42 set is fine. Consider adding another case with multiple ranges to catch encoding edge cases later.

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

1517-1579: SectorContentChangedParams mappings

The ext::miner wrapper looks consistent. Consider adding a non-empty snapshot with multiple PieceChange entries later to harden coverage.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0825c59 and 02b1560.

📒 Files selected for processing (3)
  • src/lotus_json/actor_states/methods/market_actor_params.rs (1 hunks)
  • src/tool/subcommands/api_cmd/api_compare_tests.rs (2 hunks)
  • src/tool/subcommands/api_cmd/test_snapshots.txt (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: akaladarshi
PR: ChainSafe/forest#5996
File: src/lotus_json/actor_states/methods/paych_params.rs:269-277
Timestamp: 2025-09-02T08:46:04.937Z
Learning: In payment channel actor Lotus JSON serialization, empty merges should be serialized as `null` (not an empty array `[]`) to maintain compatibility with Lotus behavior.
📚 Learning: 2025-08-18T12:25:29.183Z
Learnt from: akaladarshi
PR: ChainSafe/forest#5896
File: src/lotus_json/actor_states/methods/verified_reg_actor.rs:133-137
Timestamp: 2025-08-18T12:25:29.183Z
Learning: In Lotus JSON for verified registry actor, the SectorAllocationClaimsLotusJson struct uses "SectorExpiry" as the field name for the expiry field, not "Expiry". The current code with #[serde(rename = "SectorExpiry")] is correct.

Applied to files:

  • src/lotus_json/actor_states/methods/market_actor_params.rs
🧬 Code graph analysis (2)
src/tool/subcommands/api_cmd/api_compare_tests.rs (4)
src/shim/address.rs (3)
  • default (122-124)
  • new_id (142-144)
  • new_bls (150-152)
src/shim/econ.rs (1)
  • from_atto (106-108)
src/shim/crypto.rs (1)
  • new_bls (77-82)
src/blocks/tipset.rs (4)
  • new (242-260)
  • new (494-511)
  • key (336-339)
  • key (530-533)
src/lotus_json/actor_states/methods/market_actor_params.rs (3)
src/shim/address.rs (1)
  • new_id (142-144)
src/lotus_json/mod.rs (17)
  • snapshots (147-147)
  • snapshots (566-568)
  • snapshots (580-582)
  • snapshots (597-599)
  • snapshots (621-623)
  • serde_json (301-301)
  • serde_json (325-325)
  • into_lotus_json (148-148)
  • into_lotus_json (569-571)
  • into_lotus_json (583-585)
  • into_lotus_json (600-606)
  • into_lotus_json (624-631)
  • from_lotus_json (149-149)
  • from_lotus_json (572-574)
  • from_lotus_json (586-591)
  • from_lotus_json (607-613)
  • from_lotus_json (632-639)
src/shim/sector.rs (13)
  • from (108-110)
  • from (191-197)
  • from (212-214)
  • from (255-257)
  • from (261-264)
  • from (268-271)
  • from (275-277)
  • from (281-284)
  • from (288-291)
  • from (379-384)
  • invalid (139-141)
  • new (170-180)
  • new (362-367)
⏰ 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). (7)
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: tests
  • GitHub Check: tests-release
  • GitHub Check: Snapshot export checks v2 with F3 data
  • GitHub Check: Snapshot export checks
  • GitHub Check: Calibnet no discovery checks
  • GitHub Check: Calibnet check
🔇 Additional comments (8)
src/tool/subcommands/api_cmd/test_snapshots.txt (1)

93-113: Remove local snapshot file presence check — entries are manifest-only
Snapshot files listed in test_snapshots.txt aren’t committed to the repo but are fetched from the DigitalOcean bucket via the manifest; no need to verify local file existence.

Likely an incorrect or invalid review comment.

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

1903-1906: Wire-up of market decode tests is correct

Hooking market_actor_state_decode_params_tests into state_decode_params_api_tests broadens coverage as intended. LGTM.


3513-3524: AddBalanceExported params use Address — correct for FRC-42 export

Passing Address for AddBalanceExported matches Lotus’ exported signature. LGTM.


3531-3566: Deal-query exported methods reuse DealQueryParams — good reuse

Reusing DealQueryParams across all GetDeal*Exported variants is correct and keeps the tests lean. LGTM.

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

173-187: DealProposalLotusJson mappings look correct

PieceCID rename, PaddedPieceSize wrapper, and TokenAmount fields align with Lotus expectations. LGTM.


115-121: Label untagged enum is correct and version-agnostic

The untagged String/Bytes representation matches Lotus. Good choice.


690-830: SectorDeals cross-version handling is careful and sensible

Defaulting absent sector_type/number appropriately and using RegisteredSealProof::invalid() for missing values is pragmatic across v8–v16. LGTM.


1581-1608: Snapshot coverage is comprehensive

Great breadth across v8–v16, including exported methods. This should catch most regressions.

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 (3)
src/rpc/registry/actors/market.rs (3)

4-4: Alias the macro to avoid name confusion with the local fn of the same identifier.

Having both a macro and a function named register_actor_methods in scope is legal but easy to misread. Alias the macro and invoke the alias throughout this module.

Apply:

-use crate::rpc::registry::methods_reg::{MethodRegistry, register_actor_methods};
+use crate::rpc::registry::methods_reg::{MethodRegistry, register_actor_methods as register_methods};

Then replace all invocations:

-        register_actor_methods!(
+        register_methods!(

(Repeat for all occurrences in this file.)


89-109: Slight import clarity tweak for nested ext::miner path.

Split the nested import to make the scope explicit and reduce chances of future merge conflicts.

-        use $market_state_version::{
-            GetDealSectorParams, Method, SettleDealPaymentsParams,
-            ext::miner::SectorContentChangedParams,
-        };
+        use $market_state_version::{GetDealSectorParams, Method, SettleDealPaymentsParams};
+        use $market_state_version::ext::miner::SectorContentChangedParams;

177-191: Log on unknown/unsupported version to aid diagnostics.

A silent no-op on _ => {} can hide misconfigurations. Emit a low-level log.

-        _ => {}
+        _ => {
+            tracing::debug!(%version, actor_code = %cid, "Market actor version not handled; no method registrations performed");
+        }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02b1560 and 81c1f4b.

📒 Files selected for processing (2)
  • src/lotus_json/actor_states/methods/market_actor_params.rs (1 hunks)
  • src/rpc/registry/actors/market.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lotus_json/actor_states/methods/market_actor_params.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). (7)
  • GitHub Check: All lint checks
  • GitHub Check: tests
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: tests-release
  • GitHub Check: Build Ubuntu
  • GitHub Check: Build MacOS
  • GitHub Check: Build forest binaries on Linux AMD64
🔇 Additional comments (5)
src/rpc/registry/actors/market.rs (5)

9-41: Basic methods set looks correct and clearly grouped.

Constructor/CronTick registered as empty; core params wired per version module. No issues spotted.


43-87: Exported methods v10+: solid mapping; param types look right.

Notably, GetBalanceExported taking Address matches expectations; others reuse the corresponding params. Good.


111-126: v8–v9 additions LGTM.

ActivateDeals and ComputeDataCommitment are registered alongside basics for these versions. Looks consistent.


128-145: v10–v11 set is consistent with v8–v9 plus exported block.

No concerns.


161-175: Double-check v13+ method surface for any lingering ComputeDataCommitment variant.

If ComputeDataCommitment persists beyond v12, add it here as well; otherwise current set is fine.

Patch if needed:

-        use $market_state_version::{BatchActivateDealsParams, Method};
+        use $market_state_version::{BatchActivateDealsParams, ComputeDataCommitmentParams, Method};

         register_actor_methods!(
             $registry,
             $code_cid,
-            [(Method::BatchActivateDeals, BatchActivateDealsParams),]
+            [
+                (Method::BatchActivateDeals, BatchActivateDealsParams),
+                (Method::ComputeDataCommitment, ComputeDataCommitmentParams),
+            ]
         );

@akaladarshi akaladarshi force-pushed the elmattic/market-decode-params branch from 81c1f4b to 15083d0 Compare September 10, 2025 06:08
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lotus_json/actor_states/methods/market_actor_params.rs (1)

1566-1593: Add missing HasLotusJson impls for all GetDeal*Params
The test_snapshots! calls at the end of market_actor_params.rs reference these types, but there are no corresponding impl HasLotusJson for fil_actor_market_state::vX::GetDeal…Params. You must add conversion implementations (e.g. via a new macro or explicit impl HasLotusJson blocks) for each of:

  • GetDealActivationParams
  • GetDealClientCollateralParams
  • GetDealClientParams
  • GetDealDataCommitmentParams
  • GetDealLabelParams
  • GetDealProviderCollateralParams
  • GetDealProviderParams
  • GetDealTermParams
  • GetDealTotalPriceParams
  • GetDealVerifiedParams
  • GetDealSectorParams
♻️ Duplicate comments (2)
src/lotus_json/actor_states/methods/market_actor_params.rs (2)

14-18: Fix: bring serde_json::json! into scope (compilation blocker).

Unqualified json! is used in several snapshots but the macro isn’t imported. Add the import (or fully-qualify each call).

Apply at the top of the file:

 use schemars::JsonSchema;
 use serde::{Deserialize, Serialize};
+use serde_json::json;
 use std::fmt::Debug;

Also applies to: 81-85, 422-447, 504-526, 586-610


1424-1431: Empty BitField snapshot should be [] (not [0]).

[0] encodes bit 0 set; an empty BitField should serialize to an empty array.

-                            (
-                                serde_json::json!([0]),
-                                Self { deal_ids: BitField::new() }
-                            ),
+                            (
+                                serde_json::json!([]),
+                                Self { deal_ids: BitField::new() }
+                            ),
🧹 Nitpick comments (1)
src/lotus_json/actor_states/methods/market_actor_params.rs (1)

411-491: Optional: deduplicate PublishStorageDeals snapshots.

The V2/V3/V4 snapshot blocks share most JSON; only the signature type differs. Consider extracting a tiny helper to build the common JSON/value pair to reduce duplication and future drift.

I can propose a small local function under #[cfg(test)] returning the shared tuple, parameterized by the signature.

Also applies to: 493-573, 575-655

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81c1f4b and 15083d0.

📒 Files selected for processing (2)
  • src/lotus_json/actor_states/methods/market_actor_params.rs (1 hunks)
  • src/rpc/registry/actors/market.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/rpc/registry/actors/market.rs
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-18T12:25:29.183Z
Learnt from: akaladarshi
PR: ChainSafe/forest#5896
File: src/lotus_json/actor_states/methods/verified_reg_actor.rs:133-137
Timestamp: 2025-08-18T12:25:29.183Z
Learning: In Lotus JSON for verified registry actor, the SectorAllocationClaimsLotusJson struct uses "SectorExpiry" as the field name for the expiry field, not "Expiry". The current code with #[serde(rename = "SectorExpiry")] is correct.

Applied to files:

  • src/lotus_json/actor_states/methods/market_actor_params.rs
📚 Learning: 2025-09-02T08:44:08.346Z
Learnt from: akaladarshi
PR: ChainSafe/forest#5996
File: src/lotus_json/actor_states/methods/paych_params.rs:56-58
Timestamp: 2025-09-02T08:44:08.346Z
Learning: In Lotus JSON for payment channel SignedVoucher, the secret_pre_image field should use serde rename to "SecretHash" (not "SecretPreImage") for Lotus API compatibility, even though the internal struct field is named SecretPreimage. This matches the actual JSON format used by Lotus.

Applied to files:

  • src/lotus_json/actor_states/methods/market_actor_params.rs
📚 Learning: 2025-09-02T08:46:04.937Z
Learnt from: akaladarshi
PR: ChainSafe/forest#5996
File: src/lotus_json/actor_states/methods/paych_params.rs:269-277
Timestamp: 2025-09-02T08:46:04.937Z
Learning: In payment channel actor Lotus JSON serialization, empty merges should be serialized as `null` (not an empty array `[]`) to maintain compatibility with Lotus behavior.

Applied to files:

  • src/lotus_json/actor_states/methods/market_actor_params.rs
🧬 Code graph analysis (1)
src/lotus_json/actor_states/methods/market_actor_params.rs (5)
src/shim/address.rs (1)
  • new_id (142-144)
src/lotus_json/mod.rs (17)
  • snapshots (147-147)
  • snapshots (566-568)
  • snapshots (580-582)
  • snapshots (597-599)
  • snapshots (621-623)
  • serde_json (301-301)
  • serde_json (325-325)
  • into_lotus_json (148-148)
  • into_lotus_json (569-571)
  • into_lotus_json (583-585)
  • into_lotus_json (600-606)
  • into_lotus_json (624-631)
  • from_lotus_json (149-149)
  • from_lotus_json (572-574)
  • from_lotus_json (586-591)
  • from_lotus_json (607-613)
  • from_lotus_json (632-639)
src/lotus_json/actor_states/methods/miner_actor_params.rs (33)
  • snapshots (797-811)
  • snapshots (1152-1186)
  • snapshots (1279-1290)
  • snapshots (1403-1417)
  • snapshots (1532-1546)
  • snapshots (1679-1691)
  • snapshots (1752-1762)
  • snapshots (2005-2041)
  • snapshots (2566-2578)
  • snapshots (3085-3106)
  • snapshots (3277-3301)
  • into_lotus_json (813-819)
  • into_lotus_json (1188-1207)
  • into_lotus_json (1292-1297)
  • into_lotus_json (1419-1425)
  • into_lotus_json (1548-1554)
  • into_lotus_json (1693-1701)
  • into_lotus_json (1764-1771)
  • into_lotus_json (2043-2062)
  • into_lotus_json (2580-2588)
  • into_lotus_json (3108-3124)
  • into_lotus_json (3303-3316)
  • from_lotus_json (821-827)
  • from_lotus_json (1209-1231)
  • from_lotus_json (1299-1304)
  • from_lotus_json (1427-1433)
  • from_lotus_json (1556-1562)
  • from_lotus_json (1703-1708)
  • from_lotus_json (1773-1777)
  • from_lotus_json (2064-2083)
  • from_lotus_json (2590-2595)
  • from_lotus_json (3126-3139)
  • from_lotus_json (3318-3328)
src/shim/econ.rs (1)
  • from_atto (106-108)
src/shim/sector.rs (13)
  • from (108-110)
  • from (191-197)
  • from (212-214)
  • from (255-257)
  • from (261-264)
  • from (268-271)
  • from (275-277)
  • from (281-284)
  • from (288-291)
  • from (379-384)
  • invalid (139-141)
  • new (170-180)
  • new (362-367)
⏰ 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). (7)
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: Build Ubuntu
  • GitHub Check: Build MacOS
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: tests
  • GitHub Check: All lint checks
  • GitHub Check: tests-release
🔇 Additional comments (7)
src/lotus_json/actor_states/methods/market_actor_params.rs (7)

20-29: WithdrawBalance params mapping looks correct.

Field rename to “ProviderOrClientAddress” and TokenAmount mapping match Lotus JSON.


31-37: Tuple newtype for AddBalance is appropriate.

Lotus expects a bare address; tuple struct keeps encoding minimal.


111-116: Label untagged enum matches Lotus (string-or-bytes) behavior.

Good use of #[serde(untagged)].


152-181: DealProposal Lotus JSON shape LGTM.

  • Correct “PieceCID” rename.
  • PaddedPieceSize and TokenAmount conversions are wired properly.

657-672: SectorDealsLotusJson keys align with Lotus.

Optional SectorNumber/SectorType with DealIDs rename is correct.


718-761: Defaulting SectorType to invalid() on deserialize—confirm intent.

For v9–v12, from_lotus_json uses unwrap_or(RegisteredSealProof::invalid()). Verify that “missing SectorType” should round-trip to Invalid(0) rather than error.

Would you prefer to treat missing SectorType as an error for these versions?


1183-1233: BitField JSON form in snapshots—confirm consistency across modules.

Here, V13 OnMinerSectorsTerminateParams snapshot encodes Sectors as [1, 1], while miner actor snapshots sometimes use a base64 string. Ensure the crate’s LotusJson<BitField> intentionally supports both and that tests reflect the canonical form you want to enforce.

If you want a single canonical encoding across snapshots, I can generate a patch to standardize them.

@akaladarshi akaladarshi added this pull request to the merge queue Sep 10, 2025
Merged via the queue into main with commit 4b4411a Sep 10, 2025
39 checks passed
@akaladarshi akaladarshi deleted the elmattic/market-decode-params branch September 10, 2025 08:56
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 Market actor state in Filecoin.StateDecodeParams API

6 participants