From 7392b8b084be14b75536887b7ff216152d0a3307 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 19 Aug 2025 16:52:02 -0400 Subject: [PATCH] miner: clamp options instead of asserting --- src/node/miner.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/node/miner.cpp b/src/node/miner.cpp index 02a7684178c..a08c70e29da 100644 --- a/src/node/miner.cpp +++ b/src/node/miner.cpp @@ -77,9 +77,8 @@ void RegenerateCommitments(CBlock& block, ChainstateManager& chainman) static BlockAssembler::Options ClampOptions(BlockAssembler::Options options) { - Assert(options.block_reserved_weight <= MAX_BLOCK_WEIGHT); - Assert(options.block_reserved_weight >= MINIMUM_BLOCK_RESERVED_WEIGHT); - Assert(options.coinbase_output_max_additional_sigops <= MAX_BLOCK_SIGOPS_COST); + options.block_reserved_weight = std::clamp(options.block_reserved_weight, MINIMUM_BLOCK_RESERVED_WEIGHT, MAX_BLOCK_WEIGHT); + options.coinbase_output_max_additional_sigops = std::clamp(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.nBlockMaxWeight = std::clamp(options.nBlockMaxWeight, options.block_reserved_weight, MAX_BLOCK_WEIGHT);