Skip to content

wallet: route chain scan + rescan through the Store#1258

Open
yyforyongyu wants to merge 12 commits into
impl-runtime-store-2from
impl-runtime-store-3
Open

wallet: route chain scan + rescan through the Store#1258
yyforyongyu wants to merge 12 commits into
impl-runtime-store-2from
impl-runtime-store-3

Conversation

@yyforyongyu

Copy link
Copy Markdown
Collaborator

Routes relevant-tx notifications, filtered-block batches, scan-batch writes, unmined rebroadcast reads, and scan-data loading (addresses, account horizons, watch outputs) through the Store, with a legacy scan-data fallback. Stacked on impl-runtime-store-2.

@coveralls

coveralls commented Jun 3, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28395402981

Warning

No base build found for commit 7328715 on impl-runtime-store-2.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 56.12%

Details

  • Patch coverage: 295 uncovered changes across 7 files (596 of 891 lines covered, 66.89%).

Uncovered Changes

File Changed Covered %
wallet/internal/db/kvdb/txstore.go 157 65 41.4%
wallet/syncer.go 264 200 75.76%
wallet/internal/db/pg/txstore_batch.go 139 97 69.78%
wallet/internal/db/sqlite/txstore_batch.go 139 97 69.78%
wallet/internal/db/pg/txstore_rollback.go 66 42 63.64%
wallet/internal/db/sqlite/txstore_rollback.go 66 42 63.64%
wallet/internal/db/txstore_common.go 20 13 65.0%
Total (11 files) 891 596 66.89%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 58901
Covered Lines: 33055
Line Coverage: 56.12%
Coverage Strength: 8677.25 hits per line

💛 - Coveralls

@yyforyongyu yyforyongyu left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (deepseek-v4-pro)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR routes key chain-sync paths (relevant-tx notifications, filtered-block batches, scan batch persistence, unmined rebroadcast reads, and scan-data loading) through the runtime Store when configured, while preserving a legacy walletdb fallback for scan initialization data.

Changes:

  • Added store-backed implementations for recording relevant tx and filtered-block notifications via batched store writes.
  • Added store-backed persistence for sync/targeted scan batches and store-backed scan initialization loading (accounts, addresses, watch outputs).
  • Updated unmined rebroadcast reads to load active unmined transactions from the store, and added/expanded tests to validate the new routing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
wallet/syncer.go Adds store-backed routing for tx/block notifications, scan batch persistence, unmined rebroadcast reads, and scan initialization loading with fallback behavior.
wallet/syncer_test.go Adds tests and matchers validating store-backed routing for notifications, scan batches, scan-data loading, and unmined rebroadcast reads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wallet/syncer.go Outdated
Comment thread wallet/syncer.go Outdated
@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

LGTM 🪴 (gemini-3.5-flash)

@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

LGTM 🛰️
(claude-opus-4-8[1m])

Comment thread wallet/syncer.go Outdated
Comment thread wallet/syncer.go Outdated
@saubyk saubyk added this to lnd v0.22 Jun 3, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in lnd v0.22 Jun 3, 2026
@yyforyongyu yyforyongyu force-pushed the impl-runtime-store-2 branch from 5be4143 to afaded5 Compare June 3, 2026 14:43
@yyforyongyu yyforyongyu force-pushed the impl-runtime-store-3 branch from 3ed7628 to 04e4b28 Compare June 3, 2026 14:43
@yyforyongyu yyforyongyu force-pushed the impl-runtime-store-2 branch from afaded5 to c9e1606 Compare June 4, 2026 07:08
@yyforyongyu yyforyongyu force-pushed the impl-runtime-store-3 branch 2 times, most recently from 6c8506c to 941a49d Compare June 4, 2026 07:38

@yyforyongyu yyforyongyu left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (deepseek-v4-pro)

@yyforyongyu yyforyongyu left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (deepseek-v4-pro)

@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

LGTM 🧭
(claude-opus-4-8[1m])

@yyforyongyu yyforyongyu force-pushed the impl-runtime-store-2 branch from c9e1606 to 603075d Compare June 4, 2026 08:22
@yyforyongyu yyforyongyu force-pushed the impl-runtime-store-3 branch from 941a49d to cfe5d16 Compare June 4, 2026 08:24
Comment thread wallet/syncer.go Outdated
Comment thread wallet/syncer.go Outdated
@yyforyongyu yyforyongyu force-pushed the impl-runtime-store-2 branch from 603075d to 01e07da Compare June 5, 2026 00:09
@yyforyongyu yyforyongyu force-pushed the impl-runtime-store-3 branch from cfe5d16 to 09dbc5f Compare June 5, 2026 00:09
@yyforyongyu yyforyongyu force-pushed the impl-runtime-store-2 branch from 01e07da to 2ea1bc5 Compare June 5, 2026 12:12
Comment thread wallet/syncer.go
Comment thread wallet/syncer.go Outdated
@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

No issues found by claude-opus-4-8[1m] 🧭

Comment thread wallet/syncer.go Outdated
@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

No issues found by gpt-5.5 🦔

Comment thread wallet/syncer.go Outdated
Comment thread wallet/internal/db/interface.go
Comment thread wallet/internal/db/interface.go
@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

No issues found by claude-opus-4-8[1m] 🔄

@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

No issues found by gpt-5.5 🦎

Comment thread wallet/syncer.go
@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

No issues found by claude-opus-4-8[1m] 🏷️

@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

No issues found by claude-opus-4-8[1m]

@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

No issues found by claude-opus-4-8[1m] 🔁

Comment thread wallet/syncer.go Outdated
@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

No issues found by gpt-5.5 🦀

Comment thread wallet/internal/db/pg/txstore_batch.go
@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

No issues found by claude-opus-4-8[1m] ✂️

Pure plumbing: passes the runtime store reference and wallet ID
into the syncer. Behavior is covered by the route tests in
follow-up runtime startup, sync-tip, rollback-read, and
rollback-write commits.
Route startup account preload and expired lease cleanup through
db.Store while preserving existing mock fallback behavior for
legacy startup tests.
Route connected-block sync-tip writes through db.Store while
preserving the legacy path for syncers that are not store-wired
in existing tests.
Read synced block hashes through db.Store for rollback detection
while retaining the legacy read path for syncers without store
wiring.
Add RewindWallet to the store interface and wire the kvdb, sqlite, and postgres implementations so manual rescans can rewind one wallet without deleting shared block rows.
Add cross-backend coverage proving RewindWallet detaches only the requested wallet and leaves another wallet's transactions and sync state unchanged.
Use the wallet-scoped RewindWallet API for manual rescans, resolving height-only requests to the canonical block hash and header before recording the new sync tip.
DBPutRewind advances the live address manager's in-memory synced tip via
SetSyncedTo before txStore.Rollback inside one walletdb update. If the
rollback fails, walletdb reverts the bucket write but the in-memory tip
stays rewound to a never-persisted fork point. Snapshot the pre-rewind tip
and restore it via RestoreSyncedTo on failure, mirroring ApplyScanBatch's
synced-tip rollback. Successful rewinds are unchanged.
Use db.Store to load active unmined transactions for rebroadcast
while preserving the legacy read path for syncers without store
wiring.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants