wallet: parallel fast rescan #34400

pull Eunovo wants to merge 7 commits into bitcoin:master from Eunovo:new-rescan changing 8 files +776 −178
  1. Eunovo commented at 7:46 PM on January 24, 2026: contributor

    This PR speeds up wallet fast-rescan by executing the filter checks in parallel while ensuring that the filters are updated properly so that no output scripts are missed. Benchmarks, outlined below, show considerable improvement that slows down around 8 threads.

    Prerequisite PRs

    • #34667 - modify the fast-rescan test to ensure that it fails when the filter is not updated properly.
    • #34681 - refactor CWallet::ScanForWalletTransactions to prepare for the work in this PR.

    Benchmarks

    Prepare

    • Please tune your system with pyperf system tune.
    • Enable block filters by setting blockfilterindex=1 in your bitcoin.conf file and sync your node to the tip.
    • Parallel fast-rescan will not be used if chain.isInitialBlockDownload() is true. Ensure your node is synced before shutting down and running the mainnet benchmark commands.

    Using the following command on mainnet with a wallet with no scripts and hyperfine version 1.20.0:

    • On master
    hyperfine --show-output --export-markdown master.md --export-json master.json  \
    --sort command \
    --runs 3 \
    --prepare 'cmake --build build -j 20 && build/bin/bitcoind -blockfilterindex=1 -networkactive=0 && sleep 10 && build/bin/bitcoin-cli loadwalllet <wallet-name>' \
    --conclude 'build/bin/bitcoin-cli stop && sleep 10' \
    'build/bin/bitcoin-cli rescanblockchain 700000 900000'
    
    • On this PR:
    hyperfine --show-output --export-markdown results.md --export-json results.json  \
    --sort command \
    --runs 3 \
    -L num_threads 1,2,3,4,5,6,7,8,9,16 \
    --prepare 'cmake --build build -j 20 && build/bin/bitcoind -blockfilterindex=1 -networkactive=0 -walletpar={num_threads} && sleep 10 && build/bin/bitcoin-cli loadwalllet <wallet-name>' \
    --conclude 'build/bin/bitcoin-cli stop && sleep 10' \
    'build/bin/bitcoin-cli rescanblockchain 700000 900000'
    

    <details> <summary>Table 1 was obtained on a machine with the following specifications</summary>

    Architecture:             x86_64
      CPU op-mode(s):         32-bit, 64-bit
      Address sizes:          46 bits physical, 48 bits virtual
      Byte Order:             Little Endian
    CPU(s):                   20
      On-line CPU(s) list:    0-19
    Vendor ID:                GenuineIntel
      Model name:             Intel(R) Core(TM) Ultra 7 265
        CPU family:           6
        Model:                198
        Thread(s) per core:   1
        Core(s) per socket:   1
        Socket(s):            20
        Stepping:             2
        CPU(s) scaling MHz:   41%
        CPU max MHz:          4800.0000
        CPU min MHz:          800.0000
        BogoMIPS:             4761.60
    

    </details>

    Branch Mean [s] Min [s] Max [s]
    master 272.222 ± 0.183 272.064 272.423
    new-rescan (num_threads = 1) 274.423 ± 0.515 273.831 274.771
    new-rescan (num_threads = 2) 137.240 ± 0.210 137.111 137.483
    new-rescan (num_threads = 4) 70.159 ± 0.172 69.998 70.340
    new-rescan (num_threads = 6) 48.351 ± 0.051 48.319 48.411
    new-rescan (num_threads = 8) 37.955 ± 0.084 37.884 38.048
    new-rescan (num_threads = 10) 33.271 ± 0.028 33.240 33.295
    new-rescan (num_threads = 16) 25.295 ± 0.015 25.284 25.312

    Table 1. Table of results of a mainnet benchmark of scanning 200,000 blocks on a wallet with no scripts. An empty wallet is not representative of a typical wallet; the next benchmark tries to simulate more "interesting" scenarios.

    This Python script patch python script creates custom chains designed with payments at specified intervals to observe the performance of parallel fast rescan.

    <details> <summary> Fig 1 shown below was produced using this patch on a machine with the following specifications</summary>

    Architecture:                x86_64
      CPU op-mode(s):            32-bit, 64-bit
      Address sizes:             48 bits physical, 48 bits virtual
      Byte Order:                Little Endian
    CPU(s):                      16
      On-line CPU(s) list:       0-15
    Vendor ID:                   AuthenticAMD
      Model name:                AMD Ryzen 9 8945HS w/ Radeon 780M Graphics
        CPU family:              25
        Model:                   117
        Thread(s) per core:      2
        Core(s) per socket:      8
        Socket(s):               1
        Stepping:                2
        Frequency boost:         enabled
        CPU(s) scaling MHz:      63%
        CPU max MHz:             5263.0000
        CPU min MHz:             400.0000
    

    </details>

    <img width="2840" height="1639" alt="benchmark_comparison" src="https://github.com/user-attachments/assets/cef4e57b-7727-4a0d-87fd-dbd7d6995747" />

    Fig 1. Time to scan a 2000-block chain on Regtest with payments at varying intervals, comparing parallel Fast Rescan against serial Fast Rescan (baseline). These benchmarks use the -walletpar commit as a baseline instead of master, since master lacks the -walletpar config parameter. All materials for this custom benchmark are available here.

  2. DrahtBot commented at 7:46 PM on January 24, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    Concept ACK w0xlt, ismaelsadeeq, rkrux, polespinasa

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36904 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36904.svg"></sub> (log: Remove trailing and embedded newlines from log messages by maflcko)
    • #32857 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32857.svg"></sub> (wallet: allow skipping script paths by Sjors)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

    LLM Linter (✨ experimental)

    Possible typos and grammar issues:

    • src/wallet/scan.cpp: and to added if given → and to \added` if given` [the sentence is grammatically broken]

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • src/wallet/test/rescan_tests.cpp (resume-after-tip test): MakeIndex<BlockFilterIndex>(interfaces::MakeChain(m_node), BlockFilterType::BASIC, 1_MiB, /*f_memory=*/true)
    • src/wallet/test/rescan_tests.cpp (attach-chain test): MakeIndex<BlockFilterIndex>(interfaces::MakeChain(m_node), BlockFilterType::BASIC, 1_MiB, /*f_memory=*/true)
    • src/wallet/test/rescan_tests.cpp (parallel-rescan test): MakeIndex<BlockFilterIndex>(interfaces::MakeChain(m_node), BlockFilterType::BASIC, 1_MiB, /*f_memory=*/true)

    <sup>2026-11-24 10:51:12</sup>

  3. DrahtBot added the label CI failed on Jan 24, 2026
  4. DrahtBot commented at 8:44 PM on January 24, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task test max 6 ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/21320629356/job/61369934184</sub> <sub>LLM reason (✨ experimental): Compilation failed due to an unused private member (m_thread_pool) in wallet.h being treated as an error under -Werror.</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  5. Eunovo force-pushed on Jan 25, 2026
  6. DrahtBot removed the label CI failed on Jan 25, 2026
  7. Eunovo renamed this:
    Parallel Fast Rescan (approx 5x speed up with 16 threads)
    wallet: parallel fast rescan (approx 5x speed up with 16 threads)
    on Jan 27, 2026
  8. DrahtBot added the label Wallet on Jan 27, 2026
  9. luke-jr commented at 4:50 AM on January 29, 2026: contributor

    I would have expected rescanning to be I/O bound rather than CPU, in which case parallelization could make things worse (more random seeking). Have you benchmarked this on a non-SSD?

  10. Eunovo commented at 8:42 AM on January 29, 2026: contributor

    I would have expected rescanning to be I/O bound rather than CPU, in which case parallelization could make things worse (more random seeking). Have you benchmarked this on a non-SSD?

    Fast rescan checks block filters, which involves considerable hashing. This PR parallelises the checking of block filters, and my benchmarks show considerable improvements in rescan speeds with block filters. Slow rescan, which is I/O bound, remains the same. I expect the speedup to be transferable to non-SSD machines, but I haven't benchmarked this.

  11. DrahtBot added the label Needs rebase on Feb 4, 2026
  12. in src/wallet/scan.cpp:203 in ef847e8bce outdated
     198 | +        // If m_max_blockqueue_size blocks have been filtered,
     199 | +        // stop reading more blocks for now, to give the
     200 | +        // main scanning loop a chance to update progress
     201 | +        // and erase some blocks from the queue.
     202 | +        if (m_continue && completed < m_max_blockqueue_size) m_continue = ReadBlockHash(result);
     203 | +        else if (!futures.empty()) thread_pool->ProcessTask();
    


    bvbfan commented at 8:59 AM on February 8, 2026:

    This slows down the scanning no? All workers already process submit task in its own WorkThread just randomly trying to acquire mutex from scanning thread is non sense to me.


    Eunovo commented at 11:40 AM on February 8, 2026:

    Are you referring to the ThreadPool::m_mutex? This mutex is not held during task processing. It is only briefly held to access the work queue. Calling ProcessTask() from the main thread does not slow down scanning; it gives the main thread work to do instead of wasting cycles waiting for results.


    bvbfan commented at 6:29 PM on February 9, 2026:

    Yep it's not held during task execution, but if main thread do a task, it cannot put new tasks to queue i.e. workers "fight" itself to read something and do nothing. The idea is main thread submit tasks faster than workers could finish to keep all of them busy otherwise there is no difference between 3 and 16 thread (~13 threads do nothing).


    Eunovo commented at 9:34 AM on February 10, 2026:

    The main thread intentionally submits only up to WORKERS_COUNT tasks before waiting, rather than continuously submitting. This allows it to pause and update filters whenever a payment is found, preventing unnecessary work on wallets with many transactions packed into a short block range.


    Eunovo commented at 12:59 PM on April 14, 2026:

    I have changed the implementation so that the main thread only joins task processing when it needs to clear the work queue (after a range of blocks to fetch and scan has been determined) before processing blocks. The number of blocks that can be submitted at once has been raised to 2 * WORKERS_COUNT, it is still kept low intentionally to reduce wasted work.

  13. Eunovo force-pushed on Feb 8, 2026
  14. DrahtBot removed the label Needs rebase on Feb 8, 2026
  15. Eunovo force-pushed on Feb 11, 2026
  16. Eunovo commented at 5:20 PM on February 11, 2026: contributor

    #33689 has been merged; the cherry-picked Threadpool commit has been removed.

  17. furszy commented at 8:43 PM on February 11, 2026: member

    I like the PR conceptually but I think it would be nice to first improve the current scanning code structure, then land the parallelization feature. The current code mixes a lot responsibilities. Similar to what you did in 633531614f69de49733642fd19cc9eba830fbdea, but into a separate PR so we can first land some good building blocks for this to happen.

    Some quick pseudo-code structuring how I imagine it, which is similar to yours:

    Scan(wallet, start_block_hash, end_block_hash, fn_filter_block, fn_process_block, interrupt) {
         it_current_hash = start_block_hash;
    
         while (it_current_hash != end_block_hash || interrupt) {
             // Skip block if needed (this function contains the BlockFilterIndex check if enabled)
             if (fn_filter_block(it_current_hash)) continue;
        
             // (this is more or less how we currently do it, we fetch the block and the next block hash at the same time)
             block = chain.find_block(it_current_hash).next_block(it_current_hash);
        
             // (inside this function the wallet will digest the block update the filter and save progress if needed)
             fn_process_block(block);
          }
    }
    
  18. w0xlt commented at 8:12 AM on February 21, 2026: contributor

    Concept ACK

  19. Eunovo force-pushed on Feb 26, 2026
  20. Eunovo commented at 4:21 PM on February 26, 2026: contributor

    I like the PR conceptually but I think it would be nice to first improve the current scanning code structure, then land the parallelization feature. The current code mixes a lot responsibilities. Similar to what you did in 6335316, but into a separate PR so we can first land some good building blocks for this to happen.

    I moved the test change into #34667 and the ScanForWalletTransactions refactor into #34681. I'll be putting this PR in draft while those PRs are open.

  21. Eunovo marked this as a draft on Feb 26, 2026
  22. ismaelsadeeq commented at 2:34 PM on March 13, 2026: member

    Concept ACK

    I attempted to reproduce the benchmarks for this But I did not use hyperfine, I used time

    System: AMD Ryzen 7 7700, 16 cores, 64GB RAM, mainnet, blocks 500000–900000, 3 runs averaged.

    Baseline (881ebc4730ad15bd26e3e32ee3c9ba9d6e05552d): single-threaded fast rescan, -walletpar has no effect — consistently ~283s regardless of thread count.

    Parallel scan (48154b87e2fb303ca0f3d46da29a3fbbf8758a06): fast rescan with threadpool parallelism enabled via -walletpar.

    num_threads baseline parallel speedup
    1 282.618s 288.214s 0.98x (slight overhead)
    2 282.618s 187.485s 1.51x
    4 282.618s 119.575s 2.37x
    8 282.618s 81.565s 3.47x
    16 282.618s 62.965s 4.53x
    • Speedup scales well up to 16 threads, going from ~283s down to ~63s — a 4.5x improvement.
    • Results are very consistent across runs (low variance), because the machine is bare metal and no other running processes apart from bitcoind are present during the benchmark runs.

    Steps to reproduce

    1. Restart bitcoind with -blockfilterindex=1 till it's done.
    2. create a new wallet test
    3. Stop the node
    4. Save the script below as bench_script.sh

    <details> <summary>script</summary>

    #!/usr/bin/env bash
    set -euo pipefail
    
    COMMITS=(881ebc4730ad15bd26e3e32ee3c9ba9d6e05552d 48154b87e2fb303ca0f3d46da29a3fbbf8758a06)
    THREADS=(1 2 4 8 16)
    RUNS=3
    WALLET_NAME="test"
    DATADIR="$HOME/.bitcoin"
    RESULTS_CSV="results.csv"
    RESULTS_MD="results.md"
    
    echo "commit,num_threads,run,seconds" > "$RESULTS_CSV"
    
    for commit in "${COMMITS[@]}"; do
      short="${commit:0:7}"
      git checkout "$commit"
      cmake --build build -j 20
    
      for num_threads in "${THREADS[@]}"; do
        echo "=== commit=$short num_threads=$num_threads ==="
    
        for run in $(seq 1 $RUNS); do
          echo "  run $run/$RUNS"
    
          # start node
          build/bin/bitcoind -blockfilterindex=1 -walletpar="$num_threads" -daemonwait
          build/bin/bitcoin-cli loadwallet "$WALLET_NAME"
    
          build/bin/bitcoin-cli rescanblockchain 500000 900000
    
          # parse timing from debug log: "Rescan completed in 284737ms"
          ms=$(grep "Rescan completed in" "$DATADIR/debug.log" | tail -1 | grep -oP '\d+(?=ms)')
          seconds=$(python3 -c "print(f'{$ms / 1000:.3f}')")
    
          echo "$short,$num_threads,$run,$seconds" >> "$RESULTS_CSV"
          echo "  -> ${seconds}s"
    
          build/bin/bitcoin-cli stop
          # wait for clean shutdown
          while build/bin/bitcoin-cli ping 2>/dev/null; do sleep 1; done
          sleep 5
        done
      done
    done
    
    # markdown table with averages
    python3 - "$RESULTS_CSV" "$RESULTS_MD" <<'EOF'
    import sys, csv
    from collections import defaultdict
    
    infile, outfile = sys.argv[1], sys.argv[2]
    
    rows = list(csv.DictReader(open(infile)))
    groups = defaultdict(list)
    for r in rows:
        groups[(r['commit'], r['num_threads'])].append(float(r['seconds']))
    
    with open(outfile, 'w') as f:
        f.write("| commit | num_threads | run1 | run2 | run3 | mean |\n")
        f.write("|--------|-------------|------|------|------|------|\n")
        for (commit, threads), times in sorted(groups.items()):
            mean = sum(times) / len(times)
            runs = " | ".join(f"{t:.3f}" for t in times)
            f.write(f"| {commit} | {threads} | {runs} | {mean:.3f} |\n")
    
    print(f"Written {outfile}")
    EOF
    
    echo "Done. Results in $RESULTS_CSV and $RESULTS_MD"
    

    </details>

    1. Make the script executable chmod +x bench_script.sh
    2. Execute the script ./bench_script.sh
    3. You can go a step further by using a top like btop https://github.com/aristocratos/btop to monitor the resource usage and how it will be well utilized when rescanning in parallel.

    The current steps to reproduce in the description are stale because the commit hashes have changed since your force pushes.

  23. in src/wallet/scan.cpp:191 in 48154b87e2
     195 | +        // Submit jobs to the threadpool in batches of at most `workers_count` size.
     196 | +        // This prevents over-submission: if we queued all jobs upfront and the filtered
     197 | +        // block range is smaller than expected, worker threads would process blocks
     198 | +        // that get discarded, wasting CPU cycles.
     199 | +        const size_t job_gap = workers_count - futures.size();
     200 | +        if (job_gap > 0 && i < m_blocks.size()) {
    


    rkrux commented at 2:03 PM on March 16, 2026:

    In 48154b87e2fb303ca0f3d46da29a3fbbf8758a06 "wallet: check blockfilters in parallel"

    These two conditions in this check seem redundant with the same two conditions in the following for loop.


    Eunovo commented at 1:43 PM on March 18, 2026:

    Fixed.

  24. in src/wallet/scan.cpp:194 in 48154b87e2
     198 | +        // that get discarded, wasting CPU cycles.
     199 | +        const size_t job_gap = workers_count - futures.size();
     200 | +        if (job_gap > 0 && i < m_blocks.size()) {
     201 | +            for (size_t j = 0; j < job_gap && i < m_blocks.size(); ++j, ++i) {
     202 | +                auto block = m_blocks[i];
     203 | +                futures.emplace_back(*thread_pool->Submit([&filter, block = std::move(block)]() {
    


    rkrux commented at 2:08 PM on March 16, 2026:

    In 48154b87e2fb303ca0f3d46da29a3fbbf8758a06 "wallet: check blockfilters in parallel"

    So it appears this is a flow where multiple tasks can be submitted in one go. There is an overload method of Submit that accepts a range of tasks & pushes all of them in the queue within one acquisition of queue lock, while notifying all the waiting workers. I think this workflow can be benefitted with this method, an untested code snippet is below because this branch is not rebased over master that contains the ranged overload.

    https://github.com/bitcoin/bitcoin/blob/ff7cdf633e375f151cccbcc78c7add161b3d29b8/src/util/threadpool.h#L199-L220

    diff --git a/src/wallet/scan.cpp b/src/wallet/scan.cpp
    index 6b776930f1..2295a242a1 100644
    --- a/src/wallet/scan.cpp
    +++ b/src/wallet/scan.cpp
    @@ -147,6 +147,20 @@ std::optional<std::pair<size_t, size_t>> ChainScanner::ReadNextBlocks(const std:
             return std::make_pair<size_t, size_t>(0, m_blocks.size());
         }
         filter->UpdateIfNeeded();
    +
    +    auto block_matcher = [&filter](uint256 block_hash) {
    +        const auto matches_block{filter->MatchesBlock(block_hash)};
    +        if (matches_block.has_value()) {
    +            if (*matches_block) {
    +                return FilterRes::FILTER_MATCH;
    +            } else {
    +                return FilterRes::FILTER_NO_MATCH;
    +            }
    +        } else {
    +            return FilterRes::FILTER_NO_FILTER;
    +        }
    +    }
    +
         auto* thread_pool = m_wallet.m_thread_pool;
         // ThreadPool pointer should never be null here
         // during normal operation because it should
    @@ -187,23 +201,13 @@ std::optional<std::pair<size_t, size_t>> ChainScanner::ReadNextBlocks(const std:
             // This prevents over-submission: if we queued all jobs upfront and the filtered
             // block range is smaller than expected, worker threads would process blocks
             // that get discarded, wasting CPU cycles.
    -        const size_t job_gap = workers_count - futures.size();
    -        if (job_gap > 0 && i < m_blocks.size()) {
    -            for (size_t j = 0; j < job_gap && i < m_blocks.size(); ++j, ++i) {
    -                auto block = m_blocks[i];
    -                futures.emplace_back(*thread_pool->Submit([&filter, block = std::move(block)]() {
    -                    const auto matches_block{filter->MatchesBlock(block.first)};
    -                    if (matches_block.has_value()) {
    -                        if (*matches_block) {
    -                            return FilterRes::FILTER_MATCH;
    -                        } else {
    -                            return FilterRes::FILTER_NO_MATCH;
    -                        }
    -                    } else {
    -                        return FilterRes::FILTER_NO_FILTER;
    -                    }
    -                }));
    +        auto to_submit_jobs_count = std::min(workers_count - futures.size(), m_blocks - i);
    +        if (to_submit_jobs_count) {
    +            std::vector<std::function<FilterRes(uint256)>> block_matchers;
    +            for (; i < to_submit_jobs_count; ++i) {
    +                block_matchers.emplace_back(block_matcher(m_blocks[i].first));
                 }
    +            futures.emplace_back(*thread_pool->Submit(std::move(block_matchers)));
             }
     
             // If m_max_blockqueue_size blocks have been filtered,
    
    

    Eunovo commented at 12:18 PM on March 18, 2026:

    I will check this when I rebase on master.


    Eunovo commented at 12:50 PM on April 14, 2026:

    Done.

  25. in src/wallet/scan.cpp:220 in 48154b87e2 outdated
     224 | +            if (next_block) m_blocks.emplace_back(*next_block);
     225 | +        }
     226 | +        else if (!futures.empty()) {
     227 | +            // Join work processing instead of waiting idly.
     228 | +            thread_pool->ProcessTask();
     229 | +        }
    


    rkrux commented at 2:19 PM on March 16, 2026:

    In 48154b8 "wallet: check blockfilters in parallel"

    I'm doubtful that putting the controller (non-worker) thread to process the threadpool tasks is helpful.

    This threadpool is shared across wallets. It could be the case that multiple RPCs of different wallets could be called simultaneously. ProcessTask picks the first item from a shared queue in the threadpool. Can't it happen that this controller thread picks up the task of another RPC of another wallet, thereby distorting results (from a RPC latency point of view) of this one?


    Eunovo commented at 12:05 PM on March 18, 2026:

    I'm doubtful that putting the controller (non-worker) thread to process the threadpool tasks is helpful.

    It is helpful. I had better results when I put the thread to work vs when I didn't.

    Can't it happen that this controller thread picks up the task of another RPC of another wallet, thereby distorting results (from a RPC latency point of view) of this one?

    True, this creates an argument to ditch the shared threadpool and create one at the begining of the scan process; the same way we initialise script threads in ConnectBlock


    rkrux commented at 12:16 PM on March 18, 2026:

    I was doubtful of the helpfulness of using processtask because of this cross-wallet/rpc operation.

    this creates an argument to ditch the shared threadpool and create one at the begining of the scan process

    Interesting, I had thought of not using the processtask function in the current thread pool setup as a way. But an intra-wallet scan operation specific threadpool seems like a good alternative to consider. I wll think of its implications.


    Eunovo commented at 12:54 PM on April 14, 2026:

    I have changed the implementation substantially. I have moved away from a shared ThreadPool to one that is initialized before scanning and discarded after.

    ProcessTask() is now only used when the main thread needs to complete the queued up jobs before the processing the selected blocks.

  26. in src/wallet/scan.cpp:183 in 48154b87e2
     187 | +            }
     188 |  
     189 | -    const auto& [block_hash, block_height] = m_blocks[0];
     190 | -    auto matches_block{filter->MatchesBlock(block_hash)};
     191 | +            if (!range.has_value()) range = std::make_pair(current_block_index, current_block_index + 1);
     192 | +            else range->second = current_block_index + 1;
    


    rkrux commented at 2:57 PM on March 16, 2026:

    In 48154b8 "wallet: check blockfilters in parallel"

    It appears that current_block_index + 1 is equal to completed due to a int current_block_index = completed - 1; above.


    Eunovo commented at 1:43 PM on March 18, 2026:

    Fixed.

  27. rkrux commented at 3:05 PM on March 16, 2026: contributor

    I've looked only at the 48154b8 "wallet: check blockfilters in parallel" commit partially.

  28. Eunovo force-pushed on Mar 18, 2026
  29. achow101 referenced this in commit 696b5457c5 on Mar 24, 2026
  30. DrahtBot added the label Needs rebase on Mar 24, 2026
  31. Eunovo force-pushed on Apr 6, 2026
  32. DrahtBot removed the label Needs rebase on Apr 6, 2026
  33. DrahtBot added the label CI failed on Apr 6, 2026
  34. Eunovo force-pushed on Apr 12, 2026
  35. Eunovo force-pushed on Apr 12, 2026
  36. Eunovo force-pushed on Apr 12, 2026
  37. Eunovo force-pushed on Apr 12, 2026
  38. Eunovo renamed this:
    wallet: parallel fast rescan (approx 5x speed up with 16 threads)
    wallet: parallel fast rescan (approx 5x speed up with 8 threads)
    on Apr 13, 2026
  39. Eunovo force-pushed on Apr 14, 2026
  40. DrahtBot removed the label CI failed on Apr 14, 2026
  41. l0rinc commented at 3:38 PM on April 20, 2026: contributor

    I have measured it on an Intel(R) Core(TM) i7-7700 CPU with 8 cores, 64Gi RAM and a HDD:

    hyperfine --show-output \     
    --export-markdown pr34400-results.md \     
    --export-json pr34400-results.json \     
    --sort command \      
    --runs 3 \     
    -L commit 68f030eef7b14d5ac6372a12864a813317ae0f4f,b62e9e739113fe58a86d23a00f8e9b1b561cd29f \     
    -L num_threads 1,2,3,4,5,6,7,8,9,16 \     
    --prepare 'git checkout -q {commit} && cmake -S . -B build && cmake --build build --parallel "$(nproc)" && build/bin/bitcoind -daemonwait -datadir=/mnt/my_storage/BitcoinData -connect=0 -listen=0 -dnsseed=0 -blockfilterindex=1 -wallet=bench_pr34400_20260416 -walletpar={num_threads} && build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 getwalletinfo > /dev/null' \     
    --conclude 'build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData stop && sleep 10' \
    'rescanblockchain 500000 900000'
    

    <img width="2084" height="740" alt="image" src="https://github.com/user-attachments/assets/968632a3-cdc4-478f-b1e3-f908a1d862b4" />

    Command Mean [s] Min [s] Max [s] Relative
    rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 1) 572.300 ± 64.726 534.060 647.032 3.42 ± 0.39
    rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 1) 545.611 ± 14.138 536.478 561.897 3.26 ± 0.10
    rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 2) 534.545 ± 0.569 534.055 535.168 3.20 ± 0.05
    rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 2) 303.284 ± 6.724 299.207 311.045 1.81 ± 0.05
    rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 3) 534.895 ± 0.740 534.298 535.723 3.20 ± 0.05
    rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 3) 222.130 ± 4.551 216.878 224.899 1.33 ± 0.03
    rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 4) 534.069 ± 0.546 533.447 534.473 3.19 ± 0.05
    rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 4) 200.326 ± 2.305 197.771 202.248 1.20 ± 0.02
    rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 5) 534.699 ± 0.582 534.047 535.167 3.20 ± 0.05
    rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 5) 186.884 ± 4.476 182.887 191.720 1.12 ± 0.03
    rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 6) 535.054 ± 0.270 534.819 535.349 3.20 ± 0.05
    rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 6) 175.091 ± 0.531 174.640 175.677 1.05 ± 0.02
    rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 7) 534.670 ± 1.045 533.600 535.688 3.20 ± 0.05
    rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 7) 167.224 ± 2.574 165.724 170.196 1.00
    rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 8) 535.010 ± 0.121 534.875 535.105 3.20 ± 0.05
    rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 8) 172.263 ± 1.808 171.188 174.350 1.03 ± 0.02
    rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 9) 535.058 ± 0.383 534.660 535.425 3.20 ± 0.05
    rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 9) 171.178 ± 0.138 171.053 171.326 1.02 ± 0.02
    rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 16) 535.238 ± 0.204 535.013 535.412 3.20 ± 0.05
    rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 16) 172.619 ± 2.656 171.043 175.685 1.03 ± 0.02

    <details><summary>Hyperfine relative speed comparison</summary>

    3.42 ±  0.39  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 1)
    3.26 ±  0.10  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 1)
    3.20 ±  0.05  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 2)
    1.81 ±  0.05  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 2)
    3.20 ±  0.05  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 3)
    1.33 ±  0.03  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 3)
    3.19 ±  0.05  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 4)
    1.20 ±  0.02  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 4)
    3.20 ±  0.05  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 5)
    1.12 ±  0.03  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 5)
    3.20 ±  0.05  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 6)
    1.05 ±  0.02  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 6)
    3.20 ±  0.05  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 7)
    1.00          build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 7)
    3.20 ±  0.05  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 8)
    1.03 ±  0.02  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 8)
    3.20 ±  0.05  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 9)
    1.02 ±  0.02  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 9)
    3.20 ±  0.05  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = 68f030eef7b14d5ac6372a12864a813317ae0f4f, num_threads = 16)
    1.03 ±  0.02  build/bin/bitcoin-cli -rpcwait -datadir=/mnt/my_storage/BitcoinData -rpcwallet=bench_pr34400_20260416 rescanblockchain 500000 900000 (commit = b62e9e739113fe58a86d23a00f8e9b1b561cd29f, num_threads = 16)
    

    </details>

  42. DrahtBot added the label Needs rebase on May 13, 2026
  43. Kino1994 referenced this in commit f58aed3421 on Jun 28, 2026
  44. BigcoinBGC referenced this in commit 6d61c51229 on Jun 30, 2026
  45. Eunovo force-pushed on Jul 14, 2026
  46. DrahtBot added the label CI failed on Jul 14, 2026
  47. DrahtBot removed the label Needs rebase on Jul 14, 2026
  48. Eunovo force-pushed on Jul 14, 2026
  49. DrahtBot removed the label CI failed on Jul 14, 2026
  50. Eunovo renamed this:
    wallet: parallel fast rescan (approx 5x speed up with 8 threads)
    wallet: parallel fast rescan (approx 8x speed up with 8 threads)
    on Jul 15, 2026
  51. Eunovo commented at 6:43 PM on July 15, 2026: contributor

    I've made some improvements which have increased the speedup from 5x at 8 threads to 8x at 8 threads. 8x speedup seems to be the peak for now. The results have been updated in the PR description, #34400#issue-3851923967

  52. Eunovo force-pushed on Jul 21, 2026
  53. Eunovo force-pushed on Jul 21, 2026
  54. ismaelsadeeq commented at 12:53 PM on July 22, 2026: member

    I re-ran my script with the recent changes.

    Rescan of blocks 500000-900000 (mean of 3 runs).

    commit threads run1 run2 run3 mean (s) speedup
    b36c2d7 (master) 1 282.488 279.832 280.120 280.813 1.00×
    bf45a67 1 282.495 280.959 280.725 281.393 1.00×
    bf45a67 2 139.017 138.740 137.590 138.449 2.03×
    bf45a67 4 73.558 72.770 73.283 73.204 3.84×
    bf45a67 8 42.863 43.172 42.746 42.927 6.54×
    bf45a67 16 42.481 42.943 42.425 42.616 6.59×

    I got a 6× speedup relative to master.

  55. Eunovo force-pushed on Jul 22, 2026
  56. DrahtBot added the label Needs rebase on Aug 14, 2026
  57. Kino1994 referenced this in commit adade16423 on Aug 19, 2026
  58. rkrux commented at 2:44 PM on August 26, 2026: contributor

    Strong Concept ACK ae888e0, forgot to share it in the prior review.

    I will get around to re-reviewing the prerequisite #34681 so that this can be moved forward.

  59. sedited referenced this in commit d9d0578410 on Sep 14, 2026
  60. Eunovo force-pushed on Sep 17, 2026
  61. DrahtBot removed the label Needs rebase on Sep 17, 2026
  62. Kino1994 referenced this in commit 2678020096 on Sep 20, 2026
  63. Eunovo marked this as ready for review on Sep 21, 2026
  64. DrahtBot added the label Needs rebase on Oct 5, 2026
  65. Eunovo force-pushed on Oct 10, 2026
  66. DrahtBot removed the label Needs rebase on Oct 10, 2026
  67. sedited requested review from theStack on Oct 17, 2026
  68. sedited requested review from polespinasa on Oct 17, 2026
  69. DrahtBot added the label Needs rebase on Oct 20, 2026
  70. Eunovo force-pushed on Oct 20, 2026
  71. DrahtBot removed the label Needs rebase on Oct 20, 2026
  72. Eunovo marked this as a draft on Nov 3, 2026
  73. Eunovo commented at 9:43 AM on November 3, 2026: contributor

    Putting in draft while I finalize some changes.

  74. polespinasa commented at 10:52 AM on November 3, 2026: member

    concept ACK

    Will review when you force push and open it again :)

  75. Eunovo force-pushed on Nov 3, 2026
  76. Eunovo force-pushed on Nov 3, 2026
  77. DrahtBot added the label CI failed on Nov 3, 2026
  78. DrahtBot removed the label CI failed on Nov 3, 2026
  79. Eunovo renamed this:
    wallet: parallel fast rescan (approx 8x speed up with 8 threads)
    wallet: parallel fast rescan
    on Nov 4, 2026
  80. Eunovo marked this as ready for review on Nov 4, 2026
  81. Eunovo commented at 7:36 AM on November 4, 2026: contributor

    We replaced the previous implementation with a much simpler sliding-window implementation. New benchmark results are in #34400#issue-3851923967.

  82. in src/wallet/scan.h:77 in fdb49a2b72
      73 | @@ -74,11 +74,17 @@ class ChainScanner {
      74 |          uint256 tip_hash;
      75 |      };
      76 |  
      77 | -    //! Locate block_hash in the chain, queueing its active-chain successor
      78 | -    //! into next_block if it exists and is within the scan range. Returns
      79 | -    //! whether the block itself is still in the active chain.
      80 | -    bool QueueNextBlock(const uint256& block_hash, int block_height, std::optional<std::pair<uint256, int>>& next_block, std::optional<int> max_height);
      81 | -    bool ScanBlock(const uint256& block_hash, int block_height, bool save_progress);
      82 | +    enum class ScanBlockResult {
    


    polespinasa commented at 4:03 PM on November 18, 2026:

    in fdb49a2b7264c317d04e387b3e632af00b57e26d wallet/scan: check block is active under cs_wallet before syncing

    As a small nit, I think there were some discussions about not creating more "result" enum types, and start using Expected. I think it would be cleaner to have a ScanBlockError type and return those if Unexpected happens.

    <details> <summary>diff</summary>

    $ git diff
    diff --git a/src/wallet/scan.cpp b/src/wallet/scan.cpp
    index a4d783ef83..dc8c6612fe 100644
    --- a/src/wallet/scan.cpp
    +++ b/src/wallet/scan.cpp
    @@ -181,7 +181,7 @@ void ChainScanner::UpdateTipIfChanged(LoopState& state) {
         }
     }
     
    -ChainScanner::ScanBlockResult ChainScanner::ScanBlock(const uint256& block_hash, int block_height, bool save_progress) {
    +util::Expected<void, ChainScanner::ScanBlockError> ChainScanner::ScanBlock(const uint256& block_hash, int block_height, bool save_progress) {
         // Read block data and locator if needed (the locator is usually null unless we need to save progress)
         CBlock block;
         CBlockLocator loc;
    @@ -190,7 +190,7 @@ ChainScanner::ScanBlockResult ChainScanner::ScanBlock(const uint256& block_hash,
         if (save_progress) found_block.locator(loc);
         m_wallet.chain().findBlock(block_hash, found_block);
     
    -    if (block.IsNull()) return ScanBlockResult::READ_FAILED;
    +    if (block.IsNull()) return util::Unexpected{ScanBlockError::READ_FAILED};
     
         {
             // cs_wallet is a RecursiveMutex; ScanBlock may be called
    @@ -203,7 +203,7 @@ ChainScanner::ScanBlockResult ChainScanner::ScanBlock(const uint256& block_hash,
             // undoes their confirmation.
             bool active{false};
             m_wallet.chain().findBlock(block_hash, FoundBlock().inActiveChain(active));
    -        if (!active) return ScanBlockResult::NOT_ACTIVE;
    +        if (!active) return util::Unexpected{ScanBlockError::NOT_ACTIVE};
             for (size_t posInBlock = 0; posInBlock < block.vtx.size(); ++posInBlock) {
                 m_wallet.SyncTransaction(
                     block.vtx[posInBlock], TxStateConfirmed{block_hash, block_height,
    @@ -217,7 +217,7 @@ ChainScanner::ScanBlockResult ChainScanner::ScanBlock(const uint256& block_hash,
                 batch.WriteBestBlock(loc);
             }
         }
    -    return ScanBlockResult::SCANNED;
    +    return {};
     }
     
     ScanResult ChainScanner::Scan(const uint256& start_block, int start_height, std::optional<int> max_height,
    @@ -271,9 +271,14 @@ ScanResult ChainScanner::Scan(const uint256& start_block, int start_height, std:
                 fetch_block = ShouldFetchBlock(*fast_rescan_filter, block_hash, block_height);
             }
     
    -        ScanBlockResult scan_result{ScanBlockResult::SCANNED};
    +        util::Expected<void, ScanBlockError> scan_result;
             if (fetch_block) scan_result = ScanBlock(block_hash, block_height, save_progress && next_interval);
    -        if (scan_result == ScanBlockResult::NOT_ACTIVE) {
    +        if (scan_result) {
    +            // scanned the block, or skipped it via the filter: record it as
    +            // the most recent successfully scanned block
    +            result.last_scanned_block = block_hash;
    +            result.last_scanned_height = block_height;
    +        } else if (scan_result.error() == ScanBlockError::NOT_ACTIVE) {
                 // Abort scan if a block that needs to be inspected is no longer
                 // active. A block skipped by the filter can stay skipped: it has
                 // no successor in the active chain, so the scan ends successfully
    @@ -282,12 +287,6 @@ ScanResult ChainScanner::Scan(const uint256& start_block, int start_height, std:
                 result.last_failed_block = block_hash;
                 result.status = ScanResult::FAILURE;
                 break;
    -        }
    -        if (scan_result == ScanBlockResult::SCANNED) {
    -            // scanned the block, or skipped it via the filter: record it as
    -            // the most recent successfully scanned block
    -            result.last_scanned_block = block_hash;
    -            result.last_scanned_height = block_height;
             } else {
                 // could not scan block, keep scanning but record this block as the most recent failure
                 result.last_failed_block = block_hash;
    diff --git a/src/wallet/scan.h b/src/wallet/scan.h
    index 7f33608efa..e80e1091c0 100644
    --- a/src/wallet/scan.h
    +++ b/src/wallet/scan.h
    @@ -6,6 +6,7 @@
     #define BITCOIN_WALLET_SCAN_H
     
     #include <uint256.h>
    +#include <util/expected.h>
     #include <util/time.h>
     
     #include <atomic>
    @@ -74,8 +75,7 @@ private:
             uint256 tip_hash;
         };
     
    -    enum class ScanBlockResult {
    -        SCANNED,
    +    enum class ScanBlockError {
             READ_FAILED,
             //! The block left the active chain, so its transactions were not synced.
             NOT_ACTIVE,
    @@ -84,7 +84,7 @@ private:
         //! Queue block_hash's active-chain successor into next_block if it
         //! exists and is within the scan range.
         void QueueNextBlock(const uint256& block_hash, int block_height, std::optional<std::pair<uint256, int>>& next_block, std::optional<int> max_height);
    -    ScanBlockResult ScanBlock(const uint256& block_hash, int block_height, bool save_progress);
    +    util::Expected<void, ScanBlockError> ScanBlock(const uint256& block_hash, int block_height, bool save_progress);
         void UpdateProgress(const LoopState& state, double progress_current, int block_height);
         void UpdateTipIfChanged(LoopState& state);
     
    
    

    </details>


    Eunovo commented at 10:26 AM on November 19, 2026:

    Done.

  83. in src/wallet/scan.cpp:357 in c1b97000bc outdated
     398 | -            result.status = ScanResult::FAILURE;
     399 | +        if (!ctx.done && !ctx.max_height) {
     400 | +            UpdateTipIfChanged(state);
     401 | +            // The wallet's tip moved past the last processed block after its
     402 | +            // successor was looked up: continue from its successor, if any.
     403 | +            if (!HasPendingBlocks(ctx)) ctx.next_block = FindNextBlock(ctx, ctx.block_hash, ctx.block_height);
    


    polespinasa commented at 4:35 PM on November 18, 2026:

    in c1b97000bcc7f975b17f3b0164a5396fa5767642 wallet/scan: combine block iteration and filtering in NextBlocksSerial

    This is in fact a behavior change :)


    Eunovo commented at 10:28 AM on November 19, 2026:

    I updated the commit message to mention this second lookup. I also updated the comment.

  84. in src/wallet/scan.cpp:157 in c1b97000bc
     165 | +    if (!ctx.next_block) return std::nullopt;
     166 | +    const auto [block_hash, block_height] = *ctx.next_block;
     167 | +    // Blocks connected after this lookup are picked up by Scan() once the
     168 | +    // wallet's tip moves past the last processed block.
     169 | +    ctx.next_block = FindNextBlock(ctx, block_hash, block_height);
     170 | +    return QueuedBlock{block_hash, block_height};
    


    polespinasa commented at 4:59 PM on November 18, 2026:

    in c1b97000bcc7f975b17f3b0164a5396fa5767642 wallet/scan: combine block iteration and filtering in NextBlocksSerial

    nit: in many places you use QueuedBlock and in others you use a pair of {block_hash, block_height}. I think you could just use QueuedBlock always as it represents the same pair.

    <details> <summary>diff</summary>

    $ git diff
    diff --git a/src/wallet/scan.cpp b/src/wallet/scan.cpp
    index 155a496525..63d36e08e3 100644
    --- a/src/wallet/scan.cpp
    +++ b/src/wallet/scan.cpp
    @@ -137,7 +137,7 @@ struct ChainScanner::ScanContext {
         //! Optional height limit of the scan range.
         const std::optional<int> max_height;
         //! The next block to read, if any.
    -    std::optional<std::pair<uint256, int>> next_block;
    +    std::optional<QueuedBlock> next_block;
         std::unique_ptr<FastWalletRescanFilter> filter;
         //! Verification progress of the last scanned or skipped block.
         double progress_current{0};
    @@ -150,19 +150,19 @@ struct ChainScanner::ScanContext {
     
     std::optional<ChainScanner::QueuedBlock> ChainScanner::ReadNextBlock(ScanContext& ctx) {
         if (!ctx.next_block) return std::nullopt;
    -    const auto [block_hash, block_height] = *ctx.next_block;
    +    const QueuedBlock block{*ctx.next_block};
         // Blocks connected after this lookup are picked up by Scan() once the
         // wallet's tip moves past the last processed block.
    -    ctx.next_block = FindNextBlock(ctx, block_hash, block_height);
    -    return QueuedBlock{block_hash, block_height};
    +    ctx.next_block = FindNextBlock(ctx, block.hash, block.height);
    +    return block;
     }
     
    -std::optional<std::pair<uint256, int>> ChainScanner::FindNextBlock(const ScanContext& ctx, const uint256& block_hash, int block_height) {
    +std::optional<ChainScanner::QueuedBlock> ChainScanner::FindNextBlock(const ScanContext& ctx, const uint256& block_hash, int block_height) {
         bool has_next_block = false;
         uint256 next_block_hash;
         m_wallet.chain().findBlock(block_hash, FoundBlock().nextBlock(FoundBlock().inActiveChain(has_next_block).hash(next_block_hash)));
         if (!has_next_block || (ctx.max_height && block_height >= *ctx.max_height)) return std::nullopt;
    -    return {{next_block_hash, block_height + 1}};
    +    return QueuedBlock{next_block_hash, block_height + 1};
     }
     
     void ChainScanner::RecordSkipped(ScanContext& ctx, const QueuedBlock& block) {
    @@ -301,7 +301,7 @@ ScanResult ChainScanner::Scan(const uint256& start_block, int start_height, std:
         state.progress_begin = chain.guessVerificationProgress(start_block);
         state.progress_end = chain.guessVerificationProgress(end_hash);
         ctx.progress_current = state.progress_begin;
    -    ctx.next_block = {{start_block, start_height}};
    +    ctx.next_block = QueuedBlock{start_block, start_height};
         ctx.block_hash = start_block;
         ctx.block_height = start_height;
         // Report progress for the given height, logging every INTERVAL_TIME.
    diff --git a/src/wallet/scan.h b/src/wallet/scan.h
    index df10f32f45..8cddab01ec 100644
    --- a/src/wallet/scan.h
    +++ b/src/wallet/scan.h
    @@ -94,7 +94,7 @@ private:
         //! ctx.next_block if it exists and is within the scan range.
         std::optional<QueuedBlock> ReadNextBlock(ScanContext& ctx);
         //! The active-chain successor of a block, if it exists and is within range.
    -    std::optional<std::pair<uint256, int>> FindNextBlock(const ScanContext& ctx, const uint256& block_hash, int block_height);
    +    std::optional<QueuedBlock> FindNextBlock(const ScanContext& ctx, const uint256& block_hash, int block_height);
         //! Record a block skipped by the filter as the most recent successfully
         //! scanned block, and set ctx.done if it is at the wallet's tip.
         void RecordSkipped(ScanContext& ctx, const QueuedBlock& block);
    
    

    <\details>


    Eunovo commented at 10:26 AM on November 19, 2026:

    Done.

  85. in src/wallet/wallet.cpp:2940 in 15fa337407
    2935 | +        // '0' means 'autodetect'
    2936 | +        // '<0' means leave that many cores free
    2937 | +        wallet->m_wallet_par += GetNumCores();
    2938 | +    }
    2939 | +    // The calling thread counts towards -walletpar, as for -par.
    2940 | +    wallet->m_wallet_par = std::clamp(wallet->m_wallet_par, 1, MAX_WALLETPAR + 1);
    


    polespinasa commented at 5:08 PM on November 18, 2026:

    in 15fa33740799875801707e6c8e06ff5ed480dbf1 wallet: add -walletpar option

    Maybe we should just throw here if m_wallet_par is negative? I think we should require -walletpar to be bigger than -GetNumCores() and smaller than GetNumCores() + 1.

    Also GetIntArg returns an int64 while m_wallet_par is a normal int you can overflow the integers and trick a bit the result. This obviously is weird and not critic, but I think is worth addressing as is easy to fix:

    $ git diff
    diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
    index b1b9f52919..56e106afb5 100644
    --- a/src/wallet/wallet.cpp
    +++ b/src/wallet/wallet.cpp
    @@ -2930,14 +2930,14 @@ bool CWallet::LoadWalletArgs(std::shared_ptr<CWallet> wallet, const WalletContex
         wallet->m_notify_tx_changed_script = args.GetArg("-walletnotify", "");
         wallet->SetBroadcastTransactions(args.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));
     
    -    wallet->m_wallet_par = args.GetIntArg("-walletpar", DEFAULT_WALLETPAR);
    -    if (wallet->m_wallet_par <= 0) {
    +    int64_t wallet_par = args.GetIntArg("-walletpar", DEFAULT_WALLETPAR);
    +    if (wallet_par <= 0) {
             // '0' means 'autodetect'
             // '<0' means leave that many cores free
    -        wallet->m_wallet_par += GetNumCores();
    +        wallet_par += GetNumCores();
         }
         // The calling thread counts towards -walletpar, as for -par.
    -    wallet->m_wallet_par = std::clamp(wallet->m_wallet_par, 1, MAX_WALLETPAR + 1);
    +    wallet->m_wallet_par = static_cast<int>(std::clamp<int64_t>(wallet_par, 1, MAX_WALLETPAR + 1));
     
         return true;
     }
    
    

    Eunovo commented at 10:36 AM on November 19, 2026:

    I've fixed the overflow issue, but the code still doesn't throw. I'm not convinced we need to throw here. I think silently using the maximum or minimum number of threads is good enough, rather than forcing the user to enter the correct num cores.

  86. polespinasa commented at 5:53 PM on November 18, 2026: member

    reviewed 15fa33740799875801707e6c8e06ff5ed480dbf1

    will review the other 4 commits tomorrow :)

  87. in src/wallet/scan.cpp:167 in 5441a57e59 outdated
     166 | +
     167 | +enum FilterRes {
     168 | +    FILTER_NO_MATCH,
     169 | +    FILTER_MATCH,
     170 | +    FILTER_NO_FILTER,
     171 | +};
    


    polespinasa commented at 9:22 AM on November 19, 2026:

    in 5441a57e598628e94880ffcd455cecad70845e7e wallet/scan: check block filters in parallel

    nit:

    This shouldn't be uppercase. See https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md: "Enumerator constants may be snake_case, or PascalCase. They should not be ALL_CAPS, according to the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#renum-caps), to avoid clashing with macros."

    Also should probably use an enum class instead of just an enum per developer notes: "Prefer enum class (scoped enumerations) over enum (traditional enumerations) where possible."


    Eunovo commented at 11:29 AM on November 19, 2026:

    Done.

  88. in src/wallet/scan.cpp:532 in ca3136699b outdated
     527 | @@ -528,7 +528,8 @@ ScanResult ChainScanner::Scan(const uint256& start_block, int start_height, std:
     528 |      std::string log_message = "slow variant inspecting all blocks";
     529 |      if (chain.hasBlockFilterIndex(BlockFilterType::BASIC)) {
     530 |          ctx.filter = std::make_unique<FastWalletRescanFilter>(m_wallet);
     531 | -        if (m_wallet.m_wallet_par > 1) {
     532 | +        // During IBD, parallel checks would compete with block validation for cores.
     533 | +        if (m_wallet.m_wallet_par > 1 && !chain.isInitialBlockDownload()) {
    


    polespinasa commented at 9:30 AM on November 19, 2026:

    in ca3136699b8c8d926e31f04f2ad598bd5a731c9d wallet: don't rescan in parallel during IBD

    In the case of IBD, if m_wallet_par > 1 probably should log that the value of m_wallet_par was ignored.


    Eunovo commented at 11:29 AM on November 19, 2026:

    Done.

  89. Eunovo force-pushed on Nov 19, 2026
  90. polespinasa commented at 10:27 AM on November 19, 2026: member

    reviewed db2d769ff2ffa51d9a2800a036fb7477b58e8eb3

    I've just reviewed code, I've skipped tests.

    There are a few ralph comments that I would say they are worth addressing. Specially in commit 5441a57e598628e94880ffcd455cecad70845e7e where there are some edge cases that can make the rescan skip payments.

    I couldn't personally find anything else wrong in the behavior of 5441a57e598628e94880ffcd455cecad70845e7e, and my LLM scan found the same as Ralph.

  91. DrahtBot added the label CI failed on Nov 19, 2026
  92. Eunovo force-pushed on Nov 19, 2026
  93. Eunovo commented at 11:45 AM on November 19, 2026: contributor

    CI failure seems unrelated. See https://github.com/bitcoin/bitcoin/issues/36913

  94. in src/wallet/scan.h:84 in 7c6b283be6 outdated
      88 | +        uint256 hash;
      89 | +        int height;
      90 | +    };
      91 | +
      92 | +    enum class ScanBlockError {
      93 | +        READ_FAILED,
    


    w0xlt commented at 8:47 PM on November 19, 2026:

    nit:

            //! The block data could not be read (e.g. pruned or corrupt).
            READ_FAILED,
    

    Eunovo commented at 10:50 AM on November 24, 2026:

    Done.

  95. in src/wallet/scan.h:114 in 7c6b283be6 outdated
     118 | +    //! blocks as scanned.
     119 | +    //! @return the blocks to scan
     120 | +    std::vector<QueuedBlock> NextBlocksParallel(ScanContext& ctx);
     121 | +    //! Whether blocks remain to be read or delivered by the filter checker.
     122 | +    static bool HasPendingBlocks(const ScanContext& ctx);
     123 | +    util::Expected<void, ScanBlockError> ScanBlock(const uint256& block_hash, int block_height, bool save_progress);
    


    w0xlt commented at 8:48 PM on November 19, 2026:

    nit:

    +    //! Read a block and sync its transactions as confirmed in it.
    +    //! May be called with or without cs_wallet held.
         util::Expected<void, ScanBlockError> ScanBlock(const uint256& block_hash, int block_height, bool save_progress);
    

    Eunovo commented at 10:51 AM on November 24, 2026:

    Done.

  96. in src/wallet/scan.cpp:78 in 34a0646b74
      74 | @@ -73,7 +75,6 @@ void ChainScanner::Release() {
      75 |      m_scanning_with_passphrase = false;
      76 |  }
      77 |  
      78 | -namespace {
      79 |  class FastWalletRescanFilter
    


    w0xlt commented at 9:40 PM on November 19, 2026:

    Is there a reason to drop the anonymous namespace around FastWalletRescanFilter? The class is still only used inside scan.cpp. Keeping it preserves internal linkage and removes an unrelated change from this commit.

    diff --git a/src/wallet/scan.cpp b/src/wallet/scan.cpp
    index 9292b9cd8b..9a60bac7f3 100644
    --- a/src/wallet/scan.cpp
    +++ b/src/wallet/scan.cpp
    @@ -79,6 +79,7 @@ void ChainScanner::Release() {
         m_scanning_with_passphrase = false;
     }
     
    +namespace {
     class FastWalletRescanFilter
     {
     public:
    @@ -146,6 +147,7 @@ private:
         std::map<uint256, int32_t> m_last_range_ends;
         GCSFilter::ElementSet m_filter_set;
     };
    +} // namespace
     
     //! Blocks checked per thread-pool task, amortizing the per-task scheduling cost.
     static constexpr size_t BLOCKS_PER_FILTER_TASK{2};
    

    Eunovo commented at 10:51 AM on November 24, 2026:

    Done.

  97. in src/wallet/scan.cpp:198 in 34a0646b74
     214 | -    // has caught up with the wallet's tip is checked after the current block
     215 | -    // is processed, so blocks connected while it was being processed are not
     216 | -    // missed.
     217 | -    if (has_next_block && (!max_height || block_height < *max_height)) {
     218 | -        next_block = {{next_block_hash, block_height + 1}};
     219 | +    auto matches_block{ctx.filter->MatchesBlock(block->hash)};
    


    w0xlt commented at 9:48 PM on November 19, 2026:

    nit: this can be simplified for readability.

    diff --git a/src/wallet/scan.cpp b/src/wallet/scan.cpp
    index 9292b9cd8b..ef6a85148d 100644
    --- a/src/wallet/scan.cpp
    +++ b/src/wallet/scan.cpp
    @@ -394,14 +394,15 @@ std::vector<ChainScanner::QueuedBlock> ChainScanner::NextBlocksSerial(ScanContex
         // repopulate filter with new scripts if top-up has happened since last iteration
         ctx.filter->Update();
     
    -    auto matches_block{ctx.filter->MatchesBlock(block->hash)};
    -    if (matches_block.has_value() && *matches_block) {
    -        LogDebug(BCLog::SCAN, "Fast rescan: inspect block %d [%s] (filter matched)\n", block->height, block->hash.ToString());
    -        return {*block};
    -    } else if (!matches_block.has_value()) {
    +    const auto matches_block{ctx.filter->MatchesBlock(block->hash)};
    +    if (!matches_block) {
             LogDebug(BCLog::SCAN, "Fast rescan: inspect block %d [%s] (WARNING: block filter not found!)\n", block->height, block->hash.ToString());
             return {*block};
         }
    +    if (*matches_block) {
    +        LogDebug(BCLog::SCAN, "Fast rescan: inspect block %d [%s] (filter matched)\n", block->height, block->hash.ToString());
    +        return {*block};
    +    }
     
         // No match: this block needs no inspection and is skipped, even if it
         // left the active chain.
    

    Eunovo commented at 10:51 AM on November 24, 2026:

    Done.

  98. in src/wallet/scan.h:71 in 34a0646b74
      70 | -    //! current block's progress is a plain local in Scan; only the window
      71 | -    //! bounds are shared with the helpers, and UpdateTipIfChanged is the
      72 | -    //! sole mutator.
      73 | +    //! Progress window and tip tracked across Scan() iterations; only
      74 | +    //! UpdateTipIfChanged() mutates them.
      75 |      struct LoopState {
    


    w0xlt commented at 10:07 PM on November 19, 2026:

    Now that ScanContext holds the per-scan state, LoopState seems redundant. LoopState's fields can be moved into ScanContext. UpdateProgress and UpdateTipIfChanged can take ctx, like the other helpers. That removes a struct and keeps all scan state in one place.

    <details> <summary>diff</summary>

    diff --git a/src/wallet/scan.cpp b/src/wallet/scan.cpp
    index 9292b9cd8b..56b0c5eeaa 100644
    --- a/src/wallet/scan.cpp
    +++ b/src/wallet/scan.cpp
    @@ -337,8 +337,14 @@ struct ChainScanner::ScanContext {
         //! Checks block filters in parallel; only set when -walletpar > 1.
         //! Declared after filter, which it references, so it is destroyed first.
         std::unique_ptr<ParallelFilterChecker> checker;
    +    //! Verification progress at the start and end of the scan range. Without
    +    //! max_height, the end follows the wallet's tip (see UpdateTipIfChanged()).
    +    double progress_begin{0};
    +    double progress_end{0};
         //! Verification progress of the last scanned or skipped block.
         double progress_current{0};
    +    //! The wallet's tip when progress_end was last computed.
    +    uint256 tip_hash;
         //! Hash and height of the last scanned, skipped or failed block.
         uint256 block_hash;
         int block_height{0};
    @@ -458,13 +464,13 @@ bool ChainScanner::HasPendingBlocks(const ScanContext& ctx) {
         return ctx.next_block || (ctx.checker && !ctx.checker->Empty());
     }
     
    -void ChainScanner::UpdateProgress(const LoopState& state, double progress_current, int block_height) {
    +void ChainScanner::UpdateProgress(const ScanContext& ctx, int block_height) {
         m_scanning_progress = 0;
    -    double progress_diff = state.progress_end - state.progress_begin;
    +    double progress_diff = ctx.progress_end - ctx.progress_begin;
     
         // avoid divide-by-zero for single block scan range (i.e. start and stop hashes are equal)
         if (progress_diff <= 0.0) return;
    -    m_scanning_progress = (progress_current - state.progress_begin) / progress_diff;
    +    m_scanning_progress = (ctx.progress_current - ctx.progress_begin) / progress_diff;
     
         if (block_height % 100 == 0) {
             m_wallet.ShowProgress(strprintf("[%s] %s", m_wallet.DisplayName(), _("Rescanning…")),
    @@ -472,11 +478,11 @@ void ChainScanner::UpdateProgress(const LoopState& state, double progress_curren
         }
     }
     
    -void ChainScanner::UpdateTipIfChanged(LoopState& state) {
    +void ChainScanner::UpdateTipIfChanged(ScanContext& ctx) {
         const uint256 new_tip = WITH_LOCK(m_wallet.cs_wallet, return m_wallet.GetLastBlockHash());
    -    if (new_tip != state.tip_hash) {
    -        state.tip_hash = new_tip;
    -        state.progress_end = m_wallet.chain().guessVerificationProgress(state.tip_hash);
    +    if (new_tip != ctx.tip_hash) {
    +        ctx.tip_hash = new_tip;
    +        ctx.progress_end = m_wallet.chain().guessVerificationProgress(ctx.tip_hash);
         }
     }
     
    @@ -551,20 +557,19 @@ ScanResult ChainScanner::Scan(const uint256& start_block, int start_height, std:
         m_wallet.ShowProgress(strprintf("[%s] %s", m_wallet.DisplayName(), _("Rescanning…")), 0);
     
         auto& result = ctx.result;
    -    LoopState state;
    -    state.tip_hash = WITH_LOCK(m_wallet.cs_wallet, return m_wallet.GetLastBlockHash());
    -    uint256 end_hash = state.tip_hash;
    -    if (max_height) chain.findAncestorByHeight(state.tip_hash, *max_height, FoundBlock().hash(end_hash));
    -    state.progress_begin = chain.guessVerificationProgress(start_block);
    -    state.progress_end = chain.guessVerificationProgress(end_hash);
    -    ctx.progress_current = state.progress_begin;
    +    ctx.tip_hash = WITH_LOCK(m_wallet.cs_wallet, return m_wallet.GetLastBlockHash());
    +    uint256 end_hash = ctx.tip_hash;
    +    if (max_height) chain.findAncestorByHeight(ctx.tip_hash, *max_height, FoundBlock().hash(end_hash));
    +    ctx.progress_begin = chain.guessVerificationProgress(start_block);
    +    ctx.progress_end = chain.guessVerificationProgress(end_hash);
    +    ctx.progress_current = ctx.progress_begin;
         ctx.next_block = QueuedBlock{start_block, start_height};
         ctx.block_hash = start_block;
         ctx.block_height = start_height;
         // Report progress for the given height, logging every INTERVAL_TIME.
         // Returns whether the interval elapsed.
         const auto update_progress = [&](int height) {
    -        UpdateProgress(state, ctx.progress_current, height);
    +        UpdateProgress(ctx, height);
             const bool next_interval = reserver.now() >= current_time + INTERVAL_TIME;
             if (next_interval) {
                 current_time = reserver.now();
    @@ -607,7 +612,7 @@ ScanResult ChainScanner::Scan(const uint256& start_block, int start_height, std:
                 if (ctx.done) break;
             }
             if (!ctx.done && !ctx.max_height) {
    -            UpdateTipIfChanged(state);
    +            UpdateTipIfChanged(ctx);
                 // If nothing is pending, and the wallet's tip is past the last
                 // processed block (or ctx.done would be set), blocks were connected
                 // after the lookup of its successor found none. Look it up again.
    diff --git a/src/wallet/scan.h b/src/wallet/scan.h
    index fe27de7170..e934a6dad8 100644
    --- a/src/wallet/scan.h
    +++ b/src/wallet/scan.h
    @@ -66,14 +66,6 @@ private:
         std::atomic<SteadyClock::time_point> m_scanning_start{SteadyClock::time_point{}};
         std::atomic<double> m_scanning_progress{0};
     
    -    //! Progress window and tip tracked across Scan() iterations; only
    -    //! UpdateTipIfChanged() mutates them.
    -    struct LoopState {
    -        double progress_begin{0};
    -        double progress_end{0};
    -        uint256 tip_hash;
    -    };
    -
         //! A block queued for filtering and scanning.
         struct QueuedBlock {
             uint256 hash;
    @@ -112,8 +104,8 @@ private:
         //! Whether blocks remain to be read or delivered by the filter checker.
         static bool HasPendingBlocks(const ScanContext& ctx);
         util::Expected<void, ScanBlockError> ScanBlock(const uint256& block_hash, int block_height, bool save_progress);
    -    void UpdateProgress(const LoopState& state, double progress_current, int block_height);
    -    void UpdateTipIfChanged(LoopState& state);
    +    void UpdateProgress(const ScanContext& ctx, int block_height);
    +    void UpdateTipIfChanged(ScanContext& ctx);
     
         //! Only WalletRescanReserver may reserve and release scans, so that
         //! reservations are always managed RAII-style.
    

    </details>


    Eunovo commented at 10:51 AM on November 24, 2026:

    Done.

  99. DrahtBot removed the label CI failed on Nov 22, 2026
  100. DrahtBot added the label Needs rebase on Nov 23, 2026
  101. wallet/scan: check block is active under cs_wallet before syncing
    Checking inActiveChain before reading the block left a window where the
    block could be disconnected and its blockDisconnected notification
    handled before its transactions were synced as confirmed. Checking with
    cs_wallet held closes it, since that notification needs cs_wallet.
    5fbcd6331a
  102. wallet/scan: combine block iteration and filtering in NextBlocksSerial
    Move the filtering in ShouldFetchBlock into NextBlocksSerial, which
    returns the blocks to scan, and keep per-scan state in a ScanContext.
    This prepares for parallel filter checks.
    
    No behaviour change, except that if the wallet's tip moves past the
    last processed block after the lookup of its successor found none,
    the successor is looked up again instead of ending the scan.
    635da25244
  103. wallet: add -walletpar option
    Number of threads for wallet operations, to be used by parallel fast
    rescan. As for -par, the calling thread counts towards it, 0
    auto-detects, a negative value leaves that many cores free, and at most
    MAX_WALLETPAR (15) dedicated threads are used.
    15ee270221
  104. wallet/scan: check block filters in parallel
    With -walletpar > 1, fast rescan checks block filters on a thread pool.
    Blocks are read in windows, checked in tasks of BLOCKS_PER_FILTER_TASK blocks
    queued ahead of delivery, and delivered in block order, so workers keep
    checking while the scan thread scans matched blocks.
    
    On a keypool top-up, in-flight checks are drained and undelivered
    NO_MATCH verdicts are re-checked against only the new scripts. Read-ahead
    is wasted work then, so the window shrinks on every top-up and grows
    while there are none.
    faa01f0766
  105. wallet: don't rescan in parallel during IBD
    Parallel filter checks would compete with block validation for cores.
    6eca4325ae
  106. wallet/tests: exercise parallel fast rescan
    Run the filter-dependent scan tests with -walletpar 1 and 4, and check
    that the wallet loading rescan takes the parallel path.
    a33d29f577
  107. test: cover serial and parallel fast rescan in wallet_fast_rescan
    Parallel fast rescan is now the default, so pin the existing fast
    rescans to -walletpar=1 and add the same rescans with -walletpar=4.
    cdbdfd8e93
  108. Eunovo force-pushed on Nov 24, 2026
  109. DrahtBot removed the label Needs rebase on Nov 24, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-12-01 23:52 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me