Skip to content

Conversation

@hieblmi
Copy link
Collaborator

@hieblmi hieblmi commented Sep 8, 2025

In this commit we remove the ticker-based polling
of new deposits as this is wasteful, and we replace
it by polling on the arrival of new blocks.

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.

Summary of Changes

Hello @hieblmi, 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 refactors the deposit polling mechanism within the static address manager to improve efficiency. By transitioning from a time-based polling system to one that reacts to new block arrivals, the system reduces unnecessary resource consumption and ensures that deposit checks are performed only when relevant updates are expected.

Highlights

  • Polling Mechanism Change: The method for polling new deposits has been updated from a continuous, ticker-based approach to an event-driven one, triggered by the arrival of new blocks.
  • Resource Optimization: This change eliminates wasteful continuous polling, leading to more efficient resource utilization by only checking for deposits when relevant blockchain events occur.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 refactors the deposit polling mechanism to trigger on new block arrivals instead of a fixed ticker, which is a good efficiency improvement. However, the implementation introduces a critical race condition by potentially running multiple deposit polling operations concurrently. My review includes a comment detailing this issue and suggests a fix to ensure safe concurrent execution.

@hieblmi
Copy link
Collaborator Author

hieblmi commented Sep 8, 2025

/gemini review

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 refactors the deposit polling mechanism from a time-based ticker to an event-driven approach, triggering a poll on each new block arrival. This is a good optimization to reduce wasteful polling. The implementation uses a semaphore to prevent concurrent polling, which is well-executed. My main feedback is to consider re-introducing an initial poll at startup to ensure timely detection of deposits that occurred while the service was offline.

@hieblmi
Copy link
Collaborator Author

hieblmi commented Sep 8, 2025

/gemini review

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 refactors the deposit polling mechanism, moving from a time-based ticker to a more efficient block-arrival trigger. The implementation is robust, introducing a pollingGate semaphore to prevent concurrent reconciliation runs, which is a great pattern for this kind of event-driven logic. The changes are clear, correct, and represent a significant improvement in efficiency by eliminating unnecessary polling cycles. The code quality is high, and I have no further suggestions for improvement.

@hieblmi
Copy link
Collaborator Author

hieblmi commented Sep 8, 2025

/gemini review

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 refactors the deposit polling mechanism to be triggered by new block arrivals instead of a time-based ticker, which is a good efficiency improvement. My review focuses on potential resource leaks related to context cancellation and improving error handling in the new polling logic. I've identified a couple of places where context.CancelFunc is not called correctly, which could lead to leaks, and I've also suggested a way to make the new error handling more robust and its API less misleading.

@hieblmi
Copy link
Collaborator Author

hieblmi commented Sep 8, 2025

/gemini review

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 refactors the deposit polling mechanism, moving from a time-based ticker to an event-driven approach that triggers on new block arrivals. This is a significant improvement as it reduces wasteful polling. The implementation correctly uses contexts with timeouts for the polling operations. My review has identified a minor grammatical issue in a code comment, for which I've provided a suggestion to improve clarity.

@hieblmi hieblmi requested review from bhandras and sputn1ck September 8, 2025 13:29
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@hieblmi hieblmi force-pushed the recon-on-block branch 2 times, most recently from 3c031ff to 8fc87a2 Compare September 8, 2025 14:10
@hieblmi
Copy link
Collaborator Author

hieblmi commented Sep 8, 2025

/gemini review

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 is a good improvement, replacing wasteful ticker-based polling for new deposits with a more efficient approach of polling upon the arrival of new blocks. The implementation correctly removes the old polling logic and integrates deposit reconciliation into the block processing flow. I have one suggestion to improve the responsiveness of new deposit discovery by reordering operations within the block handler.

Copy link
Member

@sputn1ck sputn1ck left a comment

Choose a reason for hiding this comment

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

THANK YOU!

@hieblmi hieblmi merged commit 1f8f282 into lightninglabs:master Sep 8, 2025
10 of 12 checks passed
@hieblmi hieblmi deleted the recon-on-block branch September 8, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants