fuzz: add coins_view_stacked fuzz harness to test concurrent leveldb reads
What changed, and why it matters
This commit adds a new automated test (a fuzzing harness) for Bitcoin Core's coin database view. It does not change any production code, user-facing behavior, or network protocol. It only adds a test that exercises reading the LevelDB-backed coin database concurrently with other operations. There is no indication of a security fix or vulnerability.
No action required. This is a test-only addition. Reviewers may optionally verify the harness compiles and runs in the fuzzing CI pipeline.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a new FUZZ_TARGET named coins_view_stacked in src/test/fuzz/coins_view.cpp. It creates an in-memory LevelDB-backed CCoinsViewDB, wraps it in caches/overlays, and runs TestCoinsView while a background thread pool prefetches a block via CoinsViewOverlay::StartFetching. This is purely a test addition to exercise concurrent LevelDB reads; no production code is modified.
Changed components
src/test/fuzz/coins_view.cppInspect captured patch +22 / −0
diff --git a/src/test/fuzz/coins_view.cpp b/src/test/fuzz/coins_view.cpp
index 62f74614..52c7f031 100644
--- a/src/test/fuzz/coins_view.cpp
+++ b/src/test/fuzz/coins_view.cpp
@@ -449,3 +449,25 @@ FUZZ_TARGET(coins_view_overlay, .init = initialize_coins_view) EXCLUSIVE_LOCKS_R
const auto reset_guard{coins_view_cache.StartFetching(block)};
TestCoinsView(fuzzed_data_provider, coins_view_cache, &backend_cache);
}
+
+FUZZ_TARGET(coins_view_stacked, .init = initialize_coins_view) EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
+{
+ SeedRandomStateForTest(SeedRand::ZEROS); // for SaltedTxidHasher
+ StartPoolIfNeeded();
+ FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
+ auto db_params = DBParams{
+ .path = "",
+ .cache_bytes = 1_MiB,
+ .memory_only = true,
+ };
+ CCoinsViewDB backend_base_coins_view{std::move(db_params), CoinsViewOptions{}};
+ CCoinsViewCache backend_cache{&backend_base_coins_view, /*deterministic=*/true};
+ TestCoinsView(fuzzed_data_provider, backend_cache, &backend_base_coins_view);
+ CoinsViewOverlay coins_view_cache{&backend_cache, g_thread_pool, /*deterministic=*/true};
+ CBlock block{BuildRandomBlock(fuzzed_data_provider, backend_base_coins_view)};
+ {
+ const auto reset_guard{coins_view_cache.StartFetching(block)};
+ TestCoinsView(fuzzed_data_provider, coins_view_cache, &backend_cache);
+ }
+ TestCoinsView(fuzzed_data_provider, backend_cache, &backend_base_coins_view);
+}
Why this scored 15/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.