Skip to content

Commit a60445c

Browse files
committed
Merge bitcoin#32355: Bugfix: Miner: Don't reuse block_reserved_weight for "block is full enough to give up" weight delta
524f981 Bugfix: Miner: Don't reuse block_reserved_weight for "block is full enough to give up" weight delta (Luke Dashjr) Pull request description: PR bitcoin#30356 incorrectly changed a constant of `4000` to `m_options.coinbase_max_additional_weight` in the check for when to give up finding another transaction to fill the block: ```diff if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockWeight > - m_options.nBlockMaxWeight - 4000) { + m_options.nBlockMaxWeight - m_options.block_reserved_weight) { // Give up if we're close to full and haven't succeeded in a while break; } ``` But this constant did not deal with the reserved weight at all. It was in fact simply checking if the block was close to full, and if so, giving up finding another transaction to pad it with after `MAX_CONSECUTIVE_FAILURES` failed attempts. It doesn't seem very logical to reuse the reserve weight for this purpose, and it would be overcomplicated to add yet another setting, so this PR changes it to a new constexpr. ACKs for top commit: achow101: ACK 524f981 darosior: utACK 524f981 ismaelsadeeq: ACK 524f981 Tree-SHA512: c066debc34a021380424bd21b40444071b736325e41779a41590c2c8a6822ceeaf910fe067817c1dba108210b24c574977b0350b29520502e7af79d3b405928b
2 parents 2d5b424 + 524f981 commit a60445c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/node/miner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
311311
// close to full; this is just a simple heuristic to finish quickly if the
312312
// mempool has a lot of entries.
313313
const int64_t MAX_CONSECUTIVE_FAILURES = 1000;
314+
constexpr int32_t BLOCK_FULL_ENOUGH_WEIGHT_DELTA = 4000;
314315
int64_t nConsecutiveFailed = 0;
315316

316317
while (mi != mempool.mapTx.get<ancestor_score>().end() || !mapModifiedTx.empty()) {
@@ -392,7 +393,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
392393
++nConsecutiveFailed;
393394

394395
if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockWeight >
395-
m_options.nBlockMaxWeight - m_options.block_reserved_weight) {
396+
m_options.nBlockMaxWeight - BLOCK_FULL_ENOUGH_WEIGHT_DELTA) {
396397
// Give up if we're close to full and haven't succeeded in a while
397398
break;
398399
}

0 commit comments

Comments
 (0)