Repository navigation
esplora: fetch address histories concurrently - #37
Open
albertodeluigi wants to merge 1 commit into
Open
albertodeluigi wants to merge 1 commit into
albertodeluigi wants to merge 1 commit into
Conversation
get_scripts_history_esplora walked each batch one address at a time, so the concurrency the caller sets reached only transactions and headers. A wallet's scan is mostly address histories: every used address plus the 20-address gap on each chain. For a fresh testnet web wallet that was 44 requests in strict sequence, about 7 s behind a 120 ms round trip, with concurrency set to 8 or to 1 alike. The batch now goes through the same stream as get_transactions, up to `concurrency` requests in flight. `buffered` keeps the results in address order, which get_history needs to find the last used index. With the default concurrency of 1 nothing changes.
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.
What was wrong
get_scripts_history_esplora(lwk_wollet/src/clients/asyncr/esplora.rs) walked each batch with aforloop, one address at a time. The client'sconcurrencysetting reached onlyget_transactionsandget_headers.A wallet's scan is mostly address histories: every used address plus the 20-address gap, on each chain. A fresh testnet web wallet made about 44 of these requests in strict sequence, and as many again for the covenant order-payout wallet. That is ~7 s each behind a 120 ms round trip, whether the web wallet asked for a concurrency of 1 or of 8.
What changes
The batch goes through the same stream as
get_transactions, with up toconcurrencyrequests in flight. It usesbuffered, notbuffer_unordered, so the results stay in address order, whichget_historyrelies on to find the last used index. Error handling and the paging TODO are unchanged.With the default concurrency of 1, behaviour is identical.
Verified
wasm-pack build --target web --releaseoflwk_wasmfrom this branch, on the testnet box (Rust 1.85.0, wasm-pack 0.13.1).fix/faster-sync) against the testnet indexer:Not verified
cargo testwas not run. No suite covers this path against a live esplora, and the native build was not exercised here. The esplora client tests (cargo test -p lwk_wollet --features esplora, needs the test environment) would.lwk_wolletas a path dependency. If it builds an async esplora client with concurrency above 1, its scans speed up the same way; with 1, nothing changes.