Skip to content

Conversation

@hxrshxz
Copy link

@hxrshxz hxrshxz commented Dec 21, 2025

Change Description

Fixes #9299. On restart, zero-conf channels that are already confirmed no longer trigger historical chain rescans from the broadcast height, reducing bandwidth usage on mobile/neutrino.

Steps to Test

  1. Open a zero-conf channel and wait for it to confirm
  2. Restart lnd
  3. Check logs - no rescan from broadcast height should occur

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

@gemini-code-assist
Copy link

Summary of Changes

Hello @hxrshxz, 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 introduces an optimization for how LND handles already-confirmed zero-confirmation channels upon restart. By intelligently using the confirmed block height as a starting point for chain rescans, it eliminates redundant data retrieval from the initial broadcast height. This change primarily benefits mobile and Neutrino users by reducing bandwidth usage and improving the overall performance and responsiveness of the client after a restart.

Highlights

  • Optimized Chain Rescans: For already-confirmed zero-confirmation channels, the system now uses the confirmed block height as a hint for chain rescans instead of the initial broadcast height.
  • Reduced Bandwidth Usage: This optimization significantly reduces the historical rescan range, which is particularly beneficial for mobile devices and Neutrino clients, leading to lower bandwidth consumption.
  • Improved Restart Performance: Upon LND restart, confirmed zero-conf channels will no longer trigger unnecessary historical chain rescans, improving the startup efficiency.

🧠 New Feature in Public Preview: You can now enable Memory 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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link

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

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 introduces an optimization to skip chain rescans for zero-conf channels that are already confirmed upon restart. This is achieved by using the confirmed block height as a hint for the chain notifier and by adding a check to skip the rescan logic if a zero-conf channel is already confirmed. The changes are logical and well-implemented. My main feedback is regarding the lack of tests to cover this new logic and prevent future regressions.

// waitForZeroConfChannel is called when the state is addedToGraph with
// a zero-conf channel. This will wait for the real confirmation, add the
// confirmed SCID to the router graph, and then announce after six confs.
func (f *Manager) waitForZeroConfChannel(c *channeldb.OpenChannel) error {

Choose a reason for hiding this comment

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

medium

While the logic to skip the rescan for already confirmed zero-conf channels is sound, this bug fix would benefit from an accompanying regression test. A test case could be added to simulate a restart where a zero-conf channel is already confirmed, and then assert that no historical rescan is triggered. This would help prevent future regressions and ensure the long-term stability of this optimization.

@yyforyongyu
Copy link
Member

Thanks.

Why are we skipping the ci here?

@hxrshxz
Copy link
Author

hxrshxz commented Dec 22, 2025

Thanks.

Why are we skipping the ci here?

Oops , mb I used copilot's "generate commit message" and didn't notice the skip ci , I will remove it from both the Title and the commit msg
thanks

@hxrshxz hxrshxz changed the title funding: skip rescan for already-confirmed zero-conf channels [skip ci] funding: skip rescan for already-confirmed zero-conf channels Dec 22, 2025
@hxrshxz hxrshxz force-pushed the reduce-zeroconf-rescan-bandwidth branch from dafe40e to 22e9ae0 Compare December 22, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature]: reduce rescan bandwidth for mobile

2 participants