withdraw: retry confirmation watching on failure and handle reorgs
メンテナーはふだん 2 日以内に返信
@kaldun-tech がすでに取り組んでいます。
2026年4月12日 から。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- go
- 領域
- backend, blockchain
調査の方向性
staticaddr/withdraw/manager.go から始め、handleWithdrawal とその呼び出し元である WithdrawDeposits、および RegisterConfirmationsNtfn と RegisterSpendNtfn の経路を読みます。コードベースの他の場所にある次のブロックで再試行する既存のパターンと、Withdrawing 状態の永続化フローを追跡します。失敗した登録が再試行され、reorgs で影響を受けた confirmations が処理され、公開済みの withdrawals が復旧可能なままとなり、pkScript が呼び出し元から渡されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Context
From PR #1078 review, @starius identified two improvements needed for the withdrawal confirmation watching code in staticaddr/withdraw/manager.go.
Current Behavior
In handleWithdrawal, when RegisterConfirmationsNtfn or RegisterSpendNtfn fails, the error is logged and the goroutine returns. There is no retry mechanism, so the withdrawal may never be detected as confirmed.
Additionally, if a withdrawal transaction receives one confirmation but is then reorged out, the current code does not handle this situation — the withdrawal stays in a confirmed state despite no longer being in the chain.
Issue 2: State persistence failure on handleWithdrawal error
From PR #1078 review, @starius identified a related issue in the same code path:
If handleWithdrawal fails (because GetStaticAddressParameters or RegisterSpendNtfn fails), the caller (WithdrawDeposits) returns the error without updating internal state or persisting the state change to Withdrawing. This is a correctness/state-tracking failure — the withdrawal tx may already be published, but the restart recovery path won't pick it up because recovery sources on Withdrawing deposits.
Recommended fix shape:
- After publish success, immediately persist/transition the withdrawal state (
FinalizedWithdrawalTx,finalizedWithdrawalTxns,Withdrawing, DB update) before callinghandleWithdrawal. - Start
handleWithdrawalas best-effort; if it fails, log + schedule retry, but do not return a user-facing error for an already-published tx.
Secondary improvement to handleWithdrawal itself:
- Stop fetching address params inside
handleWithdrawal; pass the requiredpkScriptfrom the caller. - The
pkScript(of the static address) can be calculated upfront, even before publishing, at the very beginning of FSM operation.
Proposed Changes
-
Retry on next block: If
Register*calls fail, retry at the next block detection instead of giving up. This retry-on-next-block pattern is already used in other parts of the codebase. -
Handle reorgs: If a withdrawal tx gets confirmed but is later reorged out, detect and handle this automatically (e.g., re-register for spend/confirmation notifications).
-
Decouple state persistence from handleWithdrawal: Persist the
Withdrawingstate transition immediately after successful tx publish, so that restart recovery works even ifhandleWithdrawalsubsequently fails. -
Pass pkScript from caller: Remove
GetStaticAddressParameterscall fromhandleWithdrawaland pass thepkScriptin from the caller, where it can be computed once upfront.
References
- File:
staticaddr/withdraw/manager.go, around thehandleWithdrawalfunction - PR: #1078
- 主要言語
- Go
- スター
- 593
- フォーク
- 138
- 平均マージ
- 4日 18時間
- マージ済み PR(30日)
- 20
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
lightninglabs/loop のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
lightninglabs/loop#1246 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
lightninglabs/loop#1208 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
lightninglabs/loop#1196 ·
メンテナーはふだん 2 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
lightninglabs/loop#1172 ·
メンテナーはふだん 2 日以内に返信
-
Track armed static address HTLCs after aborted swaps再び着手できるかも @hieblmi が 109 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
lightninglabs/loop#1171 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
lightninglabs/loop の issue をすべて見る
似ている issue
-
[flaky test] TestValidatorCommitterDropsEmptyStatusBatch: submits to the mock VC before its stream is registered対応中かも @liran-funaro が今日担当しました。 オープンcoordinator flaky-test race-condition testing
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
hyperledger/fabric-x-committer#876 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
garethgeorge/backrest#1426 ·
メンテナーはふだん 1 日以内に返信
-
enhancement nav-pilot
難易度 2/5 半日 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
valkey-io/valkey-operator#549 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
kind/features
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
TencentBlueKing/bk-nodemgr#3804 ·
メンテナーはふだん 1 日以内に返信