miner: bugfix: fix duplicate weight reservation in block assembler
- This commit renamed coinbase_max_additional_weight to block_reserved_weight. - Also clarify that the reservation is for block header, transaction count and coinbase transaction.
This commit is contained in:
8 files changed
+23
-17
No files matched your search
+7
-7
@@ -67,11 +67,11 @@ void RegenerateCommitments(CBlock& block, ChainstateManager& chainman)
|
||||
|
||||
static BlockAssembler::Options ClampOptions(BlockAssembler::Options options)
|
||||
{
|
||||
Assert(options.coinbase_max_additional_weight <= DEFAULT_BLOCK_MAX_WEIGHT);
|
||||
Assert(options.block_reserved_weight <= MAX_BLOCK_WEIGHT);
|
||||
Assert(options.coinbase_output_max_additional_sigops <= MAX_BLOCK_SIGOPS_COST);
|
||||
// Limit weight to between coinbase_max_additional_weight and DEFAULT_BLOCK_MAX_WEIGHT for sanity:
|
||||
// Coinbase (reserved) outputs can safely exceed -blockmaxweight, but the rest of the block template will be empty.
|
||||
options.nBlockMaxWeight = std::clamp<size_t>(options.nBlockMaxWeight, options.coinbase_max_additional_weight, DEFAULT_BLOCK_MAX_WEIGHT);
|
||||
// Limit weight to between block_reserved_weight and MAX_BLOCK_WEIGHT for sanity:
|
||||
// block_reserved_weight can safely exceed -blockmaxweight, but the rest of the block template will be empty.
|
||||
options.nBlockMaxWeight = std::clamp<size_t>(options.nBlockMaxWeight, options.block_reserved_weight, MAX_BLOCK_WEIGHT);
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ void BlockAssembler::resetBlock()
|
||||
{
|
||||
inBlock.clear();
|
||||
|
||||
// Reserve space for coinbase tx
|
||||
nBlockWeight = m_options.coinbase_max_additional_weight;
|
||||
// Reserve space for fixed-size block header, txs count, and coinbase tx.
|
||||
nBlockWeight = m_options.block_reserved_weight;
|
||||
nBlockSigOpsCost = m_options.coinbase_output_max_additional_sigops;
|
||||
|
||||
// These counters do not include coinbase tx
|
||||
@@ -386,7 +386,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
|
||||
++nConsecutiveFailed;
|
||||
|
||||
if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockWeight >
|
||||
m_options.nBlockMaxWeight - m_options.coinbase_max_additional_weight) {
|
||||
m_options.nBlockMaxWeight - m_options.block_reserved_weight) {
|
||||
// Give up if we're close to full and haven't succeeded in a while
|
||||
break;
|
||||
}
|
||||
|
||||
+4
-4
@@ -14,6 +14,7 @@
|
||||
#define BITCOIN_NODE_TYPES_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <policy/policy.h>
|
||||
#include <script/script.h>
|
||||
|
||||
namespace node {
|
||||
@@ -34,11 +35,10 @@ struct BlockCreateOptions {
|
||||
*/
|
||||
bool use_mempool{true};
|
||||
/**
|
||||
* The maximum additional weight which the pool will add to the coinbase
|
||||
* scriptSig, witness and outputs. This must include any additional
|
||||
* weight needed for larger CompactSize encoded lengths.
|
||||
* The default reserved weight for the fixed-size block header,
|
||||
* transaction count and coinbase transaction.
|
||||
*/
|
||||
size_t coinbase_max_additional_weight{4000};
|
||||
size_t block_reserved_weight{DEFAULT_BLOCK_RESERVED_WEIGHT};
|
||||
/**
|
||||
* The maximum additional sigops which the pool will add in coinbase
|
||||
* transaction outputs.
|
||||
|
||||
Reference in new issue
Block a user