Skip to content

Commit ffffdc4

Browse files
instagibbsfanquake
authored andcommitted
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. Github-Pull: bitcoin#33504 Rebased-From: bbe8e90
1 parent ed730c5 commit ffffdc4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/test/fuzz/tx_pool.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
292292
std::set<CTransactionRef> added;
293293
auto txr = std::make_shared<TransactionsDelta>(removed, added);
294294
node.validation_signals->RegisterSharedValidationInterface(txr);
295-
const bool bypass_limits = fuzzed_data_provider.ConsumeBool();
296295

297296
// Make sure ProcessNewPackage on one transaction works.
298297
// The result is not guaranteed to be the same as what is returned by ATMP.
@@ -307,7 +306,7 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
307306
it->second.m_result_type == MempoolAcceptResult::ResultType::INVALID);
308307
}
309308

310-
const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), bypass_limits, /*test_accept=*/false));
309+
const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), /*bypass_limits=*/false, /*test_accept=*/false));
311310
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
312311
node.validation_signals->SyncWithValidationInterfaceQueue();
313312
node.validation_signals->UnregisterSharedValidationInterface(txr);
@@ -389,6 +388,9 @@ FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
389388

390389
chainstate.SetMempool(&tx_pool);
391390

391+
// If we ever bypass limits, do not do TRUC invariants checks
392+
bool ever_bypassed_limits{false};
393+
392394
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 300)
393395
{
394396
const auto mut_tx = ConsumeTransaction(fuzzed_data_provider, txids);
@@ -407,13 +409,17 @@ FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
407409
tx_pool.PrioritiseTransaction(txid.ToUint256(), delta);
408410
}
409411

412+
const bool bypass_limits{fuzzed_data_provider.ConsumeBool()};
413+
ever_bypassed_limits |= bypass_limits;
414+
410415
const auto tx = MakeTransactionRef(mut_tx);
411-
const bool bypass_limits = fuzzed_data_provider.ConsumeBool();
412416
const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), bypass_limits, /*test_accept=*/false));
413417
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
414418
if (accepted) {
415419
txids.push_back(tx->GetHash());
416-
CheckMempoolTRUCInvariants(tx_pool);
420+
if (!ever_bypassed_limits) {
421+
CheckMempoolTRUCInvariants(tx_pool);
422+
}
417423
}
418424
}
419425
Finish(fuzzed_data_provider, tx_pool, chainstate);

0 commit comments

Comments
 (0)