test: construct miner_tests transactions declaratively #36810

Manually merged
yuvicc merged 2 commits from test-declarative-miner into master 2026-11-10 14:28:29 +00:00 AGit
yuvicc commented 2026-11-09 05:26:32 +00:00 (Migrated from github.com)

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.

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.
DrahtBot commented 2026-11-09 05:26:40 +00:00 (Migrated from github.com)

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

External sites

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 <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36810 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36810.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36810#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [purpleKarrot](https://github.com/bitcoin/bitcoin/pull/36810#issuecomment-6767977745), [alexanderwiederin](https://github.com/bitcoin/bitcoin/pull/36810#issuecomment-6768249946), [maflcko](https://github.com/bitcoin/bitcoin/pull/36810#issuecomment-6768941971) | 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-->
First-time contributor

No verified findings are available from this review.

Review coverage was incomplete.


Reviewed: 8d33ffe47e38 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:7eebed8027c96ac27bcd79eeb7a88e35799cd96eb8fbacf34d3257986a959f64:6952af7d31ef83bb85ac4ee73e8c979307f4998f73396eb2a639b474cdfe83e6 --> <!-- ralph-base:44901d8f64cb617714707bd025ecd83f108353c2 --> <!-- ralph-head:8d33ffe47e38ebf84e2c832d426d307484a8d342 --> <!-- ralph-case:c191872f5a53a2c48bc4f033a5ae8d83a27b10e7b04714ac3687c5f5dda03035 --> No verified findings are available from this review. Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`8d33ffe47e38`](<https://git.fish.foo/bitcoin/bitcoin/commit/8d33ffe47e38ebf84e2c832d426d307484a8d342>) · [Review report](<https://review.fish.foo/report/36810-8d33ffe47e38ebf84e2c832d426d307484a8d342-2438-2.html>) · [Previous reports](<https://review.fish.foo/traces/36810/>) [permalink](<https://review.fish.foo/report/36810-8d33ffe47e38ebf84e2c832d426d307484a8d342-2438-2.html>)
alexanderwiederin (Migrated from github.com) approved these changes 2026-11-09 20:17:12 +00:00
alexanderwiederin (Migrated from github.com) left a comment
ACK 546d828c936ffdfdf192a8069e629e2b0c4eab9f
alexanderwiederin (Migrated from github.com) commented 2026-11-09 20:07:42 +00:00

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.

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.
alexanderwiederin (Migrated from github.com) commented 2026-11-09 18:46:39 +00:00

I think this can be removed.

I think this can be removed.
yuvicc (Migrated from github.com) reviewed 2026-11-10 05:57:05 +00:00
yuvicc (Migrated from github.com) commented 2026-11-10 05:57:05 +00:00

Done, removed.

Done, removed.
yuvicc (Migrated from github.com) reviewed 2026-11-10 06:05:50 +00:00
yuvicc (Migrated from github.com) commented 2026-11-10 06:05:50 +00:00

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.

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.
yuvicc commented 2026-11-10 06:08:01 +00:00 (Migrated from github.com)

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

Addressed [suggestion](https://github.com/bitcoin/bitcoin/pull/36810#discussion_r4517405746) to add comment on children reusing the padded script in miner test.
yuvicc commented 2026-11-10 07:18:56 +00:00 (Migrated from github.com)

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

Not sure about the CI failure here, the cause might be from macOS runner dropping socket.
purpleKarrot commented 2026-11-10 13:00:08 +00:00 (Migrated from github.com)

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 8d33ffe47e

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
alexanderwiederin commented 2026-11-10 13:12:59 +00:00 (Migrated from github.com)
ACK 8d33ffe47e38ebf84e2c832d426d307484a8d342
maflcko commented 2026-11-10 13:44:49 +00:00 (Migrated from github.com)

review ACK 8d33ffe47e 🦆

Show signature

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==
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>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36810
No description provided.