Merge bitcoin/bitcoin#36998: fuzz: DisableNextWrite in mempool targets
What changed, and why it matters
This change only affects Bitcoin Core's internal fuzz testing programs. It makes fuzz test runs more reproducible by preventing hidden leftover state from one test input from influencing the next. It does not change normal node behavior, consensus rules, or network code, so it is not a security vulnerability in the live Bitcoin software.
No action needed for production deployments. This is a quality-of-life improvement for fuzzing infrastructure; ensure CI fuzz builds include it so coverage and crash reproduction remain reliable.
Security signals we found
test-only fuzz harness change
determinism/reproducibility fix, not a runtime bug fix
no change to consensus, networking, wallet, or mempool acceptance logic
no input validation or boundary changes
Evidence from the diff
The commit adds chainman.DisableNextWrite() calls at the start of five fuzz targets (tx_pool, tx_pool_standard, tx_package_eval, ephemeral_package_eval, validation_load_mempool). These targets call AcceptToMemoryPool/ProcessNewPackage, which end with FlushStateToDisk(PERIODIC). That periodic flush’s execution depends on a static m_next_write timestamp, causing prior fuzz inputs to leak state into later inputs and produce nondeterministic coverage or unreproducible crashes. The patch mirrors the existing fix in process_message(s) and cmpctblock fuzz targets (#32822). It is a test-only determinism improvement.
Changed components
src/test/fuzz/package_eval.cppsrc/test/fuzz/tx_pool.cppsrc/test/fuzz/validation_load_mempool.cppInspect captured patch +13 / −0
### src/test/fuzz/package_eval.cpp
@@ -25,6 +25,7 @@
#include <test/util/script.h>
#include <test/util/setup_common.h>
#include <test/util/txmempool.h>
+#include <test/util/validation.h>
#include <txmempool.h>
#include <util/check.h>
#include <util/hasher.h>
@@ -233,6 +234,8 @@ FUZZ_TARGET(ephemeral_package_eval, .init = initialize_ephemeral_package_eval)
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
const auto& node = g_setup->m_node;
auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
+ auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
+ chainman.DisableNextWrite();
MockTime(fuzzed_data_provider, chainstate);
@@ -391,6 +394,8 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_package_eval)
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
const auto& node = g_setup->m_node;
auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
+ auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
+ chainman.DisableNextWrite();
MockTime(fuzzed_data_provider, chainstate);
### src/test/fuzz/tx_pool.cpp
@@ -27,6 +27,7 @@
#include <test/util/script.h>
#include <test/util/setup_common.h>
#include <test/util/txmempool.h>
+#include <test/util/validation.h>
#include <txmempool.h>
#include <util/check.h>
#include <util/string.h>
@@ -302,6 +303,8 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool_standard)
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
const auto& node = g_setup->m_node;
auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
+ auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
+ chainman.DisableNextWrite();
MockTime(fuzzed_data_provider, chainstate);
@@ -492,6 +495,8 @@ FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
const auto& node = g_setup->m_node;
auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
+ auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
+ chainman.DisableNextWrite();
MockTime(fuzzed_data_provider, chainstate);
### src/test/fuzz/validation_load_mempool.cpp
@@ -14,6 +14,7 @@
#include <test/fuzz/util/reachability.h>
#include <test/util/setup_common.h>
#include <test/util/txmempool.h>
+#include <test/util/validation.h>
#include <txmempool.h>
#include <util/check.h>
#include <util/time.h>
@@ -52,6 +53,8 @@ FUZZ_TARGET(validation_load_mempool, .init = initialize_validation_load_mempool)
Assert(error.empty());
auto& chainstate{static_cast<DummyChainState&>(g_setup->m_node.chainman->ActiveChainstate())};
+ auto& chainman{static_cast<TestChainstateManager&>(*g_setup->m_node.chainman)};
+ chainman.DisableNextWrite();
chainstate.SetMempool(&pool);
auto fuzzed_fopen = [&](const fs::path&, const char*) {Why this scored 20/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.