#36156 mining: include chunks that exactly fill block limits
https://github.com/bitcoin/bitcoin/pull/36156 · · +16/-8 in 2 files, 2 commits · labels: Mining · draft
Goal
- Allow block templates to include transactions that bring weight or sigops exactly to limits
- Avoids leaving unused capacity at the tail of a block template
This pull request adjusts BlockAssembler limit checks to use strict greater-than comparisons rather than greater-than-or-equal. This permits chunks that bring the block template exactly to block_max_weight or MAX_BLOCK_SIGOPS_COST to be included.
Problem: BlockAssembler currently rejects chunks that would make block weight or sigops exactly equal to configured limits, even though consensus permits equality (BIP 141). This can leave unused capacity at the tail of a block template.
Category: Mining (#13 of 13)
P4 · bug fix
- P4 because the fee gain is marginal at under 1000 sats for a single tail transaction
- Block validity far outweighs minor fee optimizations for miners
P4 because the benefit of allowing exact-limit chunks is at most a single low-fee transaction at the tail of a block template (under 1000 sats, as ajtowns noted), which ranks low under the mining rubric where template validity far outweighs minor fee optimizations.
Membership: Changes BlockAssembler chunk selection limits in src/node/miner.cpp.
Factors: security/stability 0, bug 1, performance 0, user value 1, leverage 0
Reviewability: Ready
- Ready to review
- Code and tests are complete with passing CI
The code and tests are complete, CI passes, and no outstanding revision has been requested, although the author designated it a draft for concept feedback.
Author status: silent since opening the PR on 2026-09-03
Open concerns:
- ajtowns pointed out that off-by-one errors in limit calculations risk creating an invalid block and losing the entire block reward, whereas the upside is under 1000 sats in fees.
Agreement: Mild
- Concept approval to align assembler checks with consensus limits (ismaelsadeeq)
- Nonblocking objection: risk of an invalid block outweighs negligible fee gains under 1000 sats (ajtowns)
Concept ACK from ismaelsadeeq, but ajtowns objects that invalid block risks outweigh negligible fee gains.
ajtowns raised a concrete harm regarding the asymmetric risk of invalidating a block versus negligible fee gains, but unsubscribed and left it nonblocking. ismaelsadeeq supported aligning the code with consensus limits.
- ajtowns: 'the risk of a mistake here is that the block becomes invalid losing all possible reward... as compared to the subsidy of around $240k per block... removing a defensive buffer... there isn't [a significant win] here. Anyway, I've said my piece, I'll unsubscribe.'
- ismaelsadeeq: 'Concept ACK. Looks correct to me... more about making the block assembler code correct and reflect consensus allowed limits...'
Review verdicts (DrahtBot): 0
- Concept ACK: ismaelsadeeq
Files
20 lines under test/bench/ci.
- src/test/miner_tests.cpp +14/-6
- src/node/miner.cpp +2/-2
Card
This PR changes BlockAssembler chunk limit checks from >= to > so blocks can reach weight and sigops limits exactly rather than stopping short. It addresses an off-by-one underfill issue in block template assembly. The benefit is marginal: ajtowns pointed out that the upside is less than 1000 sats in fees while touching boundary checks risks generating an invalid block. While ismaelsadeeq offered a Concept ACK, the PR remains in draft awaiting conceptual resolution.