test: construct `miner_tests` transactions declaratively #36810

pull yuvicc wants to merge 2 commits into bitcoin:master from yuvicc:test-declarative-miner changing 1 files +48 −64
  1. yuvicc commented at 5:26 AM on November 9, 2026: contributor

    Part of #36692.

    Add MakeTx() and use it in TestPackageSelection and TestPrioritisedMining so each transaction is fully specified where it is created, instead of overwriting the prevout and nValue of the previous one. Also build the CreateBigSigOpsTx() and CreateBigSigOpsCluster() transactions in place.

    One implicit dependency is now explicit: BulkTransaction() pads the output script of hashFreeTx2, and the next two transactions inherited it. Their size matters for the fee rate checks, so the padded script is now passed to MakeTx() explicitly.

    The txid, wtxid and fee of every transaction added to the mempool are unchanged.

  2. DrahtBot commented at 5:26 AM on November 9, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK purpleKarrot, alexanderwiederin, maflcko

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. yuvicc renamed this:
    Test declarative miner
    test: construct `miner_tests` transactions declaratively
    on Nov 9, 2026
  4. DrahtBot added the label Tests on Nov 9, 2026
  5. DrahtBot added the label CI failed on Nov 9, 2026
  6. DrahtBot removed the label CI failed on Nov 9, 2026
  7. DrahtBot added the label CI failed on Nov 9, 2026
  8. in src/test/miner_tests.cpp:343 in 546d828c93
     339 | @@ -344,17 +340,11 @@ std::vector<CTransactionRef> CreateBigSigOpsCluster(const CTransactionRef& first
     340 |  
     341 |      CMutableTransaction tx;
     342 |      // block sigops > limit: 1000 CHECKMULTISIG + 1
     343 | -    tx.vin.resize(1);
     344 |      // NOTE: OP_NOP is used to force 20 SigOps for the CHECKMULTISIG
    


    alexanderwiederin commented at 6:46 PM on November 9, 2026:

    I think this can be removed.


    yuvicc commented at 5:57 AM on November 10, 2026:

    Done, removed.

  9. in src/test/miner_tests.cpp:295 in a0e8878eb2 outdated
     294 | +    };
     295 |      // Increase size to avoid rounding errors: when the feerate is extremely small (i.e. 1sat/kvB), evaluating the fee
     296 |      // at smaller sizes gives us rounded values that are equal to each other, which means we incorrectly include
     297 |      // hashFreeTx2 + hashLowFeeTx2.
     298 |      BulkTransaction(tx, 4000);
     299 | +    const CScript bulked_script_pub_key{tx.vout[0].scriptPubKey};
    


    alexanderwiederin commented at 8:07 PM on November 9, 2026:

    The children reusing the padded script looks incidental to me, but it has now become load-bearing for the vtx[8] check. A comment explaining why we need this would be useful.


    yuvicc commented at 6:05 AM on November 10, 2026:

    Good point. I checked, and the vtx[8] check does depend on it. With the padded script, hashLowFeeTx2 is ~981 vB and pays a 1 sat fee, so its feerate is about blockMinFeeRate (1 sat/kvB). That's below the hashFreeTx + hashLowFeeTx package, so it's selected last. Without the padding it's 61 vB (~16 sat/kvB), it's selected ahead of that package, and the test fails at vtx[8]. I added a comment explaining this.

  10. alexanderwiederin approved
  11. alexanderwiederin commented at 8:17 PM on November 9, 2026: contributor

    ACK 546d828c936ffdfdf192a8069e629e2b0c4eab9f

  12. test: construct miner_tests package selection transactions declaratively
    Add MakeTx() and use it in TestPackageSelection and TestPrioritisedMining
    to construct each transaction from its prevout and output value, instead
    of overwriting fields of the previous transaction.
    b2ce6c1727
  13. test: construct miner_tests sigops transactions declaratively
    Construct the inputs and outputs of CreateBigSigOpsTx() and the parent
    transaction of CreateBigSigOpsCluster() in place instead of resizing the
    vectors and assigning each field afterwards.
    8d33ffe47e
  14. yuvicc force-pushed on Nov 10, 2026
  15. yuvicc commented at 6:08 AM on November 10, 2026: contributor

    Addressed suggestion to add comment on children reusing the padded script in miner test.

  16. yuvicc commented at 7:18 AM on November 10, 2026: contributor

    Not sure about the CI failure here, the cause might be from macOS runner dropping socket.

  17. DrahtBot removed the label CI failed on Nov 10, 2026
  18. purpleKarrot commented at 1:00 PM on November 10, 2026: contributor

    It is surprising at first that MakeTx() returns a CMutableTransaction. But then it becomes clear that tx = MakeTx() requires operator= support, which CTransaction lacks, unfortunately. Anyway, when splitting the test into different cases, reassignment will no longer be an issue. But that may be done in a follow-up.

    ACK 8d33ffe47e38ebf84e2c832d426d307484a8d342

  19. DrahtBot requested review from alexanderwiederin on Nov 10, 2026
  20. alexanderwiederin commented at 1:12 PM on November 10, 2026: contributor

    ACK 8d33ffe47e38ebf84e2c832d426d307484a8d342

  21. maflcko commented at 1:44 PM on November 10, 2026: member

    review ACK 8d33ffe47e38ebf84e2c832d426d307484a8d342 🦆

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

    Signature:

    untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
    RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    trusted comment: review ACK 8d33ffe47e38ebf84e2c832d426d307484a8d342 🦆
    pyrNOR3CRF0U/PwtZHGNT/IQVgaejrS66lPZ58iGrq9QEDLevh/7EqKpbuxu8gg6eIBy7jcMrfj1xCcs9PQhBw==
    

    </details>

  22. fanquake merged this on Nov 10, 2026
  23. fanquake closed this on Nov 10, 2026

  24. yuvicc deleted the branch on Nov 10, 2026

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-11-18 16:51 UTC

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