This issue aggregates ideas for making wallet rescans substantially faster.
Using compact block filters, when available, could substantially speed up wallet rescans although it is not clear to me how this might work for non-descriptor-based (legacy) wallets.
Currently, #20664 proposes to add an RPC that will use compact block filters to scan for blocks relevant to a given script descriptor. This gives a listing of blocks that correspond to the descriptor, but the user then has to do something with that list of blocks to find transactions relevant to their wallet.
It would be nice to integrate scanblocks’ use of block filters opaquely into rescanblockchain
(wallet rescanning) so that if block filters are available, the faster method of consulting them could be used instead of scanning the entire chain, or forcing the user to do something more roundabout with the output of scanblocks
.
From @sipa:
regarding faster rescanning, i think there is some lower-hanging fruit, like (a) rescanning all wallets at startup in parallel rather than one by one and (b) building a set of scriptPubKeys to look for and using that for (legacy wallet) rescanning, instead of calling IsMine for each (especially with achow101’s migrate-to-descriptor code, i think there should be a way of computing that set for legacy wallets too)
Possible changes
- integrate compact block filter usage into
rescanblockchain
to allow faster rescans when the compact block index is available, otherwise falling back to the standard scanning method. A first approach could possibly use filters only when dealing with a non-legacy descriptor wallet- Currently proposed in #23549
- allow pruned nodes with the block filter index to rescan quickly by getting a list of relevant blocks to the wallet, requesting the download of blocks, and then parsing the blocks for relevant transactions
- rescanning all wallets at startup in parallel (instead of one-by-one): #11756
- building a set of scriptPubKeys to look for when using a legacy wallet based on @achow101’s migrate-to-descriptor code