Partially fixes #35596
When assembling a block template, BlockAssembler::addChunks() adds chunks of transactions until the block is close to being full. For each chunk, TestChunkBlockLimits() checks both the weight and the sigop-cost limits before the chunk is included.
The weight check compared the chunk's sigops-adjusted weight against block_max_weight:
if (nBlockWeight + chunk_feerate.size >= m_options.block_max_weight) {
return false;
}
Whereas nBlockWeight accumulates the actual chunk weight.
A chunk whose sigop-adjusted weight exceeds the actual weight can be wrongly skipped even though the block sigop limit is enforced independently on the next line, and that could pass. Those chunks pay higher fees, so this could potentially cause miners to needlessly forfeit some fees revenue.
This PR fixes this by passing the chunk's real weight (sum of GetTxWeight(), accumulated in the same loop that already sums sigop cost) to TestChunkBlockLimits(). The separate sigop-cost check is unchanged.
The first commit adds
TestSigOpsAdjustedWeightChunkLimit: it builds one sigop-dense transaction sized to fit by real weight but not by adjusted weight, and asserts that the tx is skipped and only the coinbase is mined.The second commit applies the fix and flips the assertion to show the transaction is now included.