test: simplify and speedup mempool_updatefromblock.py by using MiniWallet #27035

pull theStack wants to merge 1 commits into bitcoin:master from theStack:202302-test-use_MiniWallet_for_mempool_updatefromblock changing 1 files +15 −42
  1. theStack commented at 4:44 PM on February 3, 2023: contributor

    This PR simplifies the functional test mempool_updatefromblock.py by using MiniWallet in order to avoid manual low-level tx creation (signing, outputs selection, fee calculation). Most of the tedious work is done by the method MiniWallet.send_self_transfer_multi (calling create_self_transfer_multi internally) which supports spending a given set of UTXOs and creating a certain number of outputs.

    As a nice side-effect, the test's performance increases significantly (~3.5x on my system):

    master
        1m56.80s real     1m50.10s user     0m06.36s system
    
    PR
        0m32.34s real     0m30.26s user     0m01.41s system
    

    The arguments start_input_txid and end_address have been removed from the transaction_graph_test method, as they are currently unused and I don't see them being needed for future tests.

  2. test: simplify and speedup mempool_updatefromblock.py by using MiniWallet dee8549be3
  3. DrahtBot commented at 4:44 PM on February 3, 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 brunoerg, MarcoFalke

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

  4. DrahtBot added the label Tests on Feb 3, 2023
  5. brunoerg commented at 7:37 PM on February 3, 2023: contributor

    nice speed-up! my result:

    master:

    ➜  bitcoin-core-dev git:(master) ✗ time ./test/functional/mempool_updatefromblock.py 
    2023-02-03T19:32:04.575000Z TestFramework (INFO): Initializing test directory /var/folders/7j/m0yjzmhj4ys9jgl353v2mqph0000gn/T/bitcoin_func_test_h40yt0t5
    2023-02-03T19:32:04.870000Z TestFramework (INFO): Creating 100 transactions...
    2023-02-03T19:32:10.305000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
    2023-02-03T19:32:10.312000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
    2023-02-03T19:32:15.681000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
    2023-02-03T19:32:15.690000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
    2023-02-03T19:32:20.717000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
    2023-02-03T19:32:20.726000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
    2023-02-03T19:32:25.189000Z TestFramework (INFO): The last batch of 25 transactions has been accepted into the mempool.
    2023-02-03T19:32:25.229000Z TestFramework (INFO): All of the recently mined transactions have been re-added into the mempool in 0.0395050048828125 seconds.
    2023-02-03T19:32:25.229000Z TestFramework (INFO): Checking descendants/ancestors properties of all of the in-mempool transactions...
    2023-02-03T19:32:25.320000Z TestFramework (INFO): Stopping nodes
    2023-02-03T19:32:25.431000Z TestFramework (INFO): Cleaning up /var/folders/7j/m0yjzmhj4ys9jgl353v2mqph0000gn/T/bitcoin_func_test_h40yt0t5 on exit
    2023-02-03T19:32:25.431000Z TestFramework (INFO): Tests successful
    ./test/functional/mempool_updatefromblock.py  19.97s user 0.41s system 94% cpu 21.519 total
    

    pr branch:

    ➜  bitcoin-core-dev git:(thestack) ✗ time ./test/functional/mempool_updatefromblock.py
    2023-02-03T19:30:49.236000Z TestFramework (INFO): Initializing test directory /var/folders/7j/m0yjzmhj4ys9jgl353v2mqph0000gn/T/bitcoin_func_test_qvob42yw
    2023-02-03T19:30:50.067000Z TestFramework (INFO): Creating 100 transactions...
    2023-02-03T19:30:50.299000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
    2023-02-03T19:30:50.306000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
    2023-02-03T19:30:50.997000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
    2023-02-03T19:30:51.004000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
    2023-02-03T19:30:52.080000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
    2023-02-03T19:30:52.088000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
    2023-02-03T19:30:52.916000Z TestFramework (INFO): The last batch of 25 transactions has been accepted into the mempool.
    2023-02-03T19:30:53.018000Z TestFramework (INFO): All of the recently mined transactions have been re-added into the mempool in 0.10210895538330078 seconds.
    2023-02-03T19:30:53.018000Z TestFramework (INFO): Checking descendants/ancestors properties of all of the in-mempool transactions...
    2023-02-03T19:30:53.107000Z TestFramework (INFO): Stopping nodes
    2023-02-03T19:30:53.218000Z TestFramework (INFO): Cleaning up /var/folders/7j/m0yjzmhj4ys9jgl353v2mqph0000gn/T/bitcoin_func_test_qvob42yw on exit
    2023-02-03T19:30:53.218000Z TestFramework (INFO): Tests successful
    ./test/functional/mempool_updatefromblock.py  3.14s user 0.12s system 68% cpu 4.758 total
    
  6. in test/functional/mempool_updatefromblock.py:23 in dee8549be3
      31 | -        address = key_to_p2pkh(pubkey)
      32 | -        self.priv_keys.append(bytes_to_wif(key.get_bytes()))
      33 | -        return address
      34 | -
      35 | -    def transaction_graph_test(self, size, n_tx_to_mine=None, start_input_txid='', end_address='', fee=Decimal(0.00100000)):
      36 | +    def transaction_graph_test(self, size, n_tx_to_mine=None, fee=100_000):
    


    brunoerg commented at 7:43 PM on February 3, 2023:

    feel free to ignore:

    perhaps we could initialize n_tx_to_mine with an empty array since we're expecting it.

        def transaction_graph_test(self, size, n_tx_to_mine=[], fee=100_000):
    

    Also, the name of that variable and its explanation seems a little weird. n_tx_to_mine -- the number of transaction that should be mined into a block

    maybe the numbers of the transactions?

  7. brunoerg approved
  8. brunoerg commented at 6:13 PM on February 6, 2023: contributor

    crACK dee8549be39f841a24c3c8a3af3c5f787b9ad880

  9. fanquake requested review from maflcko on Feb 14, 2023
  10. maflcko approved
  11. maflcko commented at 3:25 PM on February 15, 2023: member

    lgtm ACK dee8549be39f841a24c3c8a3af3c5f787b9ad880 🚏

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

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    lgtm ACK dee8549be39f841a24c3c8a3af3c5f787b9ad880 🚏
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUgRvAv+Ocqz1YXq+DqusVBZ2r4gPtEhoLtBvJoNlBshKtRL0BW8/eiLvfFQ6uuC
    ecuJmi2m4bVO8HvieSSUpkJ0A8qPy5j+5USRYa9OM7MAHJq13x35GoaQkFIt5Dw0
    WR+CvnojJZ6+pqdSQbBG9JpuU4p8D2vhjP4TSCpXhlaQl5/TbaYK1TN1fLPx+4qX
    5/7JdEjbNi6fTc2NYWOTVpyy0G+I0tVRwzuIbfb2v33A26JyPs92QSJGTVfryyt4
    TpFOZ7slxLliag6JHUsCRd+XCNSd+JSwzSOKvSQ5I000DcpVDyyP8cmdmsHkxc2t
    MG186XP25WfZnU+oUu4YA6/4RFbhP20c8HrKHzyh0/aFfLBU3aA2Xk5lpURGIsKf
    ykW00gboBsan2Y6NZY9QBaC0L/g2G7DxUHdQhb2NbjaadPzjmao7xJo50mhskhKL
    nciyIdvbb+KtXOSHNkskQQQ2HANDUk/zOVMRycm4x23nT15o7F6qMcgzbolhDiXM
    pBAC0tg9
    =CxF6
    -----END PGP SIGNATURE-----
    

    </details>

  12. maflcko merged this on Feb 15, 2023
  13. maflcko closed this on Feb 15, 2023

  14. theStack deleted the branch on Feb 15, 2023
  15. sidhujag referenced this in commit d689eed196 on Feb 15, 2023
  16. bitcoin locked this on Feb 15, 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-14 21:13 UTC

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