-
Notifications
You must be signed in to change notification settings - Fork 2.2k
lnwallet: persist close tx before aux finalization #10487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @jtobin, 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 resolves a potential channel-stalling bug during cooperative closes of asset channels. It reorders the transaction persistence logic to ensure that the closing transaction is always written to the database before any external broadcast attempts by auxiliary closers. This guarantees that even if an auxiliary closer fails to broadcast, the transaction is saved and can be re-broadcasted later, significantly improving the robustness and recoverability of asset channel closures. Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this 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 correctly addresses a potential race condition during the cooperative close of an assets channel, where a broadcast failure could leave the channel in a stuck state. By persisting the closing transaction before attempting to finalize the close with the auxiliary closer, the change ensures that the transaction can be rebroadcast on restart, significantly improving the robustness of the process. The inclusion of a specific test case that simulates this failure scenario is excellent and provides strong confidence in the fix. The changes are logical, well-contained, and effectively resolve the described issue.
Moves MarkCoopBroadcasted(closeTx) before aux.FinalizeClose() in the co-op close flow. This ensures the closing transaction is persisted to the database before the aux closer attempts to broadcast it. Previously, if aux.FinalizeClose failed (e.g., due to broadcast error like "min relay fee not met"), the close tx was never stored. The channel would remain marked ChanStatusCoopBroadcasted (set earlier with a nil tx) but have no tx available for re-broadcast on restart, leaving the channel stuck in the waiting_close_channels state.
Verify that MarkCoopBroadcasted is called with the close tx before aux.FinalizeClose, ensuring the tx is persisted even if the aux closer fails during broadcast.
Should resolve future cases of lightninglabs/taproot-assets#1890.
Consider a cooperative close of an assets channel. Upon receiving a ClosingSigned message, we call the aux closer's FinalizeClose() method, in practice dispatching to tapd's chain porter to broadcast the closing transaction, before marking the transaction as "broadcasted" and persisting it to the database. If the porter fails to broadcast (e.g., "min relay fee not met"), then we error out, leaving the channel marked as ChanStatusCoopBroadcasted, but having failed to persist the transaction. The result is that the channel gets stuck in the
waiting_close_channelsstate indefinitely, with no persisted transaction to rebroadcast upon restart ("no coop closing tx to re-publish").This fix moves MarkCoopBroadcasted(closeTx) before FinalizeClose() so that the closing transaction is persisted whether or not the aux closer succeeds. Regular channels were unaffected because they have no aux closer, and are persisted before being broadcast.