Skip to content

fix(rpc): fix Filecoin.NodeStatus input and field#7331

Open
LesnyRumcajs wants to merge 4 commits into
mainfrom
fix-node-status-rpc
Open

fix(rpc): fix Filecoin.NodeStatus input and field#7331
LesnyRumcajs wants to merge 4 commits into
mainfrom
fix-node-status-rpc

Conversation

@LesnyRumcajs

@LesnyRumcajs LesnyRumcajs commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary of changes

Changes introduced in this pull request:

  • fixes a discrepancy that caused a lot of failures integrating with Lotus Gateway (nothing immediately visible, but it stood out when looking into failed call metrics)
  • re-enabled tests that were left-out by mistake

Reference issue to close (if applicable)

Closes #7329

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

  • Bug Fixes
    • Updated Filecoin.NodeStatus to accept inclChainStatus and align “behind” reporting with Lotus using epochs (with improved skew handling).
    • Chain-health metrics are now included only when inclChainStatus is enabled.
    • Fixed Filecoin.NodeStatus JSON field casing to use Lotus-style PascalCase.
  • Tests
    • Expanded API parity checks and added unit coverage for epoch-behind conversion and skew tolerance/error cases.
  • Chores
    • Updated the changelog entry for Issue #7329.
    • Adjusted API comparison filtering for gateway support.

@LesnyRumcajs LesnyRumcajs requested a review from a team as a code owner July 9, 2026 14:17
@LesnyRumcajs LesnyRumcajs requested review from akaladarshi and hanabi1224 and removed request for a team July 9, 2026 14:17
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e7e13cc0-68cf-425f-9ca6-f5715cdc39bf

📥 Commits

Reviewing files that changed from the base of the PR and between 7393810 and 892ccb1.

📒 Files selected for processing (1)
  • scripts/tests/api_compare/filter-list-gateway
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)

Walkthrough

The Filecoin.NodeStatus RPC now accepts an inclChainStatus boolean parameter. Sync lag is computed in epochs, chain-status fields are conditional on the flag, JSON fields use PascalCase, and callers and tests are updated.

Changes

NodeStatus RPC parameter and epoch computation

Layer / File(s) Summary
NodeStatus contract and epoch computation
src/rpc/methods/node.rs
Adds epoch-based sync-lag calculation, validates timestamp skew, gates chain-status fields on inclChainStatus, applies PascalCase serialization, and tests the updated behavior.
Caller and API validation updates
src/cli/subcommands/info_cmd.rs, src/tool/subcommands/api_cmd/api_compare_tests.rs, scripts/tests/api_compare/filter-list-gateway, CHANGELOG.md
Passes (true,) from the CLI, tests both boolean values, updates the gateway filter, and records the revised NodeStatus behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant InfoCommand
  participant NodeStatusRPC
  participant EpochsBehindHead

  InfoCommand->>NodeStatusRPC: call((true,))
  NodeStatusRPC->>EpochsBehindHead: epochs_behind_head(head_timestamp, now_secs)
  EpochsBehindHead-->>NodeStatusRPC: epochs behind or error
  NodeStatusRPC->>NodeStatusRPC: compute chain-status fields if inclChainStatus
  NodeStatusRPC-->>InfoCommand: NodeStatusInfo
Loading

Possibly related PRs

Suggested labels: RPC

Suggested reviewers: sudo-shashank, akaladarshi

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the NodeStatus RPC fix.
Linked Issues check ✅ Passed The PR makes Filecoin.NodeStatus accept one boolean param and aligns behavior with Lotus Gateway, matching issue #7329.
Out of Scope Changes check ✅ Passed The changelog, tests, and gateway filter updates are directly tied to the NodeStatus compatibility fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-node-status-rpc
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix-node-status-rpc

Warning

Review ran into problems

🔥 Problems

Linked repositories: Couldn't analyze filecoin-project/lotus - clone failed: 2 UNKNOWN:

<title>500 Server Error</title>

Error: Server Error

The server encountered an error and could not complete your request.

Please try again in 30 seconds.


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

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/rpc/methods/node.rs`:
- Around line 21-34: `epochs_behind_head` is turning small clock skew into a
hard `ServerError`, which causes `NodeStatus` to fail; update this helper so
slight head/clock mismatches are tolerated instead of erroring. In
`src/rpc/methods/node.rs`, adjust `epochs_behind_head` to clamp
negative/small-overlap cases to `0` (or otherwise return a non-failing result)
and make sure the `NodeStatus` path that consumes it no longer propagates a
routine skew via `?`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cd92d9e0-e6d4-498c-8245-9fd388d5156a

📥 Commits

Reviewing files that changed from the base of the PR and between b4e5736 and d001e45.

⛔ 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 (4)
  • CHANGELOG.md
  • src/cli/subcommands/info_cmd.rs
  • src/rpc/methods/node.rs
  • src/tool/subcommands/api_cmd/api_compare_tests.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)

Comment thread src/rpc/methods/node.rs Outdated
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.50%. Comparing base (eaaa2dd) to head (892ccb1).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/rpc/methods/node.rs 88.00% 3 Missing ⚠️
src/cli/subcommands/info_cmd.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/cli/subcommands/info_cmd.rs 84.53% <0.00%> (ø)
src/rpc/methods/node.rs 44.00% <88.00%> (+44.00%) ⬆️

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eaaa2dd...892ccb1. 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.

@LesnyRumcajs LesnyRumcajs force-pushed the fix-node-status-rpc branch from d001e45 to 122b53c Compare July 9, 2026 15:05
@akaladarshi

Copy link
Copy Markdown
Collaborator

@LesnyRumcajs Should we add the RPC tag here?

hanabi1224
hanabi1224 previously approved these changes Jul 9, 2026

@akaladarshi akaladarshi left a comment

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.

@LesnyRumcajs This is breaking change, the ChangeLog should reflect that

Comment thread src/rpc/methods/node.rs
@LesnyRumcajs LesnyRumcajs force-pushed the fix-node-status-rpc branch from 6565f28 to 7393810 Compare July 10, 2026 15:04
@LesnyRumcajs LesnyRumcajs added the RPC requires calibnet RPC checks to run on CI label Jul 10, 2026

@coderabbitai coderabbitai Bot left a comment

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.

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

21-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: clarify the calculate_expected_epoch reuse.

calculate_expected_epoch(now_secs, head_timestamp, ...) passes head_timestamp into the genesis_timestamp slot to compute (now_secs - head_timestamp) / EPOCH. It's correct, but reusing an "expected epoch" helper as an epoch-difference is a readability trap for future maintainers. A direct expression reads more clearly and is equivalent given the guard already rules out large head-ahead skew.

♻️ Optional clarity refactor
-    Ok(calculate_expected_epoch(now_secs, head_timestamp, EPOCH_DURATION_SECONDS as u32) as u64)
+    // Head is at most one epoch ahead (guarded above), so this saturates to 0 in that case.
+    Ok(now_secs.saturating_sub(head_timestamp) / EPOCH_DURATION_SECONDS as u64)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/rpc/methods/node.rs` around lines 21 - 27, Clarify epochs_behind_head by
replacing the calculate_expected_epoch(now_secs, head_timestamp, ...) reuse with
a direct epoch-difference expression using now_secs, head_timestamp, and
EPOCH_DURATION_SECONDS, while preserving the existing ensure! guard and return
type.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/rpc/methods/node.rs`:
- Around line 21-27: Clarify epochs_behind_head by replacing the
calculate_expected_epoch(now_secs, head_timestamp, ...) reuse with a direct
epoch-difference expression using now_secs, head_timestamp, and
EPOCH_DURATION_SECONDS, while preserving the existing ensure! guard and return
type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 379a1b1b-d7f3-4d5a-a47a-526cc3633247

📥 Commits

Reviewing files that changed from the base of the PR and between fb405d7 and 7393810.

⛔ 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 (4)
  • CHANGELOG.md
  • src/cli/subcommands/info_cmd.rs
  • src/rpc/methods/node.rs
  • src/tool/subcommands/api_cmd/api_compare_tests.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)
✅ Files skipped from review due to trivial changes (2)
  • src/cli/subcommands/info_cmd.rs
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tool/subcommands/api_cmd/api_compare_tests.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.

Filecoin.NodeStatus discrepancy

3 participants