WIP Refactor large transaction generation for tests and make generic #12930

pull conscott wants to merge 1 commits into bitcoin:master from conscott:CRS_tests_flexible_tx_size changing 3 files +168 −36
  1. conscott commented at 8:13 AM on April 10, 2018: contributor

    In playing with some of the large transaction / full block functional tests, I found some of the construction logic for large transactions to be a bit confusing. In particular, you could make a 'large transaction', but the actual size was not exact in any way, making more advanced testing harder to reason about. This change allows customization in number of outputs / size of output to add to transactions (via gen_return_txouts) and allows creating a tx with a particular target size simply with

    def create_tx_with_size(node, target_vsize)
    

    This allows much more flexible testing of certain scenarios, for example, easily filling the mempool to an exact size, with various size txs and fees (tx radius is size). mempool2

    And from there, evaluating something like getblocktemplate selection: mempoolwithgbt

    There is a tests of this functionality in this commit but I was thinking to not include this in the PR because it's just testing what was added to test_framework. This tests was also used to generate the mempools above, and graphed with a draw mempool tool I have been working on.

    I wanted to get feedback before possibly updating / adding more functional tests to use this kind of construction. @jnewbery @MarcoFalke ?

  2. [Tests] Refactor big transaction generation and make generic ababcdede1
  3. fanquake added the label Tests on Apr 10, 2018
  4. jnewbery commented at 2:14 PM on April 10, 2018: member

    Concept ACK. A few high-level comments:

    • create_tx_with_size() is defined, but doesn't seem to be used anywhere.
    • you're doing a lot of manual transaction construction and byte wrangling. Is it possible to use the CTransaction class in messages.py to achieve this more easily
    • I much prefer docstrings (https://www.python.org/dev/peps/pep-0257/) for commenting functions than a block comment above (it makes the function stand out more, and the comment is available in interactive sessions).
    • I think the new code can be moved around a bit. Pure util functions should live in util.py in the Utility Functions section. Transaction and block building functions should live in blocktools.py
  5. MarcoFalke commented at 7:55 PM on April 11, 2018: member

    Agree with what @jnewbery already said.

    create_tx_with_size() is defined, but doesn't seem to be used anywhere.

    If the code is not simpler (or faster) or better any other way than the existing code, I see not much reason to review/merge this. Please adjust the call sites to use the new code, so reviewers can get an idea what this is supposed to be replacing.

  6. conscott commented at 8:02 PM on April 11, 2018: contributor

    Thanks for looking, will close until I have more time to update this with the usage I had in mind.

  7. conscott closed this on Apr 11, 2018

  8. MarcoFalke commented at 8:29 PM on April 11, 2018: member

    @conscott I am looking forward to this. (We might be able to speed up the pruning functional test with a version that is optimized for speed, haven't looked if that is actually the bottleneck, though)

  9. jnewbery commented at 8:33 PM on April 11, 2018: member

    I tried to refactor the pruning test here: #10591 but got bored of rebasing. The original comment in that PR did suggest that constructing large blocks was a bottleneck.

  10. conscott commented at 6:50 AM on April 12, 2018: contributor

    Thanks for the suggestion; I will try to use this with the pruning test and see what happens. I won't have time to work for the next few days, which is another reason I chose to close temporarily. Once I get some solid time to test this with large block tests I will definitely re-open :)

  11. conscott deleted the branch on Jul 31, 2018
  12. MarcoFalke locked this on Sep 8, 2021
Labels

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-02 03:15 UTC

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