tapchannel: fix immediate force-close proof sync and sweep anchoring#2133
tapchannel: fix immediate force-close proof sync and sweep anchoring#2133GeorgeTsagk wants to merge 5 commits into
Conversation
Summary of ChangesHello, 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 improves the reliability of asset channel force-closes, particularly in scenarios where a channel is closed immediately after funding. It introduces mechanisms to re-sync proofs and re-anchor outputs correctly, while also hardening the code against potential panics during anchor resolution. These changes ensure that assets remain recoverable and spendable even under edge-case timing conditions. Highlights
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 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 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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for immediate force-closing of asset channels by adding a new test case and updating the auxiliary sweeper and commitment logic to handle the necessary proof metadata and script key synchronization. The review comment regarding the robustness of the confirmation fallback logic in waitForTransferTxConf is valid and provides an actionable improvement, so it has been retained.
| if startHeight == 0 || startHeight > currentHeight { | ||
| startHeight = currentHeight | ||
| } |
There was a problem hiding this comment.
The fallback confirmation logic might not be robust enough if no height hint is provided. If scanHeight is 0, startHeight is set to currentHeight, meaning only the current block is scanned. If the transaction was confirmed in a recent block (e.g., currentHeight - 1) and the primary notification was missed, this fallback will not find it, as scanHeight will be updated to currentHeight + 1 and the missed block will never be scanned.
To make this fallback more reliable, consider scanning a few recent blocks when no height hint is available.
if startHeight == 0 {
const rescanDepth = 6
if currentHeight > rescanDepth {
startHeight = currentHeight - rescanDepth
} else {
startHeight = 1
}
} else if startHeight > currentHeight {
startHeight = currentHeight
}69612e1 to
0a8e001
Compare
Description
This PR fixes immediate post-funding (N=0) force-close recovery by correctly re-syncing active vPacket outputs with re-anchored proofs when anchor indices are stale, and hardens anchor resolution to return explicit errors instead of panicking on out-of-range indices.
It also adds an integration test that force-closes right after funding confirmation and verifies the swept assets remain spendable via an onward transfer to a third node.
Depends on lightningnetwork/lnd#10804