Avoid re-importing all static-address tapscripts on every startup

オープン
#1,196 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
静か
技術スタック
go
領域
backend

調査の方向性

静的アドレスマネージャーの起動パス、WalletKit ListAddresses と ImportTaprootScript の呼び出し、永続化された静的アドレスの読み込み、ランタイムでのスクリプトインデックス構築を追跡します。完全にインポート済みのケース、一部が欠落しているケース、wallet が置き換えられたケースをカバーするテストを追加し、その後、永続化されたすべてのアドレスがインデックス化され、すでにインポート済みのスクリプトが再インポートされないことを検証します。

索引モデルが issue の本文から書いたものです。

説明

Problem

Multi-address static-address support causes Loop's persisted address set to grow over time: one address can be added by loop static new, each fractional loop-in, and each withdrawal that creates change.

During startup, the static-address manager currently calls ImportTaprootScript sequentially for every persisted address. On a normal restart, these are duplicate wallet write RPCs. This makes startup cost grow with the full address history, relies on matching LND's "already exists" error text, and can eventually run into the manager's initialization timeout.

Originally raised by @starius in this PR #1139 comment.

Proposed improvement

  1. Call WalletKit ListAddresses once and build a set of addresses already imported into LND.
  2. Load every persisted static-address record and derive its P2TR address locally.
  3. Call ImportTaprootScript only for addresses missing from LND.
  4. Build the in-memory script index from every persisted address, whether or not it needed importing.

The Loop database should remain the source of truth. In particular, avoid a database-only "imported" flag because it can become stale if the user replaces or restores the LND wallet. Comparing against LND on startup preserves the current repair behavior.

LND currently has no batch ImportTapscript RPC, so a wallet with all scripts missing still requires individual imports. Bounded concurrency could improve that uncommon recovery path; the longer-term solution would be an LND batch-import RPC backed by one wallet transaction.

Validation

  • Measure LND and Loop startup with 0, 100, and 1,000 persisted static addresses.
  • Cover the normal restart case where every script is already imported.
  • Cover fully and partially missing scripts, including a replaced LND wallet.
  • Verify the runtime script index contains every persisted address in all cases.
  • Verify normal restarts do not issue duplicate import RPCs.
主要言語
Go
スター
593
フォーク
137
平均マージ
2日 6時間
マージ済み PR(30日)
13

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lightninglabs/loop のほかの issue

lightninglabs/loop の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。