mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-17 21:32:00 +01:00
Merge a63bae6e281a9d4b0d4d6948550107683cf65d3b into 5f4422d68dc3530c353af1f87499de1c864b60ad
This commit is contained in:
commit
c2665c6a7d
@ -129,14 +129,16 @@ FUZZ_TARGET(mini_miner_selection, .init = initialize_miner)
|
|||||||
// Make a copy to preserve determinism.
|
// Make a copy to preserve determinism.
|
||||||
std::deque<COutPoint> available_coins = g_available_coins;
|
std::deque<COutPoint> available_coins = g_available_coins;
|
||||||
std::vector<CTransactionRef> transactions;
|
std::vector<CTransactionRef> transactions;
|
||||||
|
// The maximum block template size we expect to produce
|
||||||
|
const auto block_adjusted_max_weight = MAX_BLOCK_WEIGHT - MINIMUM_BLOCK_RESERVED_WEIGHT;
|
||||||
|
|
||||||
LOCK2(::cs_main, pool.cs);
|
LOCK2(::cs_main, pool.cs);
|
||||||
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 100)
|
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 500)
|
||||||
{
|
{
|
||||||
CMutableTransaction mtx = CMutableTransaction();
|
CMutableTransaction mtx = CMutableTransaction();
|
||||||
assert(!available_coins.empty());
|
assert(!available_coins.empty());
|
||||||
const size_t num_inputs = std::min(size_t{2}, available_coins.size());
|
const size_t num_inputs = std::min(size_t{2}, available_coins.size());
|
||||||
const size_t num_outputs = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(2, 5);
|
const size_t num_outputs = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(2, 50);
|
||||||
for (size_t n{0}; n < num_inputs; ++n) {
|
for (size_t n{0}; n < num_inputs; ++n) {
|
||||||
auto prevout = available_coins.at(0);
|
auto prevout = available_coins.at(0);
|
||||||
mtx.vin.emplace_back(prevout, CScript());
|
mtx.vin.emplace_back(prevout, CScript());
|
||||||
@ -158,7 +160,6 @@ FUZZ_TARGET(mini_miner_selection, .init = initialize_miner)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto block_adjusted_max_weight = MAX_BLOCK_WEIGHT - DEFAULT_BLOCK_RESERVED_WEIGHT;
|
|
||||||
// Stop if pool reaches block_adjusted_max_weight because BlockAssembler will stop when the
|
// Stop if pool reaches block_adjusted_max_weight because BlockAssembler will stop when the
|
||||||
// block template reaches that, but the MiniMiner will keep going.
|
// block template reaches that, but the MiniMiner will keep going.
|
||||||
if (pool.GetTotalTxSize() + GetVirtualTransactionSize(*tx) >= block_adjusted_max_weight) break;
|
if (pool.GetTotalTxSize() + GetVirtualTransactionSize(*tx) >= block_adjusted_max_weight) break;
|
||||||
@ -184,6 +185,11 @@ FUZZ_TARGET(mini_miner_selection, .init = initialize_miner)
|
|||||||
node::BlockAssembler::Options miner_options;
|
node::BlockAssembler::Options miner_options;
|
||||||
miner_options.blockMinFeeRate = target_feerate;
|
miner_options.blockMinFeeRate = target_feerate;
|
||||||
miner_options.nBlockMaxWeight = MAX_BLOCK_WEIGHT;
|
miner_options.nBlockMaxWeight = MAX_BLOCK_WEIGHT;
|
||||||
|
// Only setting reserved weight when necessary based on the template size
|
||||||
|
const auto reserved_weight = MAX_BLOCK_WEIGHT - pool.GetTotalTxSize();
|
||||||
|
if (reserved_weight < DEFAULT_BLOCK_RESERVED_WEIGHT) {
|
||||||
|
miner_options.block_reserved_weight = reserved_weight;
|
||||||
|
}
|
||||||
miner_options.test_block_validity = false;
|
miner_options.test_block_validity = false;
|
||||||
miner_options.coinbase_output_script = CScript() << OP_0;
|
miner_options.coinbase_output_script = CScript() << OP_0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user