Bitcoin Core 31.99.0
P2P Digital Currency
coins_view.cpp
Go to the documentation of this file.
1// Copyright (c) 2020-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <coins.h>
6#include <consensus/amount.h>
11#include <kernel/cs_main.h>
12#include <policy/policy.h>
13#include <primitives/block.h>
15#include <script/interpreter.h>
17#include <test/fuzz/fuzz.h>
18#include <test/fuzz/util.h>
19#include <test/util/coins.h>
21#include <txdb.h>
22#include <util/hasher.h>
23#include <util/threadpool.h>
24
25#include <cassert>
26#include <algorithm>
27#include <cstdint>
28#include <functional>
29#include <limits>
30#include <memory>
31#include <optional>
32#include <ranges>
33#include <stdexcept>
34#include <string>
35#include <utility>
36#include <vector>
37
38namespace {
46class MutationGuardCoinsViewCache final : public CCoinsViewCache
47{
48private:
49 struct CacheCoinSnapshot {
50 COutPoint outpoint;
51 bool dirty{false};
52 bool fresh{false};
53 Coin coin;
54 bool operator==(const CacheCoinSnapshot&) const = default;
55 };
56
57 std::vector<CacheCoinSnapshot> ComputeCacheCoinsSnapshot() const
58 {
59 std::vector<CacheCoinSnapshot> snapshot;
60 snapshot.reserve(cacheCoins.size());
61
62 for (const auto& [outpoint, entry] : cacheCoins) {
63 snapshot.emplace_back(outpoint, entry.IsDirty(), entry.IsFresh(), entry.coin);
64 }
65
66 std::ranges::sort(snapshot, std::less<>{}, &CacheCoinSnapshot::outpoint);
67 return snapshot;
68 }
69
70 mutable std::vector<CacheCoinSnapshot> m_expected_snapshot{ComputeCacheCoinsSnapshot()};
71
72public:
73 void BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_hash) override
74 {
75 // Nothing must modify cacheCoins other than BatchWrite.
76 assert(ComputeCacheCoinsSnapshot() == m_expected_snapshot);
77 CCoinsViewCache::BatchWrite(cursor, block_hash);
78 m_expected_snapshot = ComputeCacheCoinsSnapshot();
79 }
80
82};
83
84// Reuse a single global thread pool across fuzz iterations. Creating and destroying a pool every
85// iteration leaks memory, since iterations can run faster than the OS can tear down the threads.
86std::shared_ptr<ThreadPool> g_thread_pool{std::make_shared<ThreadPool>("view_fuzz")};
87
89{
90 if (!g_thread_pool->WorkersCount()) g_thread_pool->Start(DEFAULT_PREVOUTFETCH_THREADS);
91}
92
95{
96 CBlock block;
97 CMutableTransaction coinbase;
98 coinbase.vin.emplace_back();
99 block.vtx.push_back(MakeTransactionRef(coinbase));
100
101 CCoinsViewCache seed_cache{&view, /*deterministic=*/true};
102 seed_cache.SetBestBlock(uint256::ONE);
103
106 {
109 {
112 : prevhash};
113 const COutPoint outpoint{txid, fuzzed_data_provider.ConsumeIntegral<uint32_t>()};
114 if (auto coin{ConsumeDeserializable<Coin>(fuzzed_data_provider)}; coin && !coin->IsSpent()) {
115 seed_cache.AddCoin(outpoint, std::move(*coin), /*possible_overwrite=*/true);
116 }
117 tx.vin.emplace_back(outpoint);
118 }
119 prevhash = tx.GetHash();
120 block.vtx.push_back(MakeTransactionRef(tx));
121 }
122
123 seed_cache.Flush();
124 return block;
125}
126
127} // namespace
128
130{
131 static const auto testing_setup = MakeNoLogFileContext<>();
132}
133
135{
136 auto* const db{dynamic_cast<CCoinsViewDB*>(backend_coins_view)};
137 auto* const overlay{dynamic_cast<CoinsViewOverlay*>(&coins_view_cache)};
138 const bool is_db{db != nullptr};
139 bool good_data{true};
140 auto* original_backend{backend_coins_view};
141
142 if (is_db) coins_view_cache.SetBestBlock(uint256::ONE);
143 COutPoint random_out_point;
144 Coin random_coin;
145 CMutableTransaction random_mutable_transaction;
146 LIMITED_WHILE (good_data && fuzzed_data_provider.ConsumeBool(), 10'000) {
147 CallOneOf(
149 [&] {
150 if (random_coin.IsSpent()) {
151 return;
152 }
153 COutPoint outpoint{random_out_point};
154 Coin coin{random_coin};
156 // We can only skip the check if no unspent coin exists for this outpoint.
157 const bool possible_overwrite{coins_view_cache.PeekCoin(outpoint) || fuzzed_data_provider.ConsumeBool()};
158 coins_view_cache.AddCoin(outpoint, std::move(coin), possible_overwrite);
159 } else {
160 coins_view_cache.EmplaceCoinInternalDANGER(outpoint, std::move(coin));
161 }
162 },
163 [&] {
164 if (overlay && !overlay->AllInputsConsumed()) return; // CoinsViewOverlay::Flush() must have all inputs consumed before being called
165 coins_view_cache.Flush(/*reallocate_cache=*/fuzzed_data_provider.ConsumeBool());
166 },
167 [&] {
168 if (overlay) return; // CoinsViewOverlay::Sync() is never called in production code
169 coins_view_cache.Sync();
170 },
171 [&] {
172 if (db) WITH_LOCK(::cs_main, (void)db->CompactFullAsync());
173 },
174 [&] {
176 // `CCoinsViewDB::BatchWrite()` requires a non-null best block.
177 if (is_db && best_block.IsNull()) best_block = uint256::ONE;
178 coins_view_cache.SetBestBlock(best_block);
179 },
180 [&] {
181 (void)coins_view_cache.CreateResetGuard();
182 // Reset() clears the best block, so reseed db-backed caches.
183 if (is_db) {
185 if (best_block.IsNull()) {
186 good_data = false;
187 return;
188 }
189 coins_view_cache.SetBestBlock(best_block);
190 }
191 },
192 [&] {
193 Coin move_to;
194 (void)coins_view_cache.SpendCoin(random_out_point, fuzzed_data_provider.ConsumeBool() ? &move_to : nullptr);
195 },
196 [&] {
197 coins_view_cache.Uncache(random_out_point);
198 },
199 [&] {
200 if (overlay) return; // // CoinsViewOverlay::SetBackend() is never called in production code
201 const bool use_original_backend{fuzzed_data_provider.ConsumeBool()};
202 if (use_original_backend && backend_coins_view != original_backend) {
203 // FRESH flags valid against the empty backend may be invalid
204 // against the original backend, so reset before restoring it.
205 (void)coins_view_cache.CreateResetGuard();
206 // Reset() clears the best block; db backends require a non-null hash.
207 if (is_db) coins_view_cache.SetBestBlock(uint256::ONE);
208 }
209 backend_coins_view = use_original_backend ? original_backend : &CoinsViewEmpty::Get();
210 coins_view_cache.SetBackend(*backend_coins_view);
211 },
212 [&] {
213 const std::optional<COutPoint> opt_out_point = ConsumeDeserializable<COutPoint>(fuzzed_data_provider);
214 if (!opt_out_point) {
215 good_data = false;
216 return;
217 }
218 random_out_point = *opt_out_point;
219 },
220 [&] {
221 const std::optional<Coin> opt_coin = ConsumeDeserializable<Coin>(fuzzed_data_provider);
222 if (!opt_coin) {
223 good_data = false;
224 return;
225 }
226 random_coin = *opt_coin;
227 },
228 [&] {
229 const std::optional<CMutableTransaction> opt_mutable_transaction = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);
230 if (!opt_mutable_transaction) {
231 good_data = false;
232 return;
233 }
234 random_mutable_transaction = *opt_mutable_transaction;
235 },
236 [&] {
237 CoinsCachePair sentinel{};
238 sentinel.second.SelfRef(sentinel);
239 size_t dirty_count{0};
241 CCoinsMap coins_map{0, SaltedCoinsCacheHasher{/*deterministic=*/true}, CCoinsMap::key_equal{}, &resource};
242 LIMITED_WHILE (good_data && fuzzed_data_provider.ConsumeBool(), 10'000) {
243 CCoinsCacheEntry coins_cache_entry;
245 coins_cache_entry.coin = random_coin;
246 } else {
247 const std::optional<Coin> opt_coin = ConsumeDeserializable<Coin>(fuzzed_data_provider);
248 if (!opt_coin) {
249 good_data = false;
250 return;
251 }
252 coins_cache_entry.coin = *opt_coin;
253 }
254 // Avoid setting FRESH for an outpoint that already exists unspent in the parent view.
255 bool fresh{!coins_view_cache.PeekCoin(random_out_point) && fuzzed_data_provider.ConsumeBool()};
256 bool dirty{fresh || fuzzed_data_provider.ConsumeBool()};
257 auto it{coins_map.emplace(random_out_point, std::move(coins_cache_entry)).first};
258 if (dirty) CCoinsCacheEntry::SetDirty(*it, sentinel);
259 if (fresh) CCoinsCacheEntry::SetFresh(*it, sentinel);
260 dirty_count += dirty;
261 }
262 auto cursor{CoinsViewCacheCursor(dirty_count, sentinel, coins_map, /*will_erase=*/true)};
263 uint256 best_block{coins_view_cache.GetBestBlock()};
265 // Set best block hash to non-null to satisfy the assertion in CCoinsViewDB::BatchWrite().
266 if (is_db && best_block.IsNull()) best_block = uint256::ONE;
267 coins_view_cache.BatchWrite(cursor, best_block);
268 });
269 }
270
271 {
272 (void)coins_view_cache.DynamicMemoryUsage();
273 (void)coins_view_cache.EstimateSize();
274 (void)coins_view_cache.GetBestBlock();
275 (void)coins_view_cache.GetCacheSize();
276 (void)coins_view_cache.GetHeadBlocks();
277 (void)coins_view_cache.HaveInputs(CTransaction{random_mutable_transaction});
278 }
279
280 {
281 if (is_db && backend_coins_view == original_backend) {
282 assert(db->Cursor());
283 }
284 (void)backend_coins_view->EstimateSize();
285 (void)backend_coins_view->GetBestBlock();
286 (void)backend_coins_view->GetHeadBlocks();
287 }
288
290 CallOneOf(
292 [&] {
293 const CTransaction transaction{random_mutable_transaction};
294 bool is_spent = false;
295 for (const CTxOut& tx_out : transaction.vout) {
296 if (Coin{tx_out, 0, transaction.IsCoinBase()}.IsSpent()) {
297 is_spent = true;
298 }
299 }
300 if (is_spent) {
301 // Avoid:
302 // coins.cpp:69: void CCoinsViewCache::AddCoin(const COutPoint &, Coin &&, bool): Assertion `!coin.IsSpent()' failed.
303 return;
304 }
305 const int height{int(fuzzed_data_provider.ConsumeIntegral<uint32_t>() >> 1)};
306 const bool check_for_overwrite{transaction.IsCoinBase() || [&] {
307 for (uint32_t i{0}; i < transaction.vout.size(); ++i) {
308 if (coins_view_cache.PeekCoin(COutPoint{transaction.GetHash(), i})) return true;
309 }
311 }()}; // We can only skip the check if the current txid has no unspent outputs
312 AddCoins(coins_view_cache, transaction, height, check_for_overwrite);
313 },
314 [&] {
315 (void)ValidateInputsStandardness(CTransaction{random_mutable_transaction}, coins_view_cache);
316 },
317 [&] {
318 TxValidationState state;
319 CAmount tx_fee_out;
320 const CTransaction transaction{random_mutable_transaction};
321 if (ContainsSpentInput(transaction, coins_view_cache)) {
322 // Avoid:
323 // consensus/tx_verify.cpp:171: bool Consensus::CheckTxInputs(const CTransaction &, TxValidationState &, const CCoinsViewCache &, int, CAmount &): Assertion `!coin.IsSpent()' failed.
324 return;
325 }
326 TxValidationState dummy;
327 if (!CheckTransaction(transaction, dummy)) {
328 // It is not allowed to call CheckTxInputs if CheckTransaction failed
329 return;
330 }
331 if (Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out)) {
332 assert(MoneyRange(tx_fee_out));
333 }
334 },
335 [&] {
336 const CTransaction transaction{random_mutable_transaction};
337 if (ContainsSpentInput(transaction, coins_view_cache)) {
338 // Avoid:
339 // consensus/tx_verify.cpp:130: unsigned int GetP2SHSigOpCount(const CTransaction &, const CCoinsViewCache &): Assertion `!coin.IsSpent()' failed.
340 return;
341 }
342 (void)GetP2SHSigOpCount(transaction, coins_view_cache);
343 },
344 [&] {
345 const CTransaction transaction{random_mutable_transaction};
346 if (ContainsSpentInput(transaction, coins_view_cache)) {
347 // Avoid:
348 // consensus/tx_verify.cpp:130: unsigned int GetP2SHSigOpCount(const CTransaction &, const CCoinsViewCache &): Assertion `!coin.IsSpent()' failed.
349 return;
350 }
352 if (!transaction.vin.empty() && (flags & SCRIPT_VERIFY_WITNESS) != 0 && (flags & SCRIPT_VERIFY_P2SH) == 0) {
353 // Avoid:
354 // script/interpreter.cpp:1705: size_t CountWitnessSigOps(const CScript &, const CScript &, const CScriptWitness &, unsigned int): Assertion `(flags & SCRIPT_VERIFY_P2SH) != 0' failed.
355 return;
356 }
357 (void)GetTransactionSigOpCost(transaction, coins_view_cache, flags);
358 },
359 [&] {
360 (void)IsWitnessStandard(CTransaction{random_mutable_transaction}, coins_view_cache);
361 });
362 }
363
364 {
365 const Coin& coin_using_access_coin = coins_view_cache.AccessCoin(random_out_point);
366 const bool exists_using_access_coin = !coin_using_access_coin.IsSpent();
367 const bool exists_using_have_coin = coins_view_cache.HaveCoin(random_out_point);
368 const bool exists_using_have_coin_in_cache = coins_view_cache.HaveCoinInCache(random_out_point);
369 if (auto coin{coins_view_cache.GetCoin(random_out_point)}) {
370 assert(*coin == coin_using_access_coin);
371 assert(exists_using_access_coin && exists_using_have_coin_in_cache && exists_using_have_coin);
372 } else {
373 assert(!exists_using_access_coin && !exists_using_have_coin_in_cache && !exists_using_have_coin);
374 }
375 // If HaveCoin on the backend is true, it must also be on the cache if the coin wasn't spent.
376 std::optional<Coin> coin_in_backend;
377 bool exists_using_have_coin_in_backend;
378 if (dynamic_cast<CoinsViewOverlay*>(&coins_view_cache)) {
379 // PeekCoin does not mutate cacheCoins, so async workers can keep running.
380 coin_in_backend = backend_coins_view->PeekCoin(random_out_point);
381 exists_using_have_coin_in_backend = coin_in_backend.has_value();
382 } else {
383 exists_using_have_coin_in_backend = backend_coins_view->HaveCoin(random_out_point);
384 coin_in_backend = backend_coins_view->GetCoin(random_out_point);
385 }
386 if (!coin_using_access_coin.IsSpent() && exists_using_have_coin_in_backend) {
387 assert(exists_using_have_coin);
388 }
389 if (coin_in_backend) {
390 assert(exists_using_have_coin_in_backend);
391 // Note we can't assert that `coin_using_get_coin == *coin` because the coin in
392 // the cache may have been modified but not yet flushed.
393 } else {
394 assert(!exists_using_have_coin_in_backend);
395 }
396 }
397}
398
400{
401 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
402 CCoinsViewCache coins_view_cache{&CoinsViewEmpty::Get(), /*deterministic=*/true};
404}
405
407{
408 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
409 auto db_params = DBParams{
410 .path = "",
411 .cache_bytes = 1_MiB,
412 .memory_only = true,
413 };
414 CCoinsViewDB backend_coins_view{std::move(db_params), CoinsViewOptions{}};
415 CCoinsViewCache coins_view_cache{&backend_coins_view, /*deterministic=*/true};
416 TestCoinsView(fuzzed_data_provider, coins_view_cache, &backend_coins_view);
417}
418
419// Creates a CoinsViewOverlay and a MutationGuardCoinsViewCache as the base.
420// This allows us to exercise all methods on a CoinsViewOverlay, while also
421// ensuring that nothing can mutate the underlying cache until Flush or Sync is
422// called.
424{
425 SeedRandomStateForTest(SeedRand::ZEROS); // for SaltedCoinsCacheHasher
427 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
428 MutationGuardCoinsViewCache backend_cache{&CoinsViewEmpty::Get(), /*deterministic=*/true};
429 CoinsViewOverlay coins_view_cache{&backend_cache, g_thread_pool, /*deterministic=*/true};
430 CBlock block{BuildRandomBlock(fuzzed_data_provider, backend_cache)};
431 const auto reset_guard{coins_view_cache.StartFetching(block)};
432 TestCoinsView(fuzzed_data_provider, coins_view_cache, &backend_cache);
433}
434
436{
437 SeedRandomStateForTest(SeedRand::ZEROS); // for SaltedCoinsCacheHasher
439 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
440 auto db_params = DBParams{
441 .path = "",
442 .cache_bytes = 1_MiB,
443 .memory_only = true,
444 };
445 CCoinsViewDB backend_base_coins_view{std::move(db_params), CoinsViewOptions{}};
446 CCoinsViewCache backend_cache{&backend_base_coins_view, /*deterministic=*/true};
447 TestCoinsView(fuzzed_data_provider, backend_cache, &backend_base_coins_view);
448 CoinsViewOverlay coins_view_cache{&backend_cache, g_thread_pool, /*deterministic=*/true};
449 CBlock block{BuildRandomBlock(fuzzed_data_provider, backend_base_coins_view)};
450 {
451 const auto reset_guard{coins_view_cache.StartFetching(block)};
452 TestCoinsView(fuzzed_data_provider, coins_view_cache, &backend_cache);
453 }
454 TestCoinsView(fuzzed_data_provider, backend_cache, &backend_base_coins_view);
455}
bool MoneyRange(const CAmount &nValue)
Definition: amount.h:27
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
if(!SetupNetworking())
int flags
Definition: bitcoin-tx.cpp:530
constexpr int32_t DEFAULT_PREVOUTFETCH_THREADS
Definition: block.h:74
std::vector< CTransactionRef > vtx
Definition: block.h:77
void SetBackend(CCoinsView &in_view)
Definition: coins.h:423
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:437
void Sync()
Push the modifications applied to this cache to its base while retaining the contents of this cache (...
Definition: coins.cpp:284
bool SpendCoin(const COutPoint &outpoint, Coin *moveto=nullptr)
Spend a coin.
Definition: coins.cpp:144
ResetGuard CreateResetGuard() noexcept
Create a scoped guard that will call Reset() on this cache when it goes out of scope.
Definition: coins.h:591
void Uncache(const COutPoint &outpoint)
Removes the UTXO with the given outpoint from the cache, if it is not modified.
Definition: coins.cpp:303
void EmplaceCoinInternalDANGER(const COutPoint &outpoint, Coin &&coin)
Emplace a coin into cacheCoins without performing any checks, marking the emplaced coin as dirty.
Definition: coins.cpp:123
void AddCoin(const COutPoint &outpoint, Coin &&coin, bool possible_overwrite)
Add a coin.
Definition: coins.cpp:80
CCoinsViewCache(CCoinsView *in_base, bool deterministic=false)
Definition: coins.cpp:43
virtual void Flush(bool reallocate_cache=true)
Push the modifications applied to this cache to its base and wipe local state.
Definition: coins.cpp:272
void SetBestBlock(const uint256 &block_hash)
Definition: coins.cpp:196
uint256 GetBestBlock() const override
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: coins.cpp:190
void BatchWrite(CoinsViewCacheCursor &cursor, const uint256 &block_hash) override
Do a bulk modification (multiple Coin changes + BestBlock change).
Definition: coins.cpp:201
std::optional< Coin > PeekCoin(const COutPoint &outpoint) const override
Retrieve the Coin (unspent transaction output) for a given outpoint, without caching results.
Definition: coins.cpp:35
CCoinsView backed by the coin database (chainstate/)
Definition: txdb.h:37
Pure abstract view on the open txout dataset.
Definition: coins.h:356
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:29
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:281
An output of a transaction.
Definition: transaction.h:140
A UTXO entry.
Definition: coins.h:46
bool IsSpent() const
Either this coin never existed (see e.g.
Definition: coins.h:94
static CoinsViewEmpty & Get()
Definition: coins.cpp:29
CCoinsViewCache subclass that asynchronously fetches most block input prevouts in parallel during Con...
Definition: coins.h:653
T ConsumeIntegralInRange(T min, T max)
SipHash-1-3-UJ based hasher for the coins cache and related coins containers.
Definition: coins.h:240
static constexpr script_verify_flags from_int(value_type f)
Definition: verify_flags.h:35
static transaction_identifier FromUint256(const uint256 &id)
256-bit opaque blob.
Definition: uint256.h:196
static const uint256 ONE
Definition: uint256.h:205
void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight, bool check_for_overwrite)
Utility function to add all of a transaction's outputs to a cache.
Definition: coins.cpp:133
std::pair< const COutPoint, CCoinsCacheEntry > CoinsCachePair
Definition: coins.h:104
std::unordered_map< COutPoint, CCoinsCacheEntry, SaltedCoinsCacheHasher, std::equal_to< COutPoint >, PoolAllocator< CoinsCachePair, sizeof(CoinsCachePair)+sizeof(void *) *4 > > CCoinsMap
PoolAllocator's MAX_BLOCK_SIZE_BYTES parameter here uses sizeof the data, and adds the size of 4 poin...
Definition: coins.h:272
CCoinsMap::allocator_type::ResourceType CCoinsMapMemoryResource
Definition: coins.h:274
void TestCoinsView(FuzzedDataProvider &fuzzed_data_provider, CCoinsViewCache &coins_view_cache, CCoinsView *backend_coins_view)
Definition: coins_view.cpp:134
FUZZ_TARGET(coins_view,.init=initialize_coins_view)
Definition: coins_view.cpp:399
void initialize_coins_view()
Definition: coins_view.cpp:129
LIMITED_WHILE(provider.remaining_bytes(), 10000)
StartPoolIfNeeded()
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: cs_main.cpp:8
bool CheckTxInputs(const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &inputs, int nSpendHeight, CAmount &txfee)
Check whether all inputs of this transaction are valid (no double spends and amounts) This does not m...
Definition: tx_verify.cpp:170
Definition: basic.cpp:8
bool operator==(const CNetAddr &a, const CNetAddr &b)
Definition: netaddress.cpp:603
TxValidationState ValidateInputsStandardness(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check transaction inputs.
Definition: policy.cpp:214
bool IsWitnessStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check if the transaction is over standard P2WSH resources limit: 3600bytes witnessScript size,...
Definition: policy.cpp:265
constexpr TransactionSerParams TX_WITH_WITNESS
Definition: transaction.h:180
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Definition: transaction.h:404
A Coin in one level of the coins database caching hierarchy.
Definition: coins.h:121
Coin coin
Definition: coins.h:153
static void SetFresh(CoinsCachePair &pair, CoinsCachePair &sentinel) noexcept
Definition: coins.h:184
static void SetDirty(CoinsCachePair &pair, CoinsCachePair &sentinel) noexcept
Definition: coins.h:183
A mutable version of CTransaction.
Definition: transaction.h:358
Txid GetHash() const
Compute the hash of this CMutableTransaction.
Definition: transaction.cpp:69
std::vector< CTxIn > vin
Definition: transaction.h:359
Cursor for iterating over the linked list of flagged entries in CCoinsViewCache.
Definition: coins.h:309
User-controlled performance and debug options.
Definition: txdb.h:28
Application-specific storage settings.
Definition: dbwrapper.h:41
fs::path path
Location in the filesystem where leveldb data will be stored.
Definition: dbwrapper.h:43
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition: sync.h:299
CDBWrapper db
Definition: dbwrapper.cpp:371
SeedRandomStateForTest(SeedRand::ZEROS)
bool ContainsSpentInput(const CTransaction &tx, const CCoinsViewCache &inputs) noexcept
Definition: util.cpp:240
uint256 ConsumeUInt256(FuzzedDataProvider &fuzzed_data_provider) noexcept
Definition: util.h:195
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
Definition: util.h:37
@ ZEROS
Seed with a compile time constant of zeros.
bool CheckTransaction(const CTransaction &tx, TxValidationState &state)
Definition: tx_check.cpp:19
int64_t GetTransactionSigOpCost(const CTransaction &tx, const CCoinsViewCache &inputs, script_verify_flags flags)
Compute total signature operation cost of a transaction.
Definition: tx_verify.cpp:149
unsigned int GetP2SHSigOpCount(const CTransaction &tx, const CCoinsViewCache &inputs)
Count ECDSA signature operations in pay-to-script-hash inputs.
Definition: tx_verify.cpp:132
assert(!tx.IsCoinBase())
FuzzedDataProvider & fuzzed_data_provider
Definition: fees.cpp:45