perf: bound and batch ancestor fetching - #27
Merged
Conversation
The descriptor path walked transaction ancestry with no depth limit, tracing every wallet tx back toward genesis. On mainnet this meant scans that ran for 40+ minutes without finishing. The UTXO path was bounded but fetched one transaction per HTTP round trip. - bound the wallet-history ancestor walk by max_ancestor_depth, matching the UTXO path (regression test proves the old code fetched the whole chain) - fetch each BFS frontier with JSON-RPC batch requests (100 per POST) instead of one call per transaction - add get_transactions to the gateway trait with a sequential default so mocks and tests keep working Same mainnet descriptor scan that never finished now completes in 2.5 seconds end to end, findings intact.
Production rule going forward: no unwrap. The two here were guarded by the len() >= 2 check, but let-else states that directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Descriptor scans on mainnet were pathologically slow for two stacked reasons. The wallet-history path walked transaction ancestry with no depth limit, tracing every wallet transaction back toward genesis until it hit coinbases. And every transaction in that walk cost one HTTP round trip to bitcoind.
Changes:
Measured on a real mainnet node (height 953137, txindex): the same descriptor scan with a birth timestamp that previously ran 40+ minutes without finishing now completes in 2.5 seconds, wallet unloaded cleanly, findings intact. Full suite 38/38 with clippy -D warnings clean.