Skip to content

chanfitness: seed peer uptime from actual online state#10890

Open
erickcestari wants to merge 2 commits into
lightningnetwork:masterfrom
erickcestari:fix-offline-peer-uptime
Open

chanfitness: seed peer uptime from actual online state#10890
erickcestari wants to merge 2 commits into
lightningnetwork:masterfrom
erickcestari:fix-offline-peer-uptime

Conversation

@erickcestari

Copy link
Copy Markdown
Collaborator

Channels are loaded into the channel fitness store on startup regardless of whether their peer is connected. When a peer monitor was first created we unconditionally recorded an online event, which caused offline peers to report 100% uptime in ListChannels.

Seed the initial event with the peer's actual connection state via a new IsPeerOnline config callback so that uptime reflects real connectivity.

Closes #10417

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where channel uptime was incorrectly reported as 100% for channels whose peers were offline at startup. By introducing a mechanism to query the actual connection state of a peer when it is first tracked, the system now accurately reflects connectivity, ensuring that uptime metrics are reliable from the moment the node starts.

Highlights

  • Uptime Calculation Fix: Updated the channel fitness store to seed initial peer uptime based on actual connection state rather than defaulting to an 'online' status.
  • New Configuration Callback: Added an IsPeerOnline callback to the Config struct to allow the store to query the current connection status of a peer.
  • Test Coverage: Added a new test case TestGetChanInfoOfflinePeer to verify that channels with offline peers correctly report zero uptime upon startup.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@erickcestari erickcestari force-pushed the fix-offline-peer-uptime branch from 279f248 to 450bc1f Compare June 9, 2026 17:47

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request fixes a bug where ListChannels incorrectly reported 100% uptime for channels whose peers were offline at startup. It introduces an IsPeerOnline callback to the Config of ChannelEventStore to seed the initial online state of a peer from its actual connectivity. The review feedback highlights a potential nil pointer dereference panic if IsPeerOnline is not initialized in external tests or integrations, suggesting a fallback check to prevent this.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread chanfitness/chaneventstore.go
@github-actions github-actions Bot added the severity-critical Requires expert review - security/consensus critical label Jun 9, 2026
@saubyk saubyk added this to lnd v0.22 Jun 9, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in lnd v0.22 Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

PR Severity: CRITICAL

Highest-severity file determines classification | 3 files | 24 lines changed (excluding tests)

Critical (1 file)
  • server.go - Core server coordination (explicitly listed as CRITICAL)
Medium (1 file)
  • chanfitness/chaneventstore.go - Channel fitness/event store (chanfitness/*)
Low (1 file)
  • docs/release-notes/release-notes-0.22.0.md - Release notes documentation

Analysis

This PR is classified CRITICAL because it modifies server.go, the core server coordination file explicitly listed as CRITICAL-tier, requiring expert review.

The bulk of the changes are in chanfitness/chaneventstore.go (MEDIUM tier), with a small 4-line addition in server.go. Any modification to the core server file warrants careful expert review to ensure correctness and avoid regressions in server startup, shutdown, or component wiring.

Severity bump check: 3 non-test files (threshold: >20), 24 non-test lines changed (threshold: >500), single critical package touched - no bump applied.


To override, add a severity-override-{critical,high,medium,low} label.
<!-- pr-severity-bot -->

Channels are loaded into the channel fitness store on startup regardless
of whether their peer is connected. When a peer monitor was first
created we unconditionally recorded an online event, which caused
offline peers to report 100% uptime in ListChannels.

Seed the initial event with the peer's actual connection state via a new
IsPeerOnline config callback so that uptime reflects real connectivity.
@erickcestari erickcestari force-pushed the fix-offline-peer-uptime branch from 450bc1f to 7e070fd Compare June 9, 2026 20:11
@saubyk saubyk moved this from Backlog to In progress in lnd v0.22 Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

severity-critical Requires expert review - security/consensus critical

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

[bug]: Uptime shows 100% for inactive channels

2 participants