fix(rpc): fix Filecoin.NodeStatus input and field#7331
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
WalkthroughThe ChangesNodeStatus RPC parameter and epoch computation
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
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Warning Review ran into problems🔥 ProblemsLinked repositories: Couldn't analyze Error: Server ErrorThe server encountered an error and could not complete your request.Please try again in 30 seconds. Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (2)
src/rpc/snapshots/forest__rpc__tests__rpc__v0.snapis excluded by!**/*.snapsrc/rpc/snapshots/forest__rpc__tests__rpc__v1.snapis excluded by!**/*.snap
📒 Files selected for processing (4)
CHANGELOG.mdsrc/cli/subcommands/info_cmd.rssrc/rpc/methods/node.rssrc/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)
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 8 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
d001e45 to
122b53c
Compare
|
@LesnyRumcajs Should we add the RPC tag here? |
akaladarshi
left a comment
There was a problem hiding this comment.
@LesnyRumcajs This is breaking change, the ChangeLog should reflect that
1b2a746 to
fb405d7
Compare
6565f28 to
7393810
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/rpc/methods/node.rs (1)
21-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: clarify the
calculate_expected_epochreuse.
calculate_expected_epoch(now_secs, head_timestamp, ...)passeshead_timestampinto thegenesis_timestampslot 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
⛔ Files ignored due to path filters (2)
src/rpc/snapshots/forest__rpc__tests__rpc__v0.snapis excluded by!**/*.snapsrc/rpc/snapshots/forest__rpc__tests__rpc__v1.snapis excluded by!**/*.snap
📒 Files selected for processing (4)
CHANGELOG.mdsrc/cli/subcommands/info_cmd.rssrc/rpc/methods/node.rssrc/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
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes #7329
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
Filecoin.NodeStatusto acceptinclChainStatusand align “behind” reporting with Lotus using epochs (with improved skew handling).inclChainStatusis enabled.Filecoin.NodeStatusJSON field casing to use Lotus-style PascalCase.#7329.