test: add `rescan utxos` inside MiniWallet's initialization #26886

pull kouloumos wants to merge 3 commits into bitcoin:master from kouloumos:miniwallet-rescan_utxos changing 35 files +10 −74
  1. kouloumos commented at 11:21 AM on January 13, 2023: contributor

    When a pre-mined blockchain is used (default behavior), it contains coinbase outputs in blocks 76-10 to the MiniWallet's default address. That's why we always* rescan_utxos() after initializing the MiniWallet, in order for the MiniWallet to account for those mature UTXOs.

    The tests following this usage pattern can be seen with: git grep -n "MiniWallet(" $(git grep -le "rescan_utxos()" $(git grep -Le "self.setup_clean_chain = True"))

    This PR adds rescan_utxos() inside MiniWallet's initialization to simplify usage when the MiniWallet is used with a pre-mined chain.

    secondary changes

    • *There are a few tests that use the pre-mined blockchain but do not rescan_utxos(), they instead generate new blocks to create mature UTXOs.

      Those were written before the rescan_utxos() method was introduced with #22955 (fac66d0a39cb0b4bc565b57087ba84dd932e9b6d) and can be seen with: git grep -n "MiniWallet(" $(git grep -Le "rescan_utxos()" $(git grep -Le "self.setup_clean_chain = True"))

      After including rescan_utxos() inside MiniWallets initilization, this blocks generation logic is not needed as the MiniWallet already accounts for enough mature UTXOs to perform the tests. Therefore the now redundant blocks generation logic is removed from those tests with the second commit.

    • The rest of the MiniWallet tests use a clean chain (self.setup_clean_chain = True) and can be seen with git grep -n "MiniWallet(" $(git grep -le "self.setup_clean_chain = True")

      From those, there are a few that start from a clean chain and then create enough mature UTXOs for the MiniWallet with this kind of logic: https://github.com/bitcoin/bitcoin/blob/07c54de550035c3441f34ef6c34209666267eb38/test/functional/mempool_expiry.py#L36-L40

      Those tests are simplified in the third commit to instead utilize the mature UTXOs of the pre-mined chain.

  2. DrahtBot commented at 11:21 AM on January 13, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK theStack, MarcoFalke

    If your review is incorrectly listed, please react with ๐Ÿ‘Ž to this comment and the bot will ignore it on the next update.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  3. DrahtBot added the label Tests on Jan 13, 2023
  4. kouloumos force-pushed on Jan 13, 2023
  5. kouloumos force-pushed on Jan 13, 2023
  6. theStack commented at 12:51 AM on January 15, 2023: contributor

    Concept ACK

    Nice idea, seems reasonable to automatically scan for relevant UTXOs on MiniWallet creation if that's what we need to do most of the times anyways. I was thinking if it's worth it to add an option to the constructor to prevent that (so that users could e.g. pass rescan=False), but on the other hand a single additional scantxoutset RPC should never be problematic at all, especially since the UTXO set would be likely empty in those cases anyways. Will do a detailled review tomorrow.

  7. kouloumos commented at 5:51 PM on January 15, 2023: contributor

    I was thinking if it's worth it to add an option to the constructor to prevent that (so that users could e.g. pass rescan=False), but on the other hand a single additional scantxoutset RPC should never be problematic at all, especially since the UTXO set would be likely empty in those cases anyways.

    Yes, the UTXO set will be empty in those cases (when a clean chain is used) as at all times (except this one) the MiniWallet is initialized at the start of the test.

    Also, just a note that since #25445(fa13375aa3fcb4fd5b9e0d4c69ac31cf66c3209a) there is an additional scantxoutset RPC every time the MiniWallet is involved in block generation.

  8. kouloumos force-pushed on Jan 16, 2023
  9. maflcko commented at 9:41 AM on January 16, 2023: member

    Needs rebase after ac4c79a2678670300e07b0556d34848a56f7b7c1 ?

  10. kouloumos force-pushed on Jan 16, 2023
  11. kouloumos force-pushed on Jan 16, 2023
  12. kouloumos commented at 9:54 AM on January 16, 2023: contributor

    Rebased after ac4c79a2678670300e07b0556d34848a56f7b7c1 and force-pushed to also remove the now redundant rescan_utxos() call from p2p_permissions.py

  13. kouloumos force-pushed on Jan 16, 2023
  14. kouloumos force-pushed on Jan 16, 2023
  15. kouloumos commented at 10:53 AM on January 16, 2023: contributor

    Rebased after d6fc1d6a3393c571a1691a6bda60433216643616 and forced-pushed to remove the now redundant rescan_utxos() call from mempool_dust.py

  16. theStack approved
  17. theStack commented at 12:22 PM on January 16, 2023: contributor

    ACK cc50ef82646699f0be0e65dbd8b3a23aed57111b ๐Ÿงน

    Nice cleanup!

  18. maflcko approved
  19. maflcko commented at 4:43 PM on January 16, 2023: member

    Needs rebase cc50ef82646699f0be0e65dbd8b3a23aed57111b ๐Ÿšฆ

    <details><summary>Show signature</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    Needs rebase cc50ef82646699f0be0e65dbd8b3a23aed57111b ๐Ÿšฆ
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUhk3wwAhDET3giO6sF+pFhfgZqbhyFKg2pK94RnqQvuXyu9iczaa0z82zXXe7O+
    kJu06aVtKFmeZNp3iIR9821WFKSUQoHuYCEZXGKISppm2MRZ89wttPpKy1OdHxJ0
    yEBpH8M+yMveucqMZ+20VgCTk7wvlJjUQsqADCYIUEdPsO6rdVXnudIKDVI5DRb9
    5Az3/hJwTWyzXnKbu4CeKq4jCu5DbLFJtCWJb5hhgnnzAfhDdViGksQqzGhIn7jX
    MrAMMHQbwkRYB08HdzvLpbEYbCwRFOZGYu4umt/wiBq18qsnfCQ3lsBOA/vlzljn
    Ua/x3ChsoEFwvvKO72fQSYhRgS5Zj7b+HfXqhd8AWdMrKYaJKD1h6Aqb83z4xj8O
    +aTwA/y2Mid4PWr47hU1VjWIhsp0rV6HizKpzLCxFPDOCfXCzczsxv0ZLBYseQfJ
    NZ+SbQDsEHxG/efOApfRP+6LcS4pMtQZ3YFcoFaY++ajBmVNBmQ5ROhm4DRj/Md7
    CC5I4huv
    =Pv5e
    -----END PGP SIGNATURE-----
    

    </details>

  20. test: add `rescan_utxos` in MiniWallet's initialization
    this simplifies usage when MiniWallet is used with a pre-mined chain.
    0377d6bb42
  21. kouloumos force-pushed on Jan 16, 2023
  22. test: remove redundant blocks generation logic
    those tests already have enough mature utxos from the pre-mined chain.
    42029a7fd4
  23. test: simplify tests by using the pre-mined chain 6bd098a838
  24. kouloumos force-pushed on Jan 16, 2023
  25. kouloumos commented at 5:20 PM on January 16, 2023: contributor

    Rebased to resolve merge conflicts after d0a909ae54a34ecd925c9d5064d530eaeeba46eb and forced-pushed to remove the now redundant blocks generation logic from feature_bip68_sequence.py

  26. theStack approved
  27. theStack commented at 5:20 PM on January 16, 2023: contributor

    re-ACK 6bd098a838881ba615c01354560a70d47256f90f

  28. maflcko commented at 8:37 AM on January 17, 2023: member

    ACK 6bd098a838881ba615c01354560a70d47256f90f ๐Ÿ•ท

    <details><summary>Show signature</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    ACK 6bd098a838881ba615c01354560a70d47256f90f ๐Ÿ•ท
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUjqPQv/Xd3MSOVVkpxX3BF+OrK9/+cR9DruoNxpuJX3cVh18y1/zWbO7qV9yaMk
    y3+SD4oFhKjuaXLNWTSpcKciaT+PdgzDv7RO4bTRLg8KSlR8FMLlEn+R7jL8yDZt
    WhwdGjhGIvGojmCoW3ZOMFY5ciZlYVfs+bA5gYz/pqpioeBLfoTxM9dti9hSio5a
    klGpTo6EesPqLPtu5Ta+pkTmbGSSnk5QFmddOC9bl55s+QDHxhb5gaHxnDrvXPjK
    dUfE/bosKhdLZIGPw08K+oKU5xhr53tG1p2utt3twonRgCEBoJjfXYe1wr1Eh+3w
    DXw9A6qwD1542Q914gc+yWWGGHxeWI8vmgmOhoNUZ0lv2gsIa1JSgFFKDMAIKArH
    ddPjm71z4vE6BzRlNxossjqCCeGemJ4Whyp6otmbTQkbRlluFXBHEXVDLP7akutT
    E//aqnRldtuKmxIQoZiHHCh4ZEepeJYomh+5lH9xUSon6zHUKKiFQ0+9HTlPhG1X
    dvXbrAxL
    =qLqj
    -----END PGP SIGNATURE-----
    

    </details>

  29. maflcko merged this on Jan 17, 2023
  30. maflcko closed this on Jan 17, 2023

  31. kouloumos deleted the branch on Jan 17, 2023
  32. sidhujag referenced this in commit 5a207d22c1 on Jan 17, 2023
  33. bitcoin locked this on Jan 17, 2024

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-04-17 06:13 UTC

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