[tests] make pruning test faster #15686

pull jnewbery wants to merge 2 commits into bitcoin:master from jnewbery:2019_03_faster_pruning_test changing 1 files +93 −93
  1. jnewbery commented at 4:13 PM on March 28, 2019: member

    This commit makes the pruning.py much faster.

    Key insights to do this:

    • pruning.py doesn't care what kind of transactions make up the big blocks that are pruned in the test. Instead of making blocks with several large, expensive to construct and validate transactions, instead make the large blocks contain a single coinbase transaction with a huge OP_RETURN txout.
    • avoid stop-starting nodes where possible.
  2. practicalswift commented at 4:51 PM on March 28, 2019: contributor

    Very nice! Do you have any numbers to share? :-)

  3. jnewbery commented at 4:59 PM on March 28, 2019: member

    Very nice! Do you have any numbers to share? :-)

    ~30 minutes -> ~4 minutes on my machine.

    (I should have mentioned that this is #10591 resurrected)

  4. in test/functional/feature_pruning.py:29 in 3ce84d764f outdated
      23 | @@ -21,19 +24,60 @@
      24 |  # compatible with pruning based on key creation time.
      25 |  TIMESTAMP_WINDOW = 2 * 60 * 60
      26 |  
      27 | +def mine_large_blocks(node, n):
      28 | +    # Make a large scriptsig for the coinbase transaction. This is OP_RETURN
      29 | +    # followed by 950k of OP_NOP. This is a non-standard transaction but it
    


    instagibbs commented at 5:52 PM on March 28, 2019:

    one hand clapping: can a coinbase tx ever be "non-standard"? :)


    sdaftuar commented at 6:03 PM on March 28, 2019:

    I think all coinbases are "non-standard", since we never relay them. :)


    jnewbery commented at 6:42 PM on March 28, 2019:

    Heh. Would you prefer "A transaction containing this scriptPubKey would be non-standard in a non-coinbase transaction, but is consensus valid"?

    I also notice that the comment incorrectly says 'scriptsig' instead of 'scriptPubKey'. I'll update.


    instagibbs commented at 6:46 PM on March 28, 2019:

    just a joke :)


    jnewbery commented at 7:43 PM on March 28, 2019:

    Needed to fix other comments, so I've fixed this too. Thanks.

  5. in test/functional/feature_pruning.py:62 in 3ce84d764f outdated
      57 | +        block.nBits = int('207fffff', 16)
      58 | +        block.nNonce = 0
      59 | +        block.vtx = [coinbase_tx]
      60 | +        block.hashMerkleRoot = block.calc_merkle_root()
      61 | +        block.solve()
      62 | +        block_binary = (b2a_hex(block.serialize()).decode('ascii'))
    


    instagibbs commented at 5:56 PM on March 28, 2019:

    block_hex? I also think a simple .hex() is kosher on master now(or at least I see many incantations of it!)


    instagibbs commented at 6:03 PM on March 28, 2019:

    Also just as test belt and suspenders, make sure the blocks you are making are actually the size you think they are:

    assert_greater_than(len(block_hex), len(big_script)*2)

    or there abouts


    jnewbery commented at 7:43 PM on March 28, 2019:

    Thanks. I've changed this to use ToHex() to match other tests.

  6. instagibbs approved
  7. instagibbs commented at 6:12 PM on March 28, 2019: member

    tACK https://github.com/bitcoin/bitcoin/pull/15686/commits/3ce84d764f28c17faa790fc9ff038626a9291a3b with non-blocking nits.

    2019-03-28T18:08:04.929000Z TestFramework (INFO): Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours) no longer true as well for me, took far less than 5 minutes on my debug build.

  8. jnewbery force-pushed on Mar 28, 2019
  9. jnewbery commented at 7:44 PM on March 28, 2019: member

    Force pushed some minor fixups. I also tested sending the blocks over P2P, and it's actually slower, so I've removed the comment saying we should do that.

  10. DrahtBot added the label Tests on Mar 28, 2019
  11. sipa commented at 9:27 PM on March 28, 2019: member

    Concept ACK

  12. MarcoFalke commented at 10:36 PM on March 28, 2019: member

    ~30 minutes -> ~4 minutes on my machine.

    That's impressive. Mind to move it to the non-extended tests?

  13. DrahtBot commented at 10:55 PM on March 28, 2019: member

    <!--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:

    • #15680 ([WIP] Remove resendwallettransactions RPC method by jnewbery)

    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.

  14. jnewbery commented at 11:46 PM on March 28, 2019: member

    Mind to move it to the non-extended tests?

    Sadly, I think this still won't run on travis. Here's my comment on the original PR:

    Unfortunately, pruning.py still isn't able to run on Travis. It appears that disk access is very slow for in the Travis environment, and this test still times out/fails. Unfortunately, it's not possible to run this test without very heavy disk access - the whole point of pruning is to remove block files when disk usage goes over a certain threshold.

    You've also asked that I split out the style changes into a separate commit, which is a fair request. I'll do that tomorrow.

  15. [tests] style fixes in feature_pruning.py
    Minor style fixups. No functional change.
    1c29ac40fb
  16. [tests] make pruning test faster
    This commit makes the pruning.py much faster.
    
    Key insights to do this:
    
    - pruning.py doesn't care what kind of transactions make up the big
    blocks that are pruned in the test. Instead of making blocks with
    several large, expensive to construct and validate transactions,
    instead make the large blocks contain a single coinbase transaction with
    a huge OP_RETURN txout.
    - avoid stop-starting nodes where possible.
    
    This test could probably be made even faster by using the P2P interface
    for submitting blocks instead of the submitblock RPC.
    03d6d23810
  17. jnewbery force-pushed on Mar 29, 2019
  18. jnewbery commented at 3:45 PM on March 29, 2019: member

    I've split style-only changes into their own commit, to make review easier. Pushed branch should be identical to previous.

  19. MarcoFalke commented at 4:20 PM on March 29, 2019: member

    utACK 03d6d238104d228acfae9f3e122879bddef8d27d

  20. in test/functional/feature_pruning.py:9 in 03d6d23810
       7 | @@ -8,11 +8,13 @@
       8 |  This test uses 4GB of disk space.
       9 |  This test takes 30 mins or more (up to 2 hours)
    


    ryanofsky commented at 5:10 PM on March 29, 2019:

    Could update this comment

  21. MarcoFalke commented at 5:16 PM on March 29, 2019: member

    Time: Less than 3 minutes on ssd and about 4 minutes on hdd. :rocket:

  22. MarcoFalke referenced this in commit dc5c2e4407 on Mar 29, 2019
  23. MarcoFalke merged this on Mar 29, 2019
  24. MarcoFalke closed this on Mar 29, 2019

  25. in test/functional/feature_pruning.py:55 in 03d6d23810
      50 | +        # Build the block
      51 | +        block = CBlock()
      52 | +        block.nVersion = best_block["version"]
      53 | +        block.hashPrevBlock = previousblockhash
      54 | +        block.nTime = mine_large_blocks.nTime
      55 | +        block.nBits = int('207fffff', 16)
    


    ryanofsky commented at 5:23 PM on March 29, 2019:

    Could write 0x207fffff

  26. ryanofsky commented at 5:24 PM on March 29, 2019: member

    ACK 03d6d238104d228acfae9f3e122879bddef8d27d. Test also took ~3 minutes for me (on ssd)

  27. jnewbery commented at 5:39 PM on March 29, 2019: member

    Thanks for the review @ryanofsky . This has been merged so I'm not intending to make further changes (happy to review your PR if you want to make the changes though).

  28. jnewbery deleted the branch on Oct 18, 2019
  29. vijaydasmp referenced this in commit 47dbb4b8fd on Oct 12, 2021
  30. vijaydasmp referenced this in commit 7e17d80b1e on Oct 14, 2021
  31. vijaydasmp referenced this in commit b3a1041447 on Oct 14, 2021
  32. vijaydasmp referenced this in commit 54731ebc08 on Oct 16, 2021
  33. vijaydasmp referenced this in commit fce74ffd0c on Oct 19, 2021
  34. PastaPastaPasta referenced this in commit 6e32a464f5 on Oct 21, 2021
  35. pravblockc referenced this in commit 81143b9194 on Nov 18, 2021
  36. MarcoFalke locked this on Dec 16, 2021

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-13 15:15 UTC

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