test: fix coinbases built on arbitrary parents

bitcoin/bitcoin: PR #36109

2 suggestions

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Optional improvements

Link

[suggestion] · The Block() subsidy change lacks a distinguishing assertion

The new subsidy assertions cover BuildChain(), but the tests using MinerTestingSetup::Block() would still accept its previous active-tip template reward.

Location: src/test/validation_block_tests.cpp:98 (head).

Details and suggested fix

SwitchBlockParent() now derives the subsidy from the supplied parent, and Block() transfers that value into vout[1]. However, switch_block_parent_coinbase exercises only the global BuildChain() helper. In mempool_locks_reorg, the withheld forks cover heights 1–124, 124–247 and 247–370 while the active tips remain at 123, 246 and 369. The corresponding template subsidies are exact or too small for every fork block, and underpayment is valid, so successful reorgs do not establish that Block() uses the parent-derived subsidy. The signals-ordering test stays below the first halving. Add an exact-subsidy assertion on each withheld fork block's vout[1].nValue, using its actual parent height. That would catch restoring the template reward in Block() alone.


Link

[suggestion] · The Block() migration spans the subsidy and padding commits

The series temporarily rewrites Block()'s coinbase input script twice; migrating the caller after the padding change would make that migration independently reviewable without changing the final tree.

Location: src/test/validation_block_tests.cpp:98 at 5cdbfd5f01a2 (commit) (commit).

Details and suggested fix

Commit 5cdbfd5f01a27e1068f05b21b12c8f269083a4dc adds the helper's subsidy calculation and coinbase-only assertion, but also migrates MinerTestingSetup::Block(). That migration disables mempool selection and adopts the parent-derived target introduced by 33bbf91e1ae661e98017049d0315974a1f772255. At this point, the helper writes an unpadded scriptSig, which Block() immediately replaces with its existing padded script. Commit b7b762880e7583a06429f9eca525670a2ee18e5e then pads the helper's script and removes that overwrite. The subsidy commit explicitly describes sharing the reconstruction, so this is a sequencing suggestion rather than an undisclosed change or a final-tree defect.

Keep the helper subsidy, assertion and BuildChain() subsidy expectation in the subsidy commit, apply the helper padding next, then migrate Block() in a final commit. That final commit can add .use_mempool = false, call the helper, remove the local field rewrites, and carry the documentation and explanation of the reorg tests' underpayment. BuildChain() already disables mempool selection, and Block() can retain its existing padding until it migrates. This preserves dependencies and the final tree while avoiding the temporary duplicate rewrite.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.