Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36156. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
This seems backwards to me: the risk of a mistake here is that the block becomes invalid losing all possible reward from mining it, while the benefit of success is perhaps a single larger / additional transaction at the bottom of the block. Currently the bottom transaction in a block seems to pay less than 1000sats in total fees, so generously, that's less than 80c per block, as compared to the subsidy of around $240k per block. |
|
Concept ACK Looks correct to me.
This fix seems straightforward and correct, with good tests. Will the mistake come from the individual chunks sigops or weight accounting error? If indeed we do have that error, we still could end up creating an invalid block even without this fix. If we are confident that our accounting of weight and sigops is correct without this PR, and that the block assembler will not create an invalid block, then fixing this issue is okay.
I think it's less about the revenue but more about making the block assembler code correct and reflect consensus allowed limits, and making it explicit that filled blocks may be created, are valid and will be accepted as part of the blockchain. For me the more risky part is when we allow this minor bugs in the code, it incentivise pool companies to patch the code themselves to fix it, fwiw F2Pool did fix these bugs and have their custom binaries which create filled blocks. |
The issue you're referencing was in regards to 500vb of wasted space, versus this PR which is a delta of 1vb of space. The block you're referring to has a 2127 WU unused: It's certainly bad if mining pools introduce bugs in their software that invalidate blocks while trying to get to the very edge of valid behaviour, but at least it only impacts a single pool that way. I don't see why we would want to play the same stupid game and risk winning the same stupid prize. Off by one errors are common; removing a defensive buffer against that might be appropriate if there was a significant win to be had, but there isn't here. Anyway, I've said my piece, I'll unsubscribe. |
Record that `BlockAssembler` omits a chunk at `block_max_weight` exactly, while rejecting one weight unit over.
The configured `block_max_weight` is inclusive, so accept a chunk whose accounted weight reaches it exactly.
Record that `BlockAssembler` omits a chunk at `MAX_BLOCK_SIGOPS_COST` exactly, while rejecting one cost unit over.
Consensus permits the sigops cost limit exactly, so accept chunks that reach `MAX_BLOCK_SIGOPS_COST`.
dc73908 to
8e7de8e
Compare
|
While looking into why the current check uses I understand the concern about risking an invalid block for such a small gain, so I added test cases one unit over each limit and clarified the existing reservations in the docs. I’d like to hear how others weigh that against the risk. |
Problem:
BlockAssemblerfills block templates with mempool chunks that fit the configured weight limit and the consensus sigops limit, but currently rejects a chunk when it brings either total exactly to its limit.Equality is valid because
block_max_weightis a maximum and BIP 141 defines both consensus limits using≤.The
>=checks can therefore leave valid capacity unused and omit a fee-paying chunk.Mining option validation also permits
block_max_weight == MAX_BLOCK_WEIGHTandcoinbase_output_max_additional_sigops == MAX_BLOCK_SIGOPS_COST, while the chunk checks reject an accounted total equal to either limit.A 2016 review comment on the original package-selection PR raised the same inclusive-limit point.
Fix: Use strict greater-than comparisons so exact-limit chunks are included.
Extend the existing chunk-limit test to cover exact fits and one-unit overages for both weight and sigops.
Clarify how mining software reserves weight and sigops for the completed block.
This addresses the first issue in #35596.