perf(bdk): batch and harden wallet sync tx lookups#60
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes BDK wallet sync transaction lookup behavior by batching DB lookups/miss resolution and optionally prewarming raw transaction cache for large wallets, aiming to reduce bdk.db.get_tx pressure and improve same-sync retry semantics.
Changes:
- Add a large-wallet gate to prewarm raw-tx cache before sync (based on DB tx count).
- Replace single-tx fallback lookups with batched
find_by_idsand add explicit pending “lookup” vs “miss” queues. - Harden pending-drain behavior to guarantee the requested txid is included, and allow safe requeue/retry within the same sync.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/wallet/keychain/wallet.rs | Adds pre-sync tx-count check and conditional raw-tx prewarm; includes unit test for threshold gating. |
| src/bdk/pg/transactions.rs | Adds count_active() query and removes single-row find_by_id in favor of batching. |
| src/bdk/pg/mod.rs | Exposes tx_count() and prewarm_raw_txs() on SqlxWalletDb; updates tests to use extend_txs. |
| src/bdk/pg/lookups.rs | Refactors tx lookup/miss resolution into distinct batched paths with forced inclusion and requeue semantics; adds unit test for unresolved filtering. |
| src/bdk/pg/db_traits.rs | Updates tests to use extend_txs. |
| src/bdk/pg/cache.rs | Introduces pending_tx_lookups queue and related drain/requeue helpers; splits “record missing” vs “enqueue miss”. |
| .sqlx/query-c3fc3bf10aaefb6411ef73538d7a581cde4aee4a44070b237493999ab7d52c2f.json | Adds SQLX offline metadata for COUNT(*) tx count query. |
| .sqlx/query-5256bb536a5c8b3421a642b8e4eb005975efe12df569e823b49bbd7b2688d52b.json | Removes SQLX offline metadata for the deleted find_by_id query. |
Files not reviewed (2)
- .sqlx/query-5256bb536a5c8b3421a642b8e4eb005975efe12df569e823b49bbd7b2688d52b.json: Language not supported
- .sqlx/query-c3fc3bf10aaefb6411ef73538d7a581cde4aee4a44070b237493999ab7d52c2f.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.
Files not reviewed (2)
- .sqlx/query-5256bb536a5c8b3421a642b8e4eb005975efe12df569e823b49bbd7b2688d52b.json: Language not supported
- .sqlx/query-c3fc3bf10aaefb6411ef73538d7a581cde4aee4a44070b237493999ab7d52c2f.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.
Files not reviewed (2)
- .sqlx/query-5256bb536a5c8b3421a642b8e4eb005975efe12df569e823b49bbd7b2688d52b.json: Language not supported
- .sqlx/query-c3fc3bf10aaefb6411ef73538d7a581cde4aee4a44070b237493999ab7d52c2f.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.
Files not reviewed (2)
- .sqlx/query-5256bb536a5c8b3421a642b8e4eb005975efe12df569e823b49bbd7b2688d52b.json: Language not supported
- .sqlx/query-c3fc3bf10aaefb6411ef73538d7a581cde4aee4a44070b237493999ab7d52c2f.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.
Files not reviewed (2)
- .sqlx/query-5256bb536a5c8b3421a642b8e4eb005975efe12df569e823b49bbd7b2688d52b.json: Language not supported
- .sqlx/query-c3fc3bf10aaefb6411ef73538d7a581cde4aee4a44070b237493999ab7d52c2f.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.
Files not reviewed (2)
- .sqlx/query-5256bb536a5c8b3421a642b8e4eb005975efe12df569e823b49bbd7b2688d52b.json: Language not supported
- .sqlx/query-c3fc3bf10aaefb6411ef73538d7a581cde4aee4a44070b237493999ab7d52c2f.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated no new comments.
Files not reviewed (2)
- .sqlx/query-5256bb536a5c8b3421a642b8e4eb005975efe12df569e823b49bbd7b2688d52b.json: Language not supported
- .sqlx/query-c3fc3bf10aaefb6411ef73538d7a581cde4aee4a44070b237493999ab7d52c2f.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
bdk.db.get_txdatabase pressurefind_by_idsbatching and preserve retryability for unresolved same-sync missesmiss_cachelookups can retry safely within the same sync