kvdb: implement the ApplyScanBatch scan engine#1256
Conversation
Coverage Report for CI Build 28448439256Warning No base build found for commit Coverage: 55.49%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
yyforyongyu
left a comment
There was a problem hiding this comment.
LGTM (deepseek-v4-pro)
There was a problem hiding this comment.
Pull request overview
Implements additional runtime and scan-batch Store surface area for the legacy kvdb backend by adapting operations onto existing waddrmgr and wtxmgr paths, along with adding the associated request/parameter types and tests.
Changes:
- Add
kvdb.Store.ListSyncedBlocksand a shared helper for convertingdb.Blockto legacywaddrmgr.BlockStamp. - Add
kvdbimplementations for recovery/runtime UTXO helpers (ListOutputsToWatch,DeleteExpiredLeases). - Add batch-oriented tx write paths (
ApplyTxBatch,ApplyScanBatch) plusRollbackToBlock, with new unit tests and new db parameter types.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wallet/internal/db/kvdb/walletstore.go | Adds synced-block listing and a block conversion helper for legacy sync/scan paths. |
| wallet/internal/db/kvdb/walletstore_test.go | Adds unit test coverage for ListSyncedBlocks. |
| wallet/internal/db/kvdb/utxostore.go | Implements outputs-to-watch listing and expired-lease deletion via legacy wtxmgr. |
| wallet/internal/db/kvdb/utxostore_test.go | Adds tests for expired lease deletion and watch-list behavior with leased credits. |
| wallet/internal/db/kvdb/txstore.go | Implements tx/scan batch application and rollback via legacy managers. |
| wallet/internal/db/kvdb/txstore_test.go | Adds tests for tx batch, scan batch, and rollback behavior. |
| wallet/internal/db/data_types.go | Introduces query/params types for synced-block listing and batch apply operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
LGTM 🐳 ( |
|
LGTM 🧱 |
c5d47e5 to
49471d8
Compare
077faba to
0802858
Compare
49471d8 to
50a31f0
Compare
yyforyongyu
left a comment
There was a problem hiding this comment.
LGTM (deepseek-v4-pro)
yyforyongyu
left a comment
There was a problem hiding this comment.
LGTM (deepseek-v4-pro)
|
LGTM 🪨 |
0802858 to
6012ecd
Compare
50a31f0 to
1232175
Compare
6012ecd to
861974a
Compare
1232175 to
56aa683
Compare
861974a to
7adbbb2
Compare
56aa683 to
9b2ec64
Compare
7adbbb2 to
aeb6c40
Compare
9b2ec64 to
a56abdf
Compare
|
Branch hygiene: this PR was updated via merge this round rather than rebased — its range carries 2 Please rebase onto the base to drop the ( |
7e7f10b to
15cbd1a
Compare
|
No issues found by gpt-5.5 🦉 |
|
No issues found by |
|
No issues found by |
|
No issues found by gpt-5.5 🧩 |
|
No issues found by |
|
No issues found by |
|
No issues found by |
|
No issues found by gpt-5.5 🐙 |
Add the kvdb scan-horizon machinery: classifyLegacyHorizonBranch and resolveLegacyHorizonAccount validate a horizon and resolve its real account by scope-unique name, applyLegacyScanHorizons extends each branch through the legacy ExtendAddresses path and records a scanHorizonRollback range, and applyLegacySyncedBlocks connects discovered blocks.
Add ApplyScanBatch, extending horizons before recording the tx batch so freshly derived credit addresses are persisted first, then connecting discovered blocks, all in one walletdb write. On failure rollbackScanBatchCaches evicts the derived addresses, invalidates the account caches, and restores the synced tip so no rolled-back in-memory advance stays observable.
Add CanSkipCreateTxDuplicate, reporting whether a batch insert may treat an ErrTxAlreadyExists result as an idempotent no-op: only an exact current-shape duplicate (same live status and block) is skippable, while terminal history rows must not be skipped.
Refactor the sqlite ApplyTxBatch tx loop into applyBatchTransaction and canSkipBatchDuplicate so the upcoming ApplyScanBatch shares one duplicate-tolerant tx writer, treating an exact-shape duplicate as an idempotent retry via CanSkipCreateTxDuplicate.
Refactor the postgres ApplyTxBatch tx loop into applyBatchTransaction and canSkipBatchDuplicate, mirroring the sqlite shared duplicate-tolerant tx writer used by ApplyScanBatch.
Add the SQLite ApplyScanBatch, extending every reported horizon, then connecting discovered synced blocks before recording transactions (so a tx confirmed in a discovered block finds its block row), all in one write transaction via applyBatchSyncedBlocks and applyBatchTransaction.
Add the postgres ApplyScanBatch, mirroring the sqlite ordering: extend horizons, connect discovered synced blocks before recording transactions, all in one write transaction via applyBatchSyncedBlocks and applyBatchTransaction.
Expose ApplyScanBatch on the TxStore interface now that the kvdb and SQL backends implement it, and wire the mock store through to its testify expectations.
Implements the
ApplyScanBatchscan engine across kvdb and SQLite/PostgreSQLbehind the
db.Storeinterface, with the scan / tx-batch unit tests + itests andthe
RollbackToBlocksync-tip atomicity.The runtime query/batch methods and scan scaffolding this builds on were split
out into
prep-runtime-1+prep-runtime-2for reviewability. Stacked onprep-runtime-2.