mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 13:42:10 +02:00
mining: reject invalid block create options
Check BlockCreateOptions before block template creation instead of clamping runtime values. This makes invalid runtime block creation options, including those passed by IPC mining clients, fail explicitly instead of silently mining with different values than the caller requested. Runtime option validation now uses the same error wording as startup option validation. Startup validation also rejects -blockmaxweight values lower than -blockreservedweight instead of allowing them to be clamped later. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -969,16 +969,6 @@ public:
|
||||
|
||||
std::unique_ptr<BlockTemplate> createNewBlock(const BlockCreateOptions& options, bool cooldown) override
|
||||
{
|
||||
// Reject too-small values instead of clamping so callers don't silently
|
||||
// end up mining with different options than requested. This matches the
|
||||
// behavior of the `-blockreservedweight` startup option, which rejects
|
||||
// values below MINIMUM_BLOCK_RESERVED_WEIGHT.
|
||||
if (options.block_reserved_weight && options.block_reserved_weight < MINIMUM_BLOCK_RESERVED_WEIGHT) {
|
||||
throw std::runtime_error(strprintf("block_reserved_weight (%zu) must be at least %u weight units",
|
||||
*options.block_reserved_weight,
|
||||
MINIMUM_BLOCK_RESERVED_WEIGHT));
|
||||
}
|
||||
|
||||
// Ensure m_tip_block is set so consumers of BlockTemplate can rely on that.
|
||||
std::optional<BlockRef> maybe_tip{waitTipChanged(uint256::ZERO, MillisecondsDouble::max())};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user