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 3 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
}4899471 to
9093b73
Compare
|
@GeorgeTsagk I had a failure in the CI run of #2130. Claude & Copilot pointed me towards this PR as the likely cause https://github.com/lightninglabs/taproot-assets/actions/runs/26522178163/job/78117493175?pr=2130 EDIT: Since this is not merged it indicates that the failure is due to flakiness, possibly fixed by sergey's PR #2060 |
Pin lnd to the close-immediately-itest-lnd-7c38 branch, which carries ResolutionReq.CommitHeight (replacing the earlier InitialKeyRing plumbing). Consumed by the tapchannel aux-sweeper update in the next commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When a channel is force-closed at commit height 0 (immediately after funding, before the channel_ready commit-point rotation), the aux resolver must use the initial commitment key ring to identify outputs and re-anchor proofs. Drive that branch off lnd's new ResolutionReq.CommitHeight: at height 0, req.KeyRing is itself the initial keyring, so the previous parallel-keyring selection logic and its activeOutputsNeedReanchor override collapse into a single isInitialCommitState helper. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9093b73 to
eb8e514
Compare
|
@GeorgeTsagk, remember to re-request review from reviewers when ready |
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