mining: add block create option helpers
What changed, and why it matters
This commit is a straightforward internal code cleanup in Bitcoin Core's mining module. It moves block-template option handling into helper functions and makes the same option type usable by both internal callers and external IPC callers. The commit message explicitly says it does not change behavior, and the diff shows only minor message-string changes (dropping the word 'Specified' from some startup error messages). There is no indication of a security fix or vulnerability.
No security action required. Treat as normal code-review/merge refactoring. If desired, verify that the new CheckMiningOptions path is exercised on startup and that error messages are updated in release notes only if user-visible documentation references the old strings.
Security signals we found
No security-relevant change identified
Refactoring only: option type unification and helper extraction
Validation logic preserved and moved, not weakened
Commit message states 'This commit does not change behavior'
Evidence from the diff
The patch refactors BlockAssembler::Options into a shared BlockCreateOptions type defined in node/mining_types.h, adds FlattenMiningOptions() and MergeMiningOptions() helpers in node/mining_args, and updates callers in interfaces.cpp, rpc/mining.cpp, tests, and fuzzers. ClampOptions now calls FlattenMiningOptions before clamping. ReadMiningArgs now returns BlockCreateOptions instead of just validating. The only externally visible behavior change is the removal of ‘Specified ’ from three startup error strings in mining_basic.py. No bounds checks are removed; validation is preserved via CheckMiningOptions.
Changed components
src/node/miner.cppsrc/node/miner.hsrc/node/mining_args.cppsrc/node/mining_args.hsrc/node/mining_types.hsrc/node/interfaces.cppsrc/rpc/mining.cppInspect captured patch +150 / −84
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 7abd4b75..7a078c81 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -38,6 +38,7 @@
#include <node/interface_ui.h>
#include <node/mini_miner.h>
#include <node/miner.h>
+#include <node/mining_args.h>
#include <node/kernel_notifications.h>
#include <node/transaction.h>
#include <node/types.h>
@@ -86,6 +87,7 @@ using interfaces::Rpc;
using interfaces::WalletLoader;
using kernel::ChainstateRole;
using node::BlockAssembler;
+using node::BlockCreateOptions;
using node::BlockWaitOptions;
using node::CoinbaseTx;
using util::Join;
@@ -867,9 +869,9 @@ public:
class BlockTemplateImpl : public BlockTemplate
{
public:
- explicit BlockTemplateImpl(BlockAssembler::Options assemble_options,
+ explicit BlockTemplateImpl(BlockCreateOptions create_options,
std::unique_ptr<CBlockTemplate> block_template,
- const NodeContext& node) : m_assemble_options(std::move(assemble_options)),
+ const NodeContext& node) : m_create_options(std::move(create_options)),
m_block_template(std::move(block_template)),
m_node(node)
{
@@ -914,8 +916,14 @@ public:
std::unique_ptr<BlockTemplate> waitNext(BlockWaitOptions options) override
{
- auto new_template = WaitAndCreateNewBlock(chainman(), notifications(), m_node.mempool.get(), m_block_template, options, m_assemble_options, m_interrupt_wait);
- if (new_template) return std::make_unique<BlockTemplateImpl>(m_assemble_options, std::move(new_template), m_node);
+ auto new_template = WaitAndCreateNewBlock(chainman(),
+ notifications(),
+ m_node.mempool.get(),
+ m_block_template,
+ /*wait_options=*/options,
+ /*create_options=*/m_create_options,
+ /*interrupt_wait=*/m_interrupt_wait);
+ if (new_template) return std::make_unique<BlockTemplateImpl>(m_create_options, std::move(new_template), m_node);
return nullptr;
}
@@ -924,7 +932,7 @@ public:
InterruptWait(notifications(), m_interrupt_wait);
}
- const BlockAssembler::Options m_assemble_options;
+ const BlockCreateOptions m_create_options;
const std::unique_ptr<CBlockTemplate> m_block_template;
@@ -990,10 +998,15 @@ public:
// Also wait during the final catch-up moments after IBD.
if (!CooldownIfHeadersAhead(chainman(), notifications(), *maybe_tip, m_interrupt_mining)) return {};
}
-
- BlockAssembler::Options assemble_options{options};
- ApplyArgsManOptions(*Assert(m_node.args), assemble_options);
- return std::make_unique<BlockTemplateImpl>(assemble_options, BlockAssembler{chainman().ActiveChainstate(), m_node.mempool.get(), assemble_options}.CreateNewBlock(), m_node);
+ const auto args_options{*Assert(ReadMiningArgs(*Assert(m_node.args)))};
+ const BlockCreateOptions create_options{MergeMiningOptions(options, args_options)};
+ return std::make_unique<BlockTemplateImpl>(create_options,
+ BlockAssembler{
+ chainman().ActiveChainstate(),
+ m_node.mempool.get(),
+ create_options,
+ }.CreateNewBlock(),
+ m_node);
}
void interrupt() override
diff --git a/src/node/miner.cpp b/src/node/miner.cpp
index 41c1d997..e1b6a480 100644
--- a/src/node/miner.cpp
+++ b/src/node/miner.cpp
@@ -17,6 +17,7 @@
#include <deploymentstatus.h>
#include <node/context.h>
#include <node/kernel_notifications.h>
+#include <node/mining_args.h>
#include <policy/feerate.h>
#include <policy/policy.h>
#include <pow.h>
@@ -76,40 +77,27 @@ void RegenerateCommitments(CBlock& block, ChainstateManager& chainman)
block.hashMerkleRoot = BlockMerkleRoot(block);
}
-static BlockAssembler::Options ClampOptions(BlockAssembler::Options options)
+static BlockCreateOptions ClampOptions(BlockCreateOptions options)
{
- // Apply DEFAULT_BLOCK_RESERVED_WEIGHT and DEFAULT_BLOCK_MAX_WEIGHT when the caller left it unset.
- options.block_reserved_weight = std::clamp<uint64_t>(options.block_reserved_weight.value_or(DEFAULT_BLOCK_RESERVED_WEIGHT), MINIMUM_BLOCK_RESERVED_WEIGHT, MAX_BLOCK_WEIGHT);
+ options = FlattenMiningOptions(std::move(options));
+ options.block_reserved_weight = std::clamp<uint64_t>(*options.block_reserved_weight, MINIMUM_BLOCK_RESERVED_WEIGHT, MAX_BLOCK_WEIGHT);
options.coinbase_output_max_additional_sigops = std::clamp<size_t>(options.coinbase_output_max_additional_sigops, 0, MAX_BLOCK_SIGOPS_COST);
// 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.block_max_weight = std::clamp<uint64_t>(options.block_max_weight.value_or(DEFAULT_BLOCK_MAX_WEIGHT), *options.block_reserved_weight, MAX_BLOCK_WEIGHT);
+ options.block_max_weight = std::clamp<uint64_t>(*options.block_max_weight, *options.block_reserved_weight, MAX_BLOCK_WEIGHT);
return options;
}
-BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options)
+BlockAssembler::BlockAssembler(Chainstate& chainstate,
+ const CTxMemPool* mempool,
+ BlockCreateOptions options)
: chainparams{chainstate.m_chainman.GetParams()},
m_mempool{options.use_mempool ? mempool : nullptr},
m_chainstate{chainstate},
- m_options{ClampOptions(options)}
+ m_options{ClampOptions(std::move(options))}
{
}
-void ApplyArgsManOptions(const ArgsManager& args, BlockAssembler::Options& options)
-{
- // Block resource limits
- if (!options.block_max_weight) {
- options.block_max_weight = args.GetArg<uint64_t>("-blockmaxweight");
- }
- if (const auto blockmintxfee{args.GetArg("-blockmintxfee")}) {
- if (const auto parsed{ParseMoney(*blockmintxfee)}) options.blockMinFeeRate = CFeeRate{*parsed};
- }
- options.print_modified_fee = args.GetBoolArg("-printpriority", options.print_modified_fee);
- if (!options.block_reserved_weight) {
- options.block_reserved_weight = args.GetArg<uint64_t>("-blockreservedweight");
- }
-}
-
void BlockAssembler::resetBlock()
{
// Reserve space for fixed-size block header, txs count, and coinbase tx.
@@ -274,7 +262,7 @@ void BlockAssembler::AddToBlock(const CTxMemPoolEntry& entry)
nBlockSigOpsCost += entry.GetSigOpCost();
nFees += entry.GetFee();
- if (m_options.print_modified_fee) {
+ if (*m_options.print_modified_fee) {
LogInfo("fee rate %s txid %s\n",
CFeeRate(entry.GetModifiedFee(), entry.GetTxSize()).ToString(),
entry.GetTx().GetHash().ToString());
@@ -300,7 +288,7 @@ void BlockAssembler::addChunks()
while (selected_transactions.size() > 0) {
// Check to see if min fee rate is still respected.
- if (ByRatio{chunk_feerate_vsize} < ByRatio{m_options.blockMinFeeRate.GetFeePerVSize()}) {
+ if (ByRatio{chunk_feerate_vsize} < ByRatio{m_options.block_min_fee_rate->GetFeePerVSize()}) {
// Everything else we might consider has a lower feerate
return;
}
@@ -367,8 +355,8 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
KernelNotifications& kernel_notifications,
CTxMemPool* mempool,
const std::unique_ptr<CBlockTemplate>& block_template,
- const BlockWaitOptions& options,
- const BlockAssembler::Options& assemble_options,
+ const BlockWaitOptions& wait_options,
+ const BlockCreateOptions& create_options,
bool& interrupt_wait)
{
// Delay calculating the current template fees, just in case a new block
@@ -378,7 +366,7 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
// Alternate waiting for a new tip and checking if fees have risen.
// The latter check is expensive so we only run it once per second.
auto now{NodeClock::now()};
- const auto deadline = now + options.timeout;
+ const auto deadline = now + wait_options.timeout;
const MillisecondsDouble tick{1000};
const bool allow_min_difficulty{chainman.GetParams().GetConsensus().fPowAllowMinDifficultyBlocks};
@@ -425,12 +413,12 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
*
* We'll also create a new template if the tip changed during this iteration.
*/
- if (options.fee_threshold < MAX_MONEY || tip_changed) {
+ if (wait_options.fee_threshold < MAX_MONEY || tip_changed) {
auto new_tmpl{BlockAssembler{
chainman.ActiveChainstate(),
mempool,
- assemble_options}
- .CreateNewBlock()};
+ create_options
+ }.CreateNewBlock()};
// If the tip changed, return the new template regardless of its fees.
if (tip_changed) return new_tmpl;
@@ -442,8 +430,8 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
// Check if fees increased enough to return the new template
const CAmount new_fees = std::accumulate(new_tmpl->vTxFees.begin(), new_tmpl->vTxFees.end(), CAmount{0});
- Assume(options.fee_threshold != MAX_MONEY);
- if (new_fees >= current_fees + options.fee_threshold) return new_tmpl;
+ Assume(wait_options.fee_threshold != MAX_MONEY);
+ if (new_fees >= current_fees + wait_options.fee_threshold) return new_tmpl;
}
now = NodeClock::now();
diff --git a/src/node/miner.h b/src/node/miner.h
index b579dc68..fcb5649f 100644
--- a/src/node/miner.h
+++ b/src/node/miner.h
@@ -38,8 +38,6 @@ using interfaces::BlockRef;
namespace node {
class KernelNotifications;
-static const bool DEFAULT_PRINT_MODIFIED_FEE = false;
-
struct CBlockTemplate
{
CBlock block;
@@ -79,12 +77,9 @@ private:
Chainstate& m_chainstate;
public:
- struct Options : BlockCreateOptions {
- CFeeRate blockMinFeeRate{DEFAULT_BLOCK_MIN_TX_FEE};
- bool print_modified_fee{DEFAULT_PRINT_MODIFIED_FEE};
- };
-
- explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options);
+ explicit BlockAssembler(Chainstate& chainstate,
+ const CTxMemPool* mempool,
+ BlockCreateOptions create_options);
/** Construct a new block template */
std::unique_ptr<CBlockTemplate> CreateNewBlock();
@@ -95,7 +90,7 @@ public:
inline static std::optional<int64_t> m_last_block_weight{};
private:
- const Options m_options;
+ const BlockCreateOptions m_options;
// utility functions
/** Clear the block's state and prepare for assembling a new block */
@@ -131,9 +126,6 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
/** Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed */
void RegenerateCommitments(CBlock& block, ChainstateManager& chainman);
-/** Apply -blockmintxfee and -blockmaxweight options from ArgsManager to BlockAssembler options. */
-void ApplyArgsManOptions(const ArgsManager& gArgs, BlockAssembler::Options& options);
-
/* Compute the block's merkle root, insert or replace the coinbase transaction and the merkle root into the block */
void AddMerkleRootAndCoinbase(CBlock& block, CTransactionRef coinbase, uint32_t version, uint32_t timestamp, uint32_t nonce);
@@ -148,8 +140,8 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
KernelNotifications& kernel_notifications,
CTxMemPool* mempool,
const std::unique_ptr<CBlockTemplate>& block_template,
- const BlockWaitOptions& options,
- const BlockAssembler::Options& assemble_options,
+ const BlockWaitOptions& wait_options,
+ const BlockCreateOptions& create_options,
bool& interrupt_wait);
/* Locks cs_main and returns the block hash and block height of the active chain if it exists; otherwise, returns nullopt.*/
diff --git a/src/node/mining_args.cpp b/src/node/mining_args.cpp
index ece422a8..ef859655 100644
--- a/src/node/mining_args.cpp
+++ b/src/node/mining_args.cpp
@@ -6,13 +6,17 @@
#include <common/args.h>
#include <common/messages.h>
+#include <consensus/amount.h>
#include <consensus/consensus.h>
#include <node/mining_types.h>
+#include <policy/feerate.h>
+#include <policy/policy.h>
#include <tinyformat.h>
#include <util/moneystr.h>
#include <util/translation.h>
#include <cstdint>
+#include <optional>
using common::AmountErrMsg;
using util::Error;
@@ -20,28 +24,60 @@ using util::Result;
namespace node {
-Result<void> ReadMiningArgs(const ArgsManager& args)
+Result<void> CheckMiningOptions(const BlockCreateOptions& options, bool use_argnames)
{
- if (const auto arg{args.GetArg("-blockmintxfee")}) {
- if (!ParseMoney(*arg)) {
- return Error{AmountErrMsg("blockmintxfee", *arg)};
- }
+ if (options.block_max_weight && *options.block_max_weight > MAX_BLOCK_WEIGHT) {
+ return Error{Untranslated(strprintf("%s (%d) exceeds consensus maximum block weight (%d)",
+ use_argnames ? "-blockmaxweight" : "block_max_weight",
+ *options.block_max_weight, MAX_BLOCK_WEIGHT))};
}
-
- const uint64_t max_block_weight{args.GetArg<uint64_t>("-blockmaxweight", DEFAULT_BLOCK_MAX_WEIGHT)};
- if (max_block_weight > MAX_BLOCK_WEIGHT) {
- return Error{strprintf(_("Specified -blockmaxweight (%d) exceeds consensus maximum block weight (%d)"), max_block_weight, MAX_BLOCK_WEIGHT)};
+ if (options.block_reserved_weight && *options.block_reserved_weight > MAX_BLOCK_WEIGHT) {
+ return Error{Untranslated(strprintf("%s (%d) exceeds consensus maximum block weight (%d)",
+ use_argnames ? "-blockreservedweight" : "block_reserved_weight",
+ *options.block_reserved_weight, MAX_BLOCK_WEIGHT))};
}
-
- const uint64_t block_reserved_weight{args.GetArg<uint64_t>("-blockreservedweight", DEFAULT_BLOCK_RESERVED_WEIGHT)};
- if (block_reserved_weight > MAX_BLOCK_WEIGHT) {
- return Error{strprintf(_("Specified -blockreservedweight (%d) exceeds consensus maximum block weight (%d)"), block_reserved_weight, MAX_BLOCK_WEIGHT)};
+ if (options.block_reserved_weight && *options.block_reserved_weight < MINIMUM_BLOCK_RESERVED_WEIGHT) {
+ return Error{Untranslated(strprintf("%s (%d) is lower than minimum safety value of (%d)",
+ use_argnames ? "-blockreservedweight" : "block_reserved_weight",
+ *options.block_reserved_weight, MINIMUM_BLOCK_RESERVED_WEIGHT))};
}
- if (block_reserved_weight < MINIMUM_BLOCK_RESERVED_WEIGHT) {
- return Error{strprintf(_("Specified -blockreservedweight (%d) is lower than minimum safety value of (%d)"), block_reserved_weight, MINIMUM_BLOCK_RESERVED_WEIGHT)};
+ return {};
+}
+
+Result<BlockCreateOptions> ReadMiningArgs(const ArgsManager& args)
+{
+ BlockCreateOptions options;
+ if (const auto arg{args.GetArg("-blockmintxfee")}) {
+ std::optional<CAmount> block_min_tx_fee{ParseMoney(*arg)};
+ if (!block_min_tx_fee) return Error{AmountErrMsg("blockmintxfee", *arg)};
+ options.block_min_fee_rate = CFeeRate{*block_min_tx_fee};
}
- return {};
+ if (const auto arg{args.GetBoolArg("-printpriority")}) options.print_modified_fee = *arg;
+
+ options.block_reserved_weight = args.GetArg<uint64_t>("-blockreservedweight");
+ options.block_max_weight = args.GetArg<uint64_t>("-blockmaxweight");
+
+ if (auto result{CheckMiningOptions(options, /*use_argnames=*/true)}; !result) return Error{util::ErrorString(result)};
+ return options;
+}
+
+BlockCreateOptions FlattenMiningOptions(BlockCreateOptions options)
+{
+ if (!options.block_min_fee_rate) options.block_min_fee_rate = CFeeRate{DEFAULT_BLOCK_MIN_TX_FEE};
+ if (!options.print_modified_fee) options.print_modified_fee = DEFAULT_PRINT_MODIFIED_FEE;
+ if (!options.block_reserved_weight) options.block_reserved_weight = DEFAULT_BLOCK_RESERVED_WEIGHT;
+ if (!options.block_max_weight) options.block_max_weight = DEFAULT_BLOCK_MAX_WEIGHT;
+ return options;
+}
+
+BlockCreateOptions MergeMiningOptions(BlockCreateOptions x, const BlockCreateOptions& y)
+{
+ if (!x.block_min_fee_rate) x.block_min_fee_rate = y.block_min_fee_rate;
+ if (!x.print_modified_fee) x.print_modified_fee = y.print_modified_fee;
+ if (!x.block_reserved_weight) x.block_reserved_weight = y.block_reserved_weight;
+ if (!x.block_max_weight) x.block_max_weight = y.block_max_weight;
+ return x;
}
} // namespace node
diff --git a/src/node/mining_args.h b/src/node/mining_args.h
index 01e695ee..e3ebf959 100644
--- a/src/node/mining_args.h
+++ b/src/node/mining_args.h
@@ -5,13 +5,32 @@
#ifndef BITCOIN_NODE_MINING_ARGS_H
#define BITCOIN_NODE_MINING_ARGS_H
+#include <node/mining_types.h>
#include <util/result.h>
class ArgsManager;
namespace node {
-[[nodiscard]] util::Result<void> ReadMiningArgs(const ArgsManager& args);
+static const bool DEFAULT_PRINT_MODIFIED_FEE = false;
+
+/**
+ * Read the mining options set in \p args. Returns an error if one was
+ * encountered.
+ */
+[[nodiscard]] util::Result<BlockCreateOptions> ReadMiningArgs(const ArgsManager& args);
+
+/** Check option values for validity. Returns an error for invalid values. */
+[[nodiscard]] util::Result<void> CheckMiningOptions(const BlockCreateOptions& options, bool use_argnames);
+
+/** Replace null optional values with their hardcoded defaults. */
+[[nodiscard]] BlockCreateOptions FlattenMiningOptions(BlockCreateOptions options);
+
+/**
+ * Merge two BlockCreateOptions structs, replacing null values in \p x with
+ * non-null values from \p y.
+ */
+[[nodiscard]] BlockCreateOptions MergeMiningOptions(BlockCreateOptions x, const BlockCreateOptions& y);
} // namespace node
diff --git a/src/node/mining_types.h b/src/node/mining_types.h
index 30206c2e..6e3ee0f4 100644
--- a/src/node/mining_types.h
+++ b/src/node/mining_types.h
@@ -12,7 +12,7 @@
#define BITCOIN_NODE_MINING_TYPES_H
#include <consensus/amount.h>
-#include <consensus/consensus.h>
+#include <policy/feerate.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <script/script.h>
@@ -26,11 +26,26 @@
namespace node {
+/**
+ * Block template creation options. These override node defaults, but can't
+ * exceed node limits (e.g. block_reserved_weight can't exceed max block weight).
+ */
struct BlockCreateOptions {
/**
* Set false to omit mempool transactions
*/
bool use_mempool{true};
+ /**
+ * Minimum fee rate for transactions to be included. Providing a value
+ * overrides the -blockmintxfee startup setting.
+ */
+ std::optional<CFeeRate> block_min_fee_rate{};
+ /**
+ * Whether to log the fee rate of each transaction when it is added to the
+ * block template. Providing a value overrides the -printpriority startup
+ * setting.
+ */
+ std::optional<bool> print_modified_fee{};
/**
* The default reserved weight for the fixed-size block header,
* transaction count and coinbase transaction. Minimum: 2000 weight units
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 223569fd..62e64a54 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -22,6 +22,8 @@
#include <net.h>
#include <node/context.h>
#include <node/miner.h>
+#include <node/mining_args.h>
+#include <node/mining_types.h>
#include <node/warnings.h>
#include <policy/ephemeral_policy.h>
#include <pow.h>
@@ -463,7 +465,7 @@ static RPCMethod getmininginfo()
CBlockIndex& tip{*CHECK_NONFATAL(active_chain.Tip())};
UniValue obj(UniValue::VOBJ);
- obj.pushKV("blocks", active_chain.Height());
+ obj.pushKV("blocks", active_chain.Height());
if (BlockAssembler::m_last_block_weight) obj.pushKV("currentblockweight", *BlockAssembler::m_last_block_weight);
if (BlockAssembler::m_last_block_num_txs) obj.pushKV("currentblocktx", *BlockAssembler::m_last_block_num_txs);
obj.pushKV("bits", strprintf("%08x", tip.nBits));
@@ -471,9 +473,8 @@ static RPCMethod getmininginfo()
obj.pushKV("target", GetTarget(tip, chainman.GetConsensus().powLimit).GetHex());
obj.pushKV("networkhashps", getnetworkhashps().HandleRequest(request));
obj.pushKV("pooledtx", mempool.size());
- BlockAssembler::Options assembler_options;
- ApplyArgsManOptions(*node.args, assembler_options);
- obj.pushKV("blockmintxfee", ValueFromAmount(assembler_options.blockMinFeeRate.GetFeePerK()));
+ const auto options{node::FlattenMiningOptions(*Assert(node::ReadMiningArgs(*node.args)))};
+ obj.pushKV("blockmintxfee", ValueFromAmount(CHECK_NONFATAL(options.block_min_fee_rate)->GetFeePerK()));
obj.pushKV("chain", chainman.GetParams().GetChainTypeString());
UniValue next(UniValue::VOBJ);
diff --git a/src/test/fuzz/cmpctblock.cpp b/src/test/fuzz/cmpctblock.cpp
index 85e3bedf..7808acba 100644
--- a/src/test/fuzz/cmpctblock.cpp
+++ b/src/test/fuzz/cmpctblock.cpp
@@ -121,7 +121,7 @@ void ResetChainmanAndMempool(TestingSetup& setup)
setup.m_make_chainman();
setup.LoadVerifyActivateChainstate();
- node::BlockAssembler::Options options;
+ node::BlockCreateOptions options;
options.coinbase_output_script = P2WSH_OP_TRUE;
g_mature_coinbase.clear();
diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp
index 9cada5df..b7279990 100644
--- a/src/test/fuzz/tx_pool.cpp
+++ b/src/test/fuzz/tx_pool.cpp
@@ -22,6 +22,7 @@
#include <validationinterface.h>
using node::BlockAssembler;
+using node::BlockCreateOptions;
using node::NodeContext;
using util::ToString;
@@ -93,9 +94,10 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, Cha
{
WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));
{
- BlockAssembler::Options options;
- options.block_max_weight = fuzzed_data_provider.ConsumeIntegralInRange(0U, MAX_BLOCK_WEIGHT);
- options.blockMinFeeRate = CFeeRate{ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)};
+ BlockCreateOptions options{
+ .block_min_fee_rate = CFeeRate{ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)},
+ .block_max_weight = fuzzed_data_provider.ConsumeIntegralInRange(0U, MAX_BLOCK_WEIGHT),
+ };
auto assembler = BlockAssembler{chainstate, &tx_pool, options};
auto block_template = assembler.CreateNewBlock();
Assert(block_template->block.vtx.size() >= 1);
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp
index 5b5b6c3a..6f2855c8 100644
--- a/src/test/miner_tests.cpp
+++ b/src/test/miner_tests.cpp
@@ -181,7 +181,7 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const
const auto block_package_feerates = BlockAssembler{
m_node.chainman->ActiveChainstate(),
&tx_mempool,
- {}
+ BlockCreateOptions{},
}.CreateNewBlock()->m_package_feerates;
BOOST_CHECK(block_package_feerates.size() == 2);
diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py
index bb53f736..2f6f1146 100755
--- a/test/functional/mining_basic.py
+++ b/test/functional/mining_basic.py
@@ -357,21 +357,21 @@ class MiningTest(BitcoinTestFramework):
self.stop_node(0)
self.nodes[0].assert_start_raises_init_error(
extra_args=[f"-blockreservedweight={MAX_BLOCK_WEIGHT + 1}"],
- expected_msg=f"Error: Specified -blockreservedweight ({MAX_BLOCK_WEIGHT + 1}) exceeds consensus maximum block weight ({MAX_BLOCK_WEIGHT})",
+ expected_msg=f"Error: -blockreservedweight ({MAX_BLOCK_WEIGHT + 1}) exceeds consensus maximum block weight ({MAX_BLOCK_WEIGHT})",
)
self.log.info(f"Test that node will fail to start when user provide -blockreservedweight below {MINIMUM_BLOCK_RESERVED_WEIGHT}")
self.stop_node(0)
self.nodes[0].assert_start_raises_init_error(
extra_args=[f"-blockreservedweight={MINIMUM_BLOCK_RESERVED_WEIGHT - 1}"],
- expected_msg=f"Error: Specified -blockreservedweight ({MINIMUM_BLOCK_RESERVED_WEIGHT - 1}) is lower than minimum safety value of ({MINIMUM_BLOCK_RESERVED_WEIGHT})",
+ expected_msg=f"Error: -blockreservedweight ({MINIMUM_BLOCK_RESERVED_WEIGHT - 1}) is lower than minimum safety value of ({MINIMUM_BLOCK_RESERVED_WEIGHT})",
)
self.log.info("Test that node will fail to start when user provide invalid -blockmaxweight")
self.stop_node(0)
self.nodes[0].assert_start_raises_init_error(
extra_args=[f"-blockmaxweight={MAX_BLOCK_WEIGHT + 1}"],
- expected_msg=f"Error: Specified -blockmaxweight ({MAX_BLOCK_WEIGHT + 1}) exceeds consensus maximum block weight ({MAX_BLOCK_WEIGHT})",
+ expected_msg=f"Error: -blockmaxweight ({MAX_BLOCK_WEIGHT + 1}) exceeds consensus maximum block weight ({MAX_BLOCK_WEIGHT})",
)
def test_height_in_locktime(self):
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.