Skip to content

fix(esplora,electrum): treat parallel_requests/batch_size of 0 as 1 - #2360

Open
yahia008 wants to merge 2 commits into
bitcoindevkit:masterfrom
yahia008:fix/zero-parallel-requests
Open

yahia008 wants to merge 2 commits into
bitcoindevkit:masterfrom
yahia008:fix/zero-parallel-requests

Conversation

@yahia008

@yahia008 yahia008 commented Oct 9, 2026 •

Copy link
Copy Markdown

Description

Fixes #2291.

Passing parallel_requests = 0 to bdk_esplora, or batch_size = 0 to bdk_electrum, caused full_scan and sync to skip all requests and return an empty Ok. This made the wallet appear synced despite missing transactions, without indicating that the scan or sync had failed.

Notes to the reviewers

This change ensures that zero-valued request limits do not cause full_scan or sync to silently skip the requested work and return an apparently successful result.

The regression tests use an unreachable server endpoint to verify that the requested fetches are not skipped when the relevant parameter is zero. The Esplora tests cover parallel_requests = 0, while the Electrum tests cover batch_size = 0 and parallel_requests = 0, including the separate fetch loops for script pubkeys, transaction IDs, and outpoints.

Changelog notice

### Fixed

- Prevent `full_scan` and `sync` from silently skipping requests when `parallel_requests` or `batch_size` is zero in `bdk_esplora` and `bdk_electrum.

Checklists

All Submissions:

@yahia008
yahia008 requested a review from a team as a code owner October 9, 2026 14:03
A `parallel_requests` of 0 made `full_scan` and `sync` skip every request
and return an empty `Ok`, because each fetch loop takes its next batch with
`.take(parallel_requests)` and stops when the batch is empty.

Clamp it to 1 in `fetch_txs_with_keychain_spks`, `fetch_txs_with_txids` and
`fetch_txs_with_outpoints`, for both the blocking and async clients. This
matches how `stop_gap` is already handled. Document the behaviour on the
public methods and in the crate docs, and add tests for each scan path.

Fixes bitcoindevkit#2291
A `batch_size` of 0 made `full_scan` and `sync` skip every request and
return an empty `Ok`, because `populate_with_spks` builds each batch with
`(0..batch_size)` and returns when the batch is empty.

Clamp it to 1 in `populate_with_spks`, document the behaviour on the public
methods, and add tests for both scan methods.

Fixes bitcoindevkit#2291
@yahia008
yahia008 force-pushed the fix/zero-parallel-requests branch from a5aa794 to b3e6434 Compare October 9, 2026 16:08
@yahia008

yahia008 commented Oct 9, 2026

Copy link
Copy Markdown
Author

Hi! This is my first contribution to BDK, so the CI workflows are waiting for maintainer approval. Could someone approve them when you have a moment? 🙏

So far I've run these in a Codespace, and they all pass:

  • cargo test -p bdk_esplora --all-features --test blocking_ext zero_parallel_requests (4 passed)
  • cargo test -p bdk_esplora --all-features --test async_ext zero_parallel_requests (4 passed)
  • cargo test -p bdk_electrum --all-features --test test_electrum zero_batch_size (2 passed)
  • cargo +nightly fmt --all -- --check

I'm also happy to hear whether you'd prefer an error for 0 instead of clamping it to 1, as mentioned in the description. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

Zero batch size or parallel requests silently skips scans

1 participant