coins: delete Sync and SetBackend on CoinsViewOverlay

Neither is called in production code, and both would write to or swap
the base view, which is unsafe while workers are still fetching. Hide the non-virtual base class methods with deleted ones.

Also fix a doubled comment and reuse the existing overlay pointer in
the coins_view fuzz target.

Co-authored-by: Lőrinc <pap.lorinc@gmail.com>
This commit is contained in:
Andrew Toth
2026-07-15 13:24:11 -04:00
parent 330022993f
commit 2ffaa6e6a7
2 changed files with 6 additions and 2 deletions

View File

@@ -733,6 +733,10 @@ public:
CCoinsViewCache::Flush(reallocate_cache);
}
//! Swapping the backend or writing through to it with Sync() is not supported while fetching.
void SetBackend(CCoinsView&) = delete;
void Sync() = delete;
//! Verify that all parallel fetched input prevouts have been consumed.
bool AllInputsConsumed() const noexcept { return m_input_tail == m_inputs.size(); }
};

View File

@@ -204,7 +204,7 @@ void TestCoinsView(FuzzedDataProvider& fuzzed_data_provider, CCoinsViewCache& co
coins_view_cache.Uncache(random_out_point);
},
[&] {
if (overlay) return; // // CoinsViewOverlay::SetBackend() is never called in production code
if (overlay) return; // CoinsViewOverlay::SetBackend() is never called in production code
const bool use_original_backend{fuzzed_data_provider.ConsumeBool()};
if (use_original_backend && backend_coins_view != original_backend) {
// FRESH flags valid against the empty backend may be invalid
@@ -382,7 +382,7 @@ void TestCoinsView(FuzzedDataProvider& fuzzed_data_provider, CCoinsViewCache& co
// If HaveCoin on the backend is true, it must also be on the cache if the coin wasn't spent.
std::optional<Coin> coin_in_backend;
bool exists_using_have_coin_in_backend;
if (dynamic_cast<CoinsViewOverlay*>(&coins_view_cache)) {
if (overlay) {
// PeekCoin does not mutate cacheCoins, so async workers can keep running.
coin_in_backend = backend_coins_view->PeekCoin(random_out_point);
exists_using_have_coin_in_backend = coin_in_backend.has_value();