Skip to content

Enable strict json check in api compare#6970

Open
sudo-shashank wants to merge 6 commits intomainfrom
shashank/enable-strict-json-api
Open

Enable strict json check in api compare#6970
sudo-shashank wants to merge 6 commits intomainfrom
shashank/enable-strict-json-api

Conversation

@sudo-shashank
Copy link
Copy Markdown
Contributor

@sudo-shashank sudo-shashank commented Apr 28, 2026

Summary of changes

Changes introduced in this pull request:

  • Set FOREST_STRICT_JSON=1 for all api compare check.

  • Fix the unknown field error found in the below methods:

    • Filecoin.ChainGetBlockMessages
    • Filecoin.ChainGetMessagesInTipset
    • Filecoin.ChainGetParentMessages
    • Filecoin.MpoolPending
    • Filecoin.StateCall
    • Filecoin.StateGetNetworkParams
    • Filecoin.StateReplay
    • Filecoin.Version

Reference issue to close (if applicable)

Closes #5635

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • New Features

    • Execution traces now include IPLD operations and logs for enhanced tracing visibility
    • Messages include CID field directly in responses
    • Version API now includes optional Agent identifier
    • Network parameters extended with Genesis Timestamp and new fork upgrade height
  • Improvements

    • RPC message operations now return Message directly, simplifying response structure

@sudo-shashank sudo-shashank added the RPC requires calibnet RPC checks to run on CI label Apr 28, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

Walkthrough

The changes refactor message handling and execution trace modeling by having RPC endpoints return Message directly instead of a FlattenedApiMessage wrapper, while adding a CID field to Message itself. Execution traces are extended with IpldOps and Logs arrays. OpenRPC schema definitions and integration points across RPC methods, serialization, and client code are updated accordingly.

Changes

Cohort / File(s) Summary
OpenRPC Schema Definitions
docs/openrpc-specs/v0.json, docs/openrpc-specs/v1.json
Aligned message and trace models: replaced FlattenedApiMessage with direct Message references; added TraceIpld/TraceIpldOp schemas for execution tracing; enhanced ExecutionTrace with IpldOps and Logs fields; updated Message with CID field and Params to use Base64String; added required fields to ForkUpgradeParams (UpgradeXxHeight), NetworkParams (GenesisTimestamp), and PublicVersion (Agent).
Message Type Definitions
src/lotus_json/message.rs, src/rpc/methods/chain.rs, src/rpc/methods/gas.rs
Changed MessageLotusJson.params from Option<RawBytes> to required RawBytes and added CID field; removed FlattenedApiMessage struct; updated ChainGetMessage and GasEstimateMessageGas RPC methods to return Message directly instead of wrapper.
Execution Trace & Network Parameters
src/rpc/methods/state/types.rs, src/rpc/methods/state.rs, src/state_manager/utils.rs
Added TraceIpldOp enum and TraceIpld struct for IPLD operation tracking; extended ExecutionTrace with logs and ipld_ops fields; added genesis_timestamp to NetworkParams and upgrade_xx_height to ForkUpgradeParams; overrode ExecutionTrace equality to exclude implementation-dependent log/IPLD details.
RPC Response Types
src/rpc/methods/common.rs
Added optional agent: Option<String> field to PublicVersion struct with appropriate serde attributes.
Test Configuration & Fixtures
scripts/tests/api_compare/docker-compose.yml, src/rpc/methods/eth.rs
Added FOREST_STRICT_JSON=1 environment variable to API comparison test services; updated create_execution_trace test fixture to populate logs and ipld_ops fields.
API Testing & Integration
src/tool/subcommands/api_cmd/api_compare_tests.rs, src/tool/subcommands/api_cmd/stateful_tests.rs, src/wallet/subcommands/wallet_cmd.rs
Updated GasEstimateMessageGas test comparison to accept unwrapped Message directly; refactored EIP-1559 signing flow to use unsigned_msg directly; simplified wallet gas estimation to assign full Message result without wrapper unwrapping.
Serialization & Test Snapshots
src/lotus_json/signed_message.rs, src/tool/subcommands/api_cmd/test_snapshots.txt
Updated SignedMessage test snapshot to include computed CID field in nested Message; updated state network params test snapshot reference.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

Suggested reviewers

  • hanabi1224
  • LesnyRumcajs
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The changes extend beyond the minimal strict JSON flag by refactoring core RPC response structures (replacing FlattenedApiMessage, adding fields to Message, NetworkParams, ExecutionTrace), which goes beyond fixing deserialization errors from unknown fields. Clarify whether schema changes (Message CID field, ExecutionTrace logs/ipld_ops, ForkUpgradeParams, PublicVersion Agent, NetworkParams GenesisTimestamp) are required by issue #5635 or represent separate enhancements that should be tracked in different issues.
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Enable strict json check in api compare' is concise and directly describes the main objective of enabling strict JSON checking in API comparison tests, which aligns with the primary changeset.
Linked Issues check ✅ Passed The PR comprehensively addresses issue #5635 by implementing strict JSON field checking and fixing multiple RPC methods that failed deserialization, meeting all stated objectives and completion criteria.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shashank/enable-strict-json-api
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch shashank/enable-strict-json-api

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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

@sudo-shashank sudo-shashank changed the title Enable strict json check Enable strict json check in api compare Apr 28, 2026
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.

Caution

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

⚠️ Outside diff range comments (1)
src/rpc/methods/state.rs (1)

3234-3284: ⚠️ Potential issue | 🟠 Major

upgrade_xx_height should be config-driven, not hardcoded.

Line 3284 hardcodes a sentinel epoch, so StateGetNetworkParams can diverge from the actual network config once that upgrade is scheduled (or on custom networks). Please source this value from ChainConfig (with an explicit fallback policy if needed) rather than embedding a literal.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/rpc/methods/state.rs` around lines 3234 - 3284, The code currently
hardcodes upgrade_xx_height to 999_999_999_999_999 in TryFrom<&ChainConfig> for
ForkUpgradeParams; instead, read the value from ChainConfig (use the existing
height lookup helper get_height or an explicit ChainConfig field for the XX
upgrade) and assign that to upgrade_xx_height, with a clear fallback policy
(e.g., use get_height(XX)? or fallback to
config.some_optional_xx_height.unwrap_or(default_epoch)) so
StateGetNetworkParams stays in sync with the network config. Locate this change
in the try_from implementation that constructs ForkUpgradeParams and replace the
literal with the config-driven lookup and fallback.
🧹 Nitpick comments (2)
src/lotus_json/message.rs (1)

120-120: Optional readability tweak for intentionally ignored CID.

Consider using an explicit ignored binding name and short comment for parity with signed_message.rs.

Suggested tiny cleanup
-            cid: _,
+            cid: _ignored_cid, // CID is derived from message fields; input CID is not used
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lotus_json/message.rs` at line 120, The ignored CID field in message.rs
is currently written as cid: _, which is less explicit; update the pattern to
use an explicit ignored binding like cid: _cid and add a short comment (e.g., //
intentionally ignored) to match the style used in signed_message.rs so the
intent is clear when reading the Message destructuring.
src/rpc/methods/state/types.rs (1)

204-213: Consider adding a short struct-level note explaining why logs/ipld_ops are excluded from equality.

The code is fine as-is; this would just make intent easier to retain for future changes around API-compare behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/rpc/methods/state/types.rs` around lines 204 - 213, Add a short doc
comment on the ExecutionTrace struct explaining why logs and ipld_ops are
intentionally excluded from the PartialEq implementation: they are
implementation-dependent and not part of API-level equality comparison. Update
the struct-level comment for ExecutionTrace (referencing fields logs and
ipld_ops and the PartialEq impl) to state this intent so future maintainers
understand why eq ignores those fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/rpc/methods/state.rs`:
- Around line 3234-3284: The code currently hardcodes upgrade_xx_height to
999_999_999_999_999 in TryFrom<&ChainConfig> for ForkUpgradeParams; instead,
read the value from ChainConfig (use the existing height lookup helper
get_height or an explicit ChainConfig field for the XX upgrade) and assign that
to upgrade_xx_height, with a clear fallback policy (e.g., use get_height(XX)? or
fallback to config.some_optional_xx_height.unwrap_or(default_epoch)) so
StateGetNetworkParams stays in sync with the network config. Locate this change
in the try_from implementation that constructs ForkUpgradeParams and replace the
literal with the config-driven lookup and fallback.

---

Nitpick comments:
In `@src/lotus_json/message.rs`:
- Line 120: The ignored CID field in message.rs is currently written as cid: _,
which is less explicit; update the pattern to use an explicit ignored binding
like cid: _cid and add a short comment (e.g., // intentionally ignored) to match
the style used in signed_message.rs so the intent is clear when reading the
Message destructuring.

In `@src/rpc/methods/state/types.rs`:
- Around line 204-213: Add a short doc comment on the ExecutionTrace struct
explaining why logs and ipld_ops are intentionally excluded from the PartialEq
implementation: they are implementation-dependent and not part of API-level
equality comparison. Update the struct-level comment for ExecutionTrace
(referencing fields logs and ipld_ops and the PartialEq impl) to state this
intent so future maintainers understand why eq ignores those fields.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1d5006cd-50f9-4bf8-9882-73c9293697ea

📥 Commits

Reviewing files that changed from the base of the PR and between 65c39a0 and e15b409.

⛔ Files ignored due to path filters (2)
  • src/rpc/snapshots/forest__rpc__tests__rpc__v0.snap is excluded by !**/*.snap
  • src/rpc/snapshots/forest__rpc__tests__rpc__v1.snap is excluded by !**/*.snap
📒 Files selected for processing (11)
  • docs/openrpc-specs/v0.json
  • docs/openrpc-specs/v1.json
  • scripts/tests/api_compare/docker-compose.yml
  • src/lotus_json/message.rs
  • src/lotus_json/signed_message.rs
  • src/rpc/methods/common.rs
  • src/rpc/methods/eth.rs
  • src/rpc/methods/state.rs
  • src/rpc/methods/state/types.rs
  • src/state_manager/utils.rs
  • src/tool/subcommands/api_cmd/test_snapshots.txt

@sudo-shashank sudo-shashank marked this pull request as ready for review April 28, 2026 02:15
@sudo-shashank sudo-shashank requested a review from a team as a code owner April 28, 2026 02:15
@sudo-shashank sudo-shashank requested review from LesnyRumcajs and akaladarshi and removed request for a team April 28, 2026 02:15
"UpgradeTockHeight",
"UpgradeGoldenWeekHeight"
"UpgradeGoldenWeekHeight",
"UpgradeXxHeight"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this doesn't seem right

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.

Caution

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

⚠️ Outside diff range comments (1)
docs/openrpc-specs/v0.json (1)

10151-10189: ⚠️ Potential issue | 🟠 Major

Remove or make UpgradeXxHeight optional in the OpenRPC schema.

Lotus's StateGetNetworkParams returns UpgradeFireHorseHeight in ForkUpgradeParams, not UpgradeXxHeight. Forest's implementation hardcodes upgrade_xx_height to 999_999_999_999_999, but marking it as required in the OpenRPC schema will cause strict validation failures against Lotus responses, which omit this field entirely. Either remove UpgradeXxHeight from the schema or mark it as non-required to maintain compatibility.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/openrpc-specs/v0.json` around lines 10151 - 10189, The OpenRPC schema
currently lists UpgradeXxHeight as a required property in the ForkUpgradeParams
object which conflicts with Lotus's StateGetNetworkParams (which returns
UpgradeFireHorseHeight and omits UpgradeXxHeight) and forces strict validation
failures; update the schema by either removing UpgradeXxHeight from the
ForkUpgradeParams required array or moving UpgradeXxHeight out of the "required"
list (making it optional) so responses that omit upgrade_xx_height (Forest
hardcodes it but Lotus omits it) validate correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@docs/openrpc-specs/v0.json`:
- Around line 10151-10189: The OpenRPC schema currently lists UpgradeXxHeight as
a required property in the ForkUpgradeParams object which conflicts with Lotus's
StateGetNetworkParams (which returns UpgradeFireHorseHeight and omits
UpgradeXxHeight) and forces strict validation failures; update the schema by
either removing UpgradeXxHeight from the ForkUpgradeParams required array or
moving UpgradeXxHeight out of the "required" list (making it optional) so
responses that omit upgrade_xx_height (Forest hardcodes it but Lotus omits it)
validate correctly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 17b75584-731e-4e12-b601-7db4e794ecda

📥 Commits

Reviewing files that changed from the base of the PR and between e15b409 and 0869652.

⛔ Files ignored due to path filters (2)
  • src/rpc/snapshots/forest__rpc__tests__rpc__v0.snap is excluded by !**/*.snap
  • src/rpc/snapshots/forest__rpc__tests__rpc__v1.snap is excluded by !**/*.snap
📒 Files selected for processing (8)
  • docs/openrpc-specs/v0.json
  • docs/openrpc-specs/v1.json
  • src/lotus_json/message.rs
  • src/rpc/methods/chain.rs
  • src/rpc/methods/gas.rs
  • src/tool/subcommands/api_cmd/api_compare_tests.rs
  • src/tool/subcommands/api_cmd/stateful_tests.rs
  • src/wallet/subcommands/wallet_cmd.rs
✅ Files skipped from review due to trivial changes (1)
  • src/tool/subcommands/api_cmd/api_compare_tests.rs

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 64.13%. Comparing base (6d1789f) to head (0869652).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/wallet/subcommands/wallet_cmd.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/lotus_json/message.rs 100.00% <100.00%> (ø)
src/lotus_json/signed_message.rs 92.45% <100.00%> (+0.45%) ⬆️
src/rpc/methods/chain.rs 56.58% <100.00%> (-0.05%) ⬇️
src/rpc/methods/common.rs 61.53% <100.00%> (+1.01%) ⬆️
src/rpc/methods/eth.rs 65.27% <100.00%> (+0.02%) ⬆️
src/rpc/methods/gas.rs 86.55% <100.00%> (-0.04%) ⬇️
src/rpc/methods/state.rs 44.77% <100.00%> (+0.02%) ⬆️
src/rpc/methods/state/types.rs 100.00% <100.00%> (ø)
src/state_manager/utils.rs 79.90% <100.00%> (+0.09%) ⬆️
src/wallet/subcommands/wallet_cmd.rs 25.45% <0.00%> (ø)

... and 12 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04fac3b...0869652. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Deny unknown fields on RPC response deserialization

2 participants