3 suggestions
Optional improvements
[suggestion] · Tests do not guard Block()'s parent-derived subsidy
The new exact-subsidy assertions exercise global BuildChain(), not MinerTestingSetup::Block(); restoring only Block()'s active-tip reward would leave its current forks valid, so that part of the fix lacks a regression guard.
Location: src/test/validation_block_tests.cpp:98 (head).
Details and suggested fix
Block() now obtains the subsidy through SwitchBlockParent() and transfers it to vout[1], but switch_block_parent_coinbase checks only global BuildChain(). In mempool_locks_reorg, the withheld forks span heights 1–124, 124–247, and 247–370 while the active tips are 123, 246, and 369. Their templates would pay 50, 25, and 12.5 BTC respectively, which is correct or too low for every fork block. Underpayment is valid, so the successful-reorg checks would not catch a subsidy-only regression. The ordering test stays at or below height 100. Add an exact-subsidy assertion on the existing reorg fork blocks, checking vout[1].nValue against GetBlockSubsidy(parent.nHeight + 1, consensus), to cover this caller without changing its behavior.
[suggestion] · SwitchBlockParent() documentation omits its reward and target rewrites
The declaration omits that SwitchBlockParent() replaces the reward with the parent-derived subsidy, rewrites the target and coinbase fields, and leaves proof of work unchecked; both current callers already recheck it.
Location: src/test/util/mining.h:30 (head).
Details and suggested fix
The comment describes changing the parent and timestamp and recomputing the merkle root, but the helper also recalculates nBits, sets nLockTime to the parent height, replaces scriptSig with the child height followed by OP_0, and overwrites vout[0].nValue with the child-height subsidy. Document these effects, particularly the unconditional reward replacement. Also state that nNonce remains unchanged and callers must recheck proof of work and mine if necessary before submitting the header. The existing BuildChain() loop and FinalizeBlock() already satisfy that requirement.
[suggestion] · The Block() migration introduces one-commit padding code
The subsidy commit migrates Block() before the helper supports padding, requiring a temporary OP_0 append that the next commit removes and making the reconstruction transition require review twice.
Location: src/test/validation_block_tests.cpp:110 at 5c4209eecb19 (commit) (commit).
Details and suggested fix
At commit 5c4209eecb19c5031be7a2ff8ddc99f2f113f367 itself (parent=null), the subsidy fix also migrates MinerTestingSetup::Block() to SwitchBlockParent(). Because the helper still emits only the height, Block() temporarily appends OP_0 locally. Commit e07fdd2a11acb49721e7a21c4cafa5a9b936894e moves padding into the helper and removes that append. The subsidy commit deliberately groups both callers' fixes, but this creates an otherwise unnecessary intermediate reconstruction arrangement.
Keep the helper subsidy change, coinbase-only assertion, and associated test expectation in the subsidy commit. Keep helper padding and its test updates in the padding commit, retaining Block()'s original local reconstruction until afterward. Then migrate Block() in a final commit, including use_mempool = false, the parent lookup, documentation, and removal of its local height, locktime, and padding rewrites. This leaves the final tree unchanged and lets the caller migration be reviewed in one step after its prerequisites exist.