Skip to content

Commit bbe8e90

Browse files
committed
fuzz: don't bypass_limits for most mempool harnesses
Using bypass_limits=true is essentially fuzzing part of a reorg only, and results in TRUC invariants unable to be checked. Remove most instances of bypassing limits, leaving one harness able to do so.
1 parent 65e909d commit bbe8e90

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/test/fuzz/package_eval.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool)
325325
return ProcessNewPackage(chainstate, tx_pool, txs, /*test_accept=*/single_submit, /*client_maxfeerate=*/{}));
326326

327327
const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, txs.back(), GetTime(),
328-
/*bypass_limits=*/fuzzed_data_provider.ConsumeBool(), /*test_accept=*/!single_submit));
328+
/*bypass_limits=*/false, /*test_accept=*/!single_submit));
329329

330330
if (!single_submit && result_package.m_state.GetResult() != PackageValidationResult::PCKG_POLICY) {
331331
// We don't know anything about the validity since transactions were randomly generated, so

src/test/fuzz/tx_pool.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
296296
std::set<CTransactionRef> added;
297297
auto txr = std::make_shared<TransactionsDelta>(removed, added);
298298
node.validation_signals->RegisterSharedValidationInterface(txr);
299-
const bool bypass_limits = fuzzed_data_provider.ConsumeBool();
300299

301300
// Make sure ProcessNewPackage on one transaction works.
302301
// The result is not guaranteed to be the same as what is returned by ATMP.
@@ -311,7 +310,7 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
311310
it->second.m_result_type == MempoolAcceptResult::ResultType::INVALID);
312311
}
313312

314-
const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), bypass_limits, /*test_accept=*/false));
313+
const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), /*bypass_limits=*/false, /*test_accept=*/false));
315314
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
316315
node.validation_signals->SyncWithValidationInterfaceQueue();
317316
node.validation_signals->UnregisterSharedValidationInterface(txr);
@@ -394,6 +393,9 @@ FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
394393

395394
chainstate.SetMempool(&tx_pool);
396395

396+
// If we ever bypass limits, do not do TRUC invariants checks
397+
bool ever_bypassed_limits{false};
398+
397399
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 300)
398400
{
399401
const auto mut_tx = ConsumeTransaction(fuzzed_data_provider, txids);
@@ -412,13 +414,17 @@ FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
412414
tx_pool.PrioritiseTransaction(txid, delta);
413415
}
414416

417+
const bool bypass_limits{fuzzed_data_provider.ConsumeBool()};
418+
ever_bypassed_limits |= bypass_limits;
419+
415420
const auto tx = MakeTransactionRef(mut_tx);
416-
const bool bypass_limits = fuzzed_data_provider.ConsumeBool();
417421
const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), bypass_limits, /*test_accept=*/false));
418422
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
419423
if (accepted) {
420424
txids.push_back(tx->GetHash());
421-
CheckMempoolTRUCInvariants(tx_pool);
425+
if (!ever_bypassed_limits) {
426+
CheckMempoolTRUCInvariants(tx_pool);
427+
}
422428
}
423429
}
424430
Finish(fuzzed_data_provider, tx_pool, chainstate);

0 commit comments

Comments
 (0)