wallet: Remove first parameter to ScanForWalletTransactions start_hash #19216

pull pstratem wants to merge 1 commits into bitcoin:master from pstratem:2020-06-07-wallet-scanforwallettransactions changing 5 files +13 −37
  1. pstratem commented at 3:56 AM on June 9, 2020: contributor

    Every caller looks up the block hash from a block height immediately before calling.

  2. fanquake added the label Wallet on Jun 9, 2020
  3. DrahtBot commented at 10:25 AM on June 9, 2020: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #19310 (wallet: BerkeleyDatabase make BerkeleyDatabase::Create, CreateMock, and CreateDummy non-static functions by achow101)
    • #19195 (wallet: ScanForWalletTransactions cleanup by pstratem)
    • #19137 (wallettool: Add dump and createfromdump commands by achow101)
    • #19102 (wallet: Introduce and use DummyDatabase instead of dummy BerkeleyDatabase by achow101)
    • #19077 (wallet: Add sqlite as an alternative wallet database and use it for new descriptor wallets by achow101)
    • #18971 (wallet: Refactor the classes in wallet/db.{cpp/h} by achow101)
    • #18354 (Use shared pointers only in validation interface by bvbfan)
    • #15719 (Wallet passive startup by ryanofsky)

    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.

  4. DrahtBot cross-referenced this on Jun 9, 2020 from issue wallet: ScanForWalletTransactions cleanup by pstratem
  5. DrahtBot cross-referenced this on Jun 9, 2020 from issue wallettool: Add dump and createfromdump commands by achow101
  6. in src/wallet/rpcwallet.cpp:3564 in 5586ef7a06 outdated
    3566 | @@ -3567,7 +3567,7 @@ UniValue rescanblockchain(const JSONRPCRequest& request)
    3567 |      }
    


    MarcoFalke commented at 11:41 AM on June 9, 2020:

    Is there a reason you didn't remove the start_block variable?


    pstratem commented at 4:44 AM on June 11, 2020:

    i didn't want to change the function called but i guess i should


    promag commented at 9:24 PM on June 11, 2020:

    I think this can be removed now that block hash is gone.


    pstratem commented at 10:05 PM on June 11, 2020:

    indeed

  7. DrahtBot cross-referenced this on Jun 9, 2020 from issue wallet: Introduce and use DummyDatabase instead of dummy BerkeleyDatabase by achow101
  8. DrahtBot cross-referenced this on Jun 9, 2020 from issue wallet: Refactor the classes in wallet/db.{cpp/h} by achow101
  9. DrahtBot cross-referenced this on Jun 9, 2020 from issue Wallet passive startup by ryanofsky
  10. promag commented at 9:13 PM on June 10, 2020: member

    Concept ACK dropping one of the start args. I have a preference to keep start_block hash instead.

  11. pstratem force-pushed on Jun 11, 2020
  12. pstratem commented at 5:17 AM on June 11, 2020: contributor

    @promag im using the block height because everything that calls it is using the block height

  13. promag commented at 9:33 PM on June 11, 2020: member

    Code review ACK 8d8e4d36c3d3cbe8b495869865aa0b8ff83fdbca. @pstratem the interface uses heights but internally block hash is unambiguous - a block at a certain height can change after a reorg - but not a strong opinion.

  14. wallet: Remove first parameter to ScanForWalletTransactions start_hash
    Every caller looks up the block hash from a block height immediately before
    calling.
    dbd8498b81
  15. pstratem force-pushed on Jun 11, 2020
  16. pstratem commented at 10:36 PM on June 11, 2020: contributor

    @promag the rescan is pretty ambiguous to start with, it's scanning whatever the current active chain is

    edit: the entire concept in theory should do nothing so it's a much "fuzzier" thing than other wallet ops that handle reorgs cleanly

  17. promag commented at 10:39 PM on June 11, 2020: member

    Code review ACK dbd8498b8134cb4cefa351eb21bef2769a7bdf18, dropped unnecessary statement since last review

  18. DrahtBot cross-referenced this on Jun 14, 2020 from issue Use shared pointers only in validation interface by bvbfan
  19. DrahtBot cross-referenced this on Jun 17, 2020 from issue wallet: Add sqlite as an alternative wallet database and use it for new descriptor wallets by achow101
  20. DrahtBot cross-referenced this on Jun 17, 2020 from issue wallet: BerkeleyDatabase make BerkeleyDatabase::Create, CreateMock, and CreateDummy non-static functions by achow101
  21. DrahtBot commented at 9:48 PM on June 18, 2020: contributor

    <!--cf906140f33d8803c4a75a2196329ecb-->

    🐙 This pull request conflicts with the target branch and needs rebase.

  22. DrahtBot added the label Needs rebase on Jun 18, 2020
  23. ryanofsky commented at 9:35 PM on June 30, 2020: contributor

    This isn't a good change, I think. It doesn't simplify the code very much, and makes the scanning code less correct and more fragile. The problem is the new getBlockHash call added here:

    https://github.com/pstratem/bitcoin/blob/dbd8498b8134cb4cefa351eb21bef2769a7bdf18/src/wallet/wallet.cpp#L1672

    getBlockHash is a synchronous method that will assert and the crash the process if it is called with an invalid height. Since #16426, the wallet can no longer lock the node, so reorgs can happen any time, and getBlockHash isn't safe to call after startup. The last remaining uses of getBlockHash are removed in #15719.

    Calling getBlockHash here can also lead to less correct behavior even if it doesn't fully crash the process. RescanFromTime and CreateWalletFromFile both locate starting blocks based on time, but after this change they only pass the starting block height, not the starting block hash to ScanForWalletTransactions, meaning if there is a reorg, blocks that should be scanned might not be and no errors will be returned.

    In general, the only correct way for wallet code to reference blocks is by hash and not by height, and this PR moves in the less correct direction.

    Also, while ScanForWalletTransactions code is very messy, I think effort would be better spent deleting it and trying to move rescans outside the wallet with ariard's changes #11756 (comment), than trying to clean it up

  24. promag commented at 10:30 AM on July 1, 2020: member

    Concept ACK dropping one of the start args. I have a preference to keep start_block hash instead.

    @pstratem the interface uses heights but internally block hash is unambiguous - a block at a certain height can change after a reorg - but not a strong opinion.

    I've mentioned this before, but considering @ryanofsky comment #19216 (comment) and @ariard work I agree that this is not worth it.

  25. ryanofsky commented at 3:51 PM on July 1, 2020: contributor

    Another option could be to drop the start_height argument and keep the start_block argument

  26. fanquake commented at 8:00 AM on August 18, 2021: member

    Closing for now.

  27. fanquake closed this on Aug 18, 2021

  28. bitcoin locked this on Aug 18, 2022

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-05-20 06:54 UTC