Skip to content

Enable strict json check in api compare#6969

Draft
sudo-shashank wants to merge 1 commit intomainfrom
shashank/enable-strict-json
Draft

Enable strict json check in api compare#6969
sudo-shashank wants to merge 1 commit intomainfrom
shashank/enable-strict-json

Conversation

@sudo-shashank
Copy link
Copy Markdown
Contributor

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

Summary of changes

Changes introduced in this pull request:

  • Set FOREST_STRICT_JSON=1 for all api compare check and fix the unknown field error found in some RPC response.

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

Release Notes

  • New Features

    • RPC responses now include execution logs and IPLD operation details in trace data.
    • Version endpoint now returns an optional agent identifier.
    • Network parameters endpoint now includes genesis timestamp.
    • Fork upgrade parameters include new upgrade height value.
  • Chores

    • Updated API specification schemas to reflect new response fields and data structures.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 46f89b04-a408-43bd-9696-b8868fa4ea74

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

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shashank/enable-strict-json
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch shashank/enable-strict-json

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

@sudo-shashank sudo-shashank added the RPC requires calibnet RPC checks to run on CI label Apr 27, 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/lotus_json/message.rs (1)

108-120: ⚠️ Potential issue | 🟠 Major

Don’t discard CID if these responses still need semantic parity checks.

from_lotus_json now drops the parsed CID, so RpcTest::identity / RpcTest::validate only compare the message body fields for Message responses. That means ChainGetMessage and GasEstimateMessageGas can serialize a wrong embedded CID and still pass the new strict-json compare as long as the field is syntactically valid. Please keep the CID in a compare-only type, or add an explicit raw-JSON CID assertion for these endpoints.

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

In `@src/lotus_json/message.rs` around lines 108 - 120, The from_lotus_json
implementation is dropping the parsed CID (cid: _) which lets responses with
incorrect embedded CIDs pass semantic parity checks; update from_lotus_json in
message.rs to preserve the parsed CID (e.g., bind cid and store it on the
returned compare-type or on Message) instead of discarding it, or alternatively
add an explicit raw-JSON CID assertion in the RpcTest identity/validate code
paths for the Message responses (notably ChainGetMessage and
GasEstimateMessageGas) so the CID is included in comparisons; locate the
from_lotus_json function and the LotusJson/Message compare-type and either
propagate the cid into that type or add a CID check in RpcTest::identity /
RpcTest::validate.
🧹 Nitpick comments (1)
src/rpc/methods/state.rs (1)

3234-3234: Replace the raw upgrade sentinel with a named constant.

Line 3284 uses a magic value for upgrade_xx_height. Please extract it to a named constant with a short rationale to reduce accidental drift.

♻️ Suggested refactor
+const UPGRADE_XX_HEIGHT_PLACEHOLDER: ChainEpoch = 999_999_999_999_999;
+
 impl TryFrom<&ChainConfig> for ForkUpgradeParams {
@@
-            upgrade_xx_height: 999_999_999_999_999,
+            upgrade_xx_height: UPGRADE_XX_HEIGHT_PLACEHOLDER,

Also applies to: 3284-3284

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

In `@src/rpc/methods/state.rs` at line 3234, Introduce a named constant (e.g.
UPGRADE_XX_HEIGHT: ChainEpoch = <magic_value>) and replace the raw magic literal
used for upgrade_xx_height with that constant; update the declaration/assignment
involving upgrade_xx_height and any other occurrences to reference
UPGRADE_XX_HEIGHT, and add a brief doc comment explaining the rationale
(prevents accidental drift and centralizes the sentinel for upgrade XX). Ensure
references to the symbol upgrade_xx_height in functions/structs in this module
now use UPGRADE_XX_HEIGHT so the sentinel is defined once and clearly
documented.
🤖 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/lotus_json/message.rs`:
- Around line 108-120: The from_lotus_json implementation is dropping the parsed
CID (cid: _) which lets responses with incorrect embedded CIDs pass semantic
parity checks; update from_lotus_json in message.rs to preserve the parsed CID
(e.g., bind cid and store it on the returned compare-type or on Message) instead
of discarding it, or alternatively add an explicit raw-JSON CID assertion in the
RpcTest identity/validate code paths for the Message responses (notably
ChainGetMessage and GasEstimateMessageGas) so the CID is included in
comparisons; locate the from_lotus_json function and the LotusJson/Message
compare-type and either propagate the cid into that type or add a CID check in
RpcTest::identity / RpcTest::validate.

---

Nitpick comments:
In `@src/rpc/methods/state.rs`:
- Line 3234: Introduce a named constant (e.g. UPGRADE_XX_HEIGHT: ChainEpoch =
<magic_value>) and replace the raw magic literal used for upgrade_xx_height with
that constant; update the declaration/assignment involving upgrade_xx_height and
any other occurrences to reference UPGRADE_XX_HEIGHT, and add a brief doc
comment explaining the rationale (prevents accidental drift and centralizes the
sentinel for upgrade XX). Ensure references to the symbol upgrade_xx_height in
functions/structs in this module now use UPGRADE_XX_HEIGHT so the sentinel is
defined once and clearly documented.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5026415e-3cba-4e3d-b814-81fb089f7e5a

📥 Commits

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

⛔ 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 (15)
  • 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/chain.rs
  • src/rpc/methods/common.rs
  • src/rpc/methods/eth.rs
  • src/rpc/methods/gas.rs
  • src/rpc/methods/state.rs
  • src/rpc/methods/state/types.rs
  • src/state_manager/utils.rs
  • src/tool/subcommands/api_cmd/api_compare_tests.rs
  • src/tool/subcommands/api_cmd/stateful_tests.rs
  • src/wallet/subcommands/wallet_cmd.rs

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.

🧹 Nitpick comments (1)
src/rpc/methods/state.rs (1)

3234-3284: Replace the hard-coded upgrade sentinel with a named constant.

Line 3284 uses a raw sentinel epoch. A named constant will make intent clearer and reduce drift risk in future edits.

♻️ Suggested small cleanup
+const UPGRADE_XX_SENTINEL_HEIGHT: ChainEpoch = 999_999_999_999_999;
...
-            upgrade_xx_height: 999_999_999_999_999,
+            upgrade_xx_height: UPGRADE_XX_SENTINEL_HEIGHT,
🤖 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 hard-coded sentinel
999_999_999_999_999 assigned to ForkUpgradeParams::upgrade_xx_height in the
TryFrom<&ChainConfig> impl should be replaced with a named constant (e.g.,
UPGRADE_SENTINEL or MAX_SENTINEL_EPOCH) to clarify intent and avoid future
drift; define the constant near the top of the module (or in the crate's
constants module) and use that constant in the try_from conversion for
upgrade_xx_height so all references are explicit and easy to update.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/rpc/methods/state.rs`:
- Around line 3234-3284: The hard-coded sentinel 999_999_999_999_999 assigned to
ForkUpgradeParams::upgrade_xx_height in the TryFrom<&ChainConfig> impl should be
replaced with a named constant (e.g., UPGRADE_SENTINEL or MAX_SENTINEL_EPOCH) to
clarify intent and avoid future drift; define the constant near the top of the
module (or in the crate's constants module) and use that constant in the
try_from conversion for upgrade_xx_height so all references are explicit and
easy to update.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eff58c4a-d341-4268-9bb4-ee3402754126

📥 Commits

Reviewing files that changed from the base of the PR and between 068e96a and 0b44d82.

⛔ 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
  • scripts/tests/api_compare/docker-compose.yml
  • 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
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/rpc/methods/eth.rs
  • scripts/tests/api_compare/docker-compose.yml
  • src/rpc/methods/common.rs
  • src/state_manager/utils.rs

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

1 participant