fuzz: have package_rbf always make small txns #30300

pull instagibbs wants to merge 1 commits into bitcoin:master from instagibbs:2024-06-package_rbf_fuzz_impr changing 1 files +12 −12
  1. instagibbs commented at 2:15 pm on June 18, 2024: member

    hopefully resolves #30241

    The fuzz target is generating a large amount of transactions, but the core of the logic is ConsumeTxMemPoolEntry making the mempool entries for adding to the mempool. Since ConsumeTxMemPoolEntry generates its own transaction “vsize”, we can improve efficiency of the target by explicitly creating very small transactions, reducing the hashing and memory burden.

  2. DrahtBot commented at 2:15 pm on June 18, 2024: contributor

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

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK maflcko, hodlinator, glozow

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #28676 ([WIP] Cluster mempool implementation by sdaftuar)

    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.

  3. DrahtBot added the label Tests on Jun 18, 2024
  4. instagibbs force-pushed on Jun 18, 2024
  5. instagibbs force-pushed on Jun 18, 2024
  6. fuzz: have package_rbf always make small txns
    The fuzz target is generating a large amount of
    transactions, but the core of the logic is
    ConsumeTxMemPoolEntry making the mempool
    entries for adding to the mempool. Since
    ConsumeTxMemPoolEntry generates its own transaction
    "vsize", we can improve efficiency of the target
    by explicitly creating very small transactions,
    reducing the hashing and memory burden.
    4ccb3d6d0d
  7. instagibbs force-pushed on Jun 18, 2024
  8. maflcko commented at 2:22 pm on June 18, 2024: member

    ConsumeTxMemPoolEntry generates its own transaction “vsize”,

    Can you add a reference to this claim? Looking at src/test/fuzz/util/mempool.cpp, I couldn’t find it.

  9. maflcko commented at 2:25 pm on June 18, 2024: member
    Oh, I guess indirectly via sig_op_cost?
  10. maflcko commented at 2:27 pm on June 18, 2024: member

    lgtm ACK 4ccb3d6d0d576d32da8a1b9c6e70962cbd0f19fe

    (Assuming my assumption about the vsize mocking via sigop cost is correct)

  11. instagibbs commented at 2:27 pm on June 18, 2024: member

    Oh, I guess indirectly via sig_op_cost?

    Right, sorry!

    #29879 previously touched on this

  12. DrahtBot added the label CI failed on Jun 18, 2024
  13. DrahtBot removed the label CI failed on Jun 18, 2024
  14. in src/test/fuzz/rbf.cpp:121 in 4ccb3d6d0d
    122+        CMutableTransaction parent;
    123         assert(iter <= g_outpoints.size());
    124-        parent->vin.resize(1);
    125-        parent->vin[0].prevout = g_outpoints[iter++];
    126+        parent.vin.resize(1);
    127+        parent.vin[0].prevout = g_outpoints[iter++];
    


    hodlinator commented at 8:18 am on June 19, 2024:

    Might as well

    0        parent.vin.emplace_back(g_outpoints[iter++]);
    
  15. in src/test/fuzz/rbf.cpp:117 in 4ccb3d6d0d
    114@@ -113,15 +115,13 @@ FUZZ_TARGET(package_rbf, .init = initialize_package_rbf)
    115     LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), NUM_ITERS)
    116     {
    117         // Make sure txns only have one input, and that a unique input is given to avoid circular references
    


    hodlinator commented at 8:28 am on June 19, 2024:
    I understand this comment as explaining why a random number of vins of parent generated from fuzz data are overwritten with one input. Time to change/remove?
  16. in src/test/fuzz/rbf.cpp:134 in 4ccb3d6d0d
    129@@ -130,10 +130,10 @@ FUZZ_TARGET(package_rbf, .init = initialize_package_rbf)
    130             break;
    131         }
    132         pool.addUnchecked(parent_entry);
    133-        if (fuzzed_data_provider.ConsumeBool() && !child->vin.empty()) {
    134-            child->vin[0].prevout = COutPoint{mempool_txs.back().GetHash(), 0};
    135+        if (fuzzed_data_provider.ConsumeBool()) {
    136+            child.vin[0].prevout = COutPoint{mempool_txs.back().GetHash(), 0};
    


    hodlinator commented at 8:46 am on June 19, 2024:

    Good that you removed the unnecessary vin.empty() check.

    Until the first time ConsumeBool() returns true here, we’ll be using a child with a default-initialized vin[0]. This was true before the change as well. Does some later code hook up default-constructed CTxIn to coinbase transactions or something?

    It seems unnecessary to have created a parent at all if the ConsumeBool() returns false. But I guess it’s good to test adding unrelated transactions between each child.

  17. hodlinator commented at 8:52 am on June 19, 2024: none
    ACK 4ccb3d6d0d576d32da8a1b9c6e70962cbd0f19fe
  18. glozow commented at 10:20 am on June 19, 2024: member

    ACK 4ccb3d6d0d576d32da8a1b9c6e70962cbd0f19fe

    Agree value of GetTxSize() is chosen by ConsumeTxMemPoolEntry and conflicts aren’t calculated using outpoints, so there’s no need to make mempool transactions through ConsumeDeserializable<CMutableTransaction>.

    seed 95a3b1b42d43ac7190f24ff116b2cd6515e7a566 didn’t give me an oom but took 1981ms / now takes 71ms.

  19. glozow merged this on Jun 19, 2024
  20. glozow closed this on Jun 19, 2024

  21. murchandamus commented at 12:22 pm on June 20, 2024: contributor
    This change in the fuzzer seems to have reduced the coverage of the package_rbf fuzzer with the current qa-assets fuzz inputs by about 600 LOC. I’ll make a PR to update the fuzz inputs.
  22. maflcko commented at 12:54 pm on June 20, 2024: member
    Yes, this is expected, because all lines of code in ConsumeDeserializable<CMutableTransaction> can no longer be hit. Also, the fuzz input format changed, but that should fix itself over time, as new fuzz inputs are found.

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: 2024-09-28 22:12 UTC

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