Make rescans faster #23727

issue jamesob openend this issue on December 9, 2021
  1. jamesob commented at 8:20 pm on December 9, 2021: member

    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
  2. jamesob added the label Feature on Dec 9, 2021
  3. ryanofsky commented at 9:51 pm on December 9, 2021: contributor

    [ ] rescanning all wallets at startup in parallel (instead of one-by-one)

    This is #11756, and I’m working on it now, but a little indirectly. Specifically I’m:

    1. Porting BaseIndex::ThreadSync and other index code to sync with interfaces::Chain instead of calling validation code directly. The motivation is to let indexes be used with #10102 and run in different processes, but this also adds a new chain sync feature that can be used by wallets.
    2. Introducing a block reader class to help with parallel rescans and pass same block data to multiple indexes.
    3. Going to rebase #15719 on top of this rescan code so wallets can use the same chain sync interface as the indexes

    There’s some uncertainty and performance tradeoffs in step 2. Right now my block reader implementation just reads 2 blocks at a time so previous block can be processed while next block is read. But it might be better to let indexes and wallets read blocks more freely without trying to schedule things.

  4. maflcko commented at 11:25 am on December 10, 2021: member

    although it is not clear to me how this might work for non-descriptor-based (legacy) wallets.

    Something like #15845 (comment) should do that

  5. maflcko added the label Wallet on Dec 10, 2021
  6. maflcko commented at 11:44 am on December 15, 2021: member
    See also #19116
  7. bitcoin deleted a comment on Apr 27, 2022
  8. Sjors commented at 12:00 pm on June 8, 2022: member
    PR description could now point to #23549
  9. Sjors commented at 11:19 am on September 9, 2022: member
    As well as #15845!
  10. achow101 commented at 11:15 pm on October 26, 2022: member
    #25957 for fast rescan with filters was merged.
  11. maflcko commented at 7:22 am on October 27, 2022: member
    Can this be closed, given that the remaining thing #https://github.com/bitcoin/bitcoin/issues/11756 is already a separate issue?
  12. Sjors commented at 10:28 am on October 27, 2022: member
    Blazing fast as of #25957, so I think we can close this.
  13. jamesob closed this on Oct 27, 2022

  14. bitcoin locked this on Oct 27, 2023

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: 2024-12-22 06:12 UTC

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