Compare commits

...

6 commits

Author SHA1 Message Date
Fabian Jahr
1dfd7eecf1
Merge 5702c4410d into c5e44a0435 2025-04-29 11:55:52 +02:00
merge-script
c5e44a0435
Merge bitcoin/bitcoin#32369: test: Use the correct node for doubled keypath test
Some checks are pending
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Windows native, VS 2022 (push) Waiting to run
CI / Windows native, fuzz, VS 2022 (push) Waiting to run
CI / Linux->Windows cross, no tests (push) Waiting to run
CI / Windows, test cross-built (push) Blocked by required conditions
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
32d55e28af test: Use the correct node for doubled keypath test (Ava Chow)

Pull request description:

  #29124 had a silent merge conflict with #32350 which resulted in it using the wrong node. Fix the test to use the correct v22 node.

ACKs for top commit:
  maflcko:
    lgtm ACK 32d55e28af
  rkrux:
    ACK 32d55e28af
  BrandonOdiwuor:
    Code Review ACK 32d55e28af

Tree-SHA512: 1e0231985beb382b16e1d608c874750423d0502388db0c8ad450b22d17f9d96f5e16a6b44948ebda5efc750f62b60d0de8dd20131f449427426a36caf374af92
2025-04-29 09:59:42 +01:00
Ava Chow
32d55e28af test: Use the correct node for doubled keypath test 2025-04-28 14:44:17 -07:00
Fabian Jahr
5702c4410d
fuzz: Increase number of transactions in block in mini_miner test
At the current configuration there was zero chance to hit the size limit of a block. The new configuration uses larger transactions and conditionally adds the maximum possible number of transactions instead of using the previous limited while loop to ensure that with some regularity the test runs into full blocks.
2025-03-28 00:03:07 +01:00
Fabian Jahr
fd68e06908
fuzz: Fuzz reserved weight option in BlockAssembler 2025-03-27 23:49:33 +01:00
Fabian Jahr
0da2ae35c8
fuzz: Fix block size stop gap in mini_miner_selection
The check was comparing bytes (left) to WU (right). The check was not necessary so far because the test never hit high enough numbers for it to be actually necessary.
2025-03-27 23:46:10 +01:00
2 changed files with 38 additions and 6 deletions

View file

@ -129,14 +129,34 @@ FUZZ_TARGET(mini_miner_selection, .init = initialize_miner)
// Make a copy to preserve determinism.
std::deque<COutPoint> available_coins = g_available_coins;
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;
// When this is set to true we try to fill up the rest of the block with
// a lot of small transactions so we can actually get close to actual
// maximum block size
std::optional<bool> min_size_tx{std::nullopt};
// This decides if we target a larger, potentially full block or a smaller
// block that will complete the test much faster
bool use_limited_loop = fuzzed_data_provider.ConsumeBool();
auto should_continue = [&]() -> bool {
if (use_limited_loop) {
return fuzzed_data_provider.ConsumeBool();
}
return true;
};
LOCK2(::cs_main, pool.cs);
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 100)
// Limited to 500 because of ClusterMempool DoS protection
LIMITED_WHILE(should_continue(), 500)
{
CMutableTransaction mtx = CMutableTransaction();
assert(!available_coins.empty());
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);
size_t num_inputs = std::min(size_t{2}, available_coins.size());
size_t num_outputs = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(50, 500);
if (min_size_tx.has_value() && min_size_tx.value()) {
num_inputs = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 5);
num_outputs = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 5);
}
for (size_t n{0}; n < num_inputs; ++n) {
auto prevout = available_coins.at(0);
mtx.vin.emplace_back(prevout, CScript());
@ -158,10 +178,17 @@ 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
// 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)) * 4 >= block_adjusted_max_weight) {
// Either stop here or fill up the rest of the block with very small
// transactions and break when the block is close to the possible max
if (!min_size_tx.has_value()) {
min_size_tx = fuzzed_data_provider.ConsumeBool();
if (!min_size_tx.value()) break;
}
break;
}
TestMemPoolEntryHelper entry;
const CAmount fee{ConsumeMoney(fuzzed_data_provider, /*max=*/MAX_MONEY/100000)};
assert(MoneyRange(fee));
@ -184,6 +211,11 @@ FUZZ_TARGET(mini_miner_selection, .init = initialize_miner)
node::BlockAssembler::Options miner_options;
miner_options.blockMinFeeRate = target_feerate;
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() * 4;
if (reserved_weight < DEFAULT_BLOCK_RESERVED_WEIGHT) {
miner_options.block_reserved_weight = reserved_weight - 1;
}
miner_options.test_block_validity = false;
miner_options.coinbase_output_script = CScript() << OP_0;

View file

@ -87,7 +87,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
# 0.21.x and 22.x would both produce bad derivation paths when topping up an inactive hd chain
# Make sure that this is being automatically cleaned up by migration
node_master = self.nodes[1]
node_v22 = self.nodes[self.num_nodes - 5]
node_v22 = self.nodes[self.num_nodes - 3]
wallet_name = "bad_deriv_path"
node_v22.createwallet(wallet_name=wallet_name, descriptors=False)
bad_deriv_wallet = node_v22.get_wallet_rpc(wallet_name)