Bitcoin Core  22.0.0
P2P Digital Currency
validation.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2020 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_VALIDATION_H
7 #define BITCOIN_VALIDATION_H
8 
9 #if defined(HAVE_CONFIG_H)
10 #include <config/bitcoin-config.h>
11 #endif
12 
13 #include <amount.h>
14 #include <attributes.h>
15 #include <coins.h>
16 #include <consensus/validation.h>
17 #include <crypto/common.h> // for ReadLE64
18 #include <fs.h>
19 #include <node/utxo_snapshot.h>
20 #include <policy/feerate.h>
21 #include <policy/packages.h>
22 #include <protocol.h> // For CMessageHeader::MessageStartChars
23 #include <script/script_error.h>
24 #include <sync.h>
25 #include <txmempool.h> // For CTxMemPool::cs
26 #include <txdb.h>
27 #include <serialize.h>
28 #include <util/check.h>
29 #include <util/hasher.h>
30 #include <util/translation.h>
31 
32 #include <atomic>
33 #include <map>
34 #include <memory>
35 #include <optional>
36 #include <set>
37 #include <stdint.h>
38 #include <string>
39 #include <thread>
40 #include <utility>
41 #include <vector>
42 
43 class CChainState;
45 class CBlockIndex;
46 class CBlockTreeDB;
47 class CBlockUndo;
48 class CChainParams;
49 struct CCheckpointData;
50 class CInv;
51 class CConnman;
52 class CScriptCheck;
53 class CTxMemPool;
54 class ChainstateManager;
55 struct ChainTxData;
56 
59 struct LockPoints;
60 struct AssumeutxoData;
61 
63 static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
65 static const unsigned int DEFAULT_ANCESTOR_LIMIT = 25;
67 static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT = 101;
69 static const unsigned int DEFAULT_DESCENDANT_LIMIT = 25;
71 static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101;
73 static const unsigned int DEFAULT_MEMPOOL_EXPIRY = 336;
75 static const int MAX_SCRIPTCHECK_THREADS = 15;
77 static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
78 static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
79 static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
80 static const bool DEFAULT_TXINDEX = false;
81 static constexpr bool DEFAULT_COINSTATSINDEX{false};
82 static const char* const DEFAULT_BLOCKFILTERINDEX = "0";
84 static const bool DEFAULT_PERSIST_MEMPOOL = true;
86 static const int DEFAULT_STOPATHEIGHT = 0;
88 static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
89 static const signed int DEFAULT_CHECKBLOCKS = 6;
90 static const unsigned int DEFAULT_CHECKLEVEL = 3;
91 // Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev???.dat)
92 // At 1MB per block, 288 blocks = 288MB.
93 // Add 15% for Undo data = 331MB
94 // Add 20% for Orphan block rate = 397MB
95 // We want the low water mark after pruning to be at least 397 MB and since we prune in
96 // full block file chunks, we need the high water mark which triggers the prune to be
97 // one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB
98 // Setting the target to >= 550 MiB will make it likely we can respect the target.
99 static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;
100 
103  INIT_REINDEX,
105  POST_INIT
106 };
107 
108 extern RecursiveMutex cs_main;
109 typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
111 extern std::condition_variable g_best_block_cv;
112 extern uint256 g_best_block;
116 extern bool g_parallel_script_checks;
117 extern bool fRequireStandard;
118 extern bool fCheckBlockIndex;
119 extern bool fCheckpointsEnabled;
121 extern CFeeRate minRelayTxFee;
123 extern int64_t nMaxTipAge;
124 
126 extern uint256 hashAssumeValid;
127 
130 
133 
135 extern const std::vector<std::string> CHECKLEVEL_DOC;
136 
138 void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman);
140 void StartScriptCheckWorkerThreads(int threads_num);
155 CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock);
156 CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
157 
158 bool AbortNode(BlockValidationState& state, const std::string& strMessage, const bilingual_str& userMessage = bilingual_str{});
159 
161 double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pindex);
162 
164 void PruneBlockFilesManual(CChainState& active_chainstate, int nManualPruneHeight);
165 
171  enum class ResultType {
172  VALID,
173  INVALID,
174  };
177 
178  // The following fields are only present when m_result_type = ResultType::VALID
180  const std::optional<std::list<CTransactionRef>> m_replaced_transactions;
182  const std::optional<CAmount> m_base_fees;
184  return MempoolAcceptResult(state);
185  }
186 
187  static MempoolAcceptResult Success(std::list<CTransactionRef>&& replaced_txns, CAmount fees) {
188  return MempoolAcceptResult(std::move(replaced_txns), fees);
189  }
190 
191 // Private constructors. Use static methods MempoolAcceptResult::Success, etc. to construct.
192 private:
195  : m_result_type(ResultType::INVALID), m_state(state) {
196  Assume(!state.IsValid()); // Can be invalid or error
197  }
198 
200  explicit MempoolAcceptResult(std::list<CTransactionRef>&& replaced_txns, CAmount fees)
201  : m_result_type(ResultType::VALID),
202  m_replaced_transactions(std::move(replaced_txns)), m_base_fees(fees) {}
203 };
204 
209 {
216  std::map<const uint256, const MempoolAcceptResult> m_tx_results;
217 
219  std::map<const uint256, const MempoolAcceptResult>&& results)
220  : m_state{state}, m_tx_results(std::move(results)) {}
221 
223  explicit PackageMempoolAcceptResult(const uint256& wtxid, const MempoolAcceptResult& result)
224  : m_tx_results{ {wtxid, result} } {}
225 };
226 
233  bool bypass_limits, bool test_accept=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
234 
247  const Package& txns, bool test_accept)
249 
251 void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight);
252 
262 bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, int flags = -1) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
263 
268 
289  const CCoinsView& coins_view,
290  const CTransaction& tx,
291  int flags,
292  LockPoints* lp = nullptr,
293  bool useExistingLockPoints = false);
294 
300 {
301 private:
304  unsigned int nIn;
305  unsigned int nFlags;
309 
310 public:
311  CScriptCheck(): ptxTo(nullptr), nIn(0), nFlags(0), cacheStore(false), error(SCRIPT_ERR_UNKNOWN_ERROR) {}
312  CScriptCheck(const CTxOut& outIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData* txdataIn) :
313  m_tx_out(outIn), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), error(SCRIPT_ERR_UNKNOWN_ERROR), txdata(txdataIn) { }
314 
315  bool operator()();
316 
317  void swap(CScriptCheck &check) {
318  std::swap(ptxTo, check.ptxTo);
319  std::swap(m_tx_out, check.m_tx_out);
320  std::swap(nIn, check.nIn);
321  std::swap(nFlags, check.nFlags);
322  std::swap(cacheStore, check.cacheStore);
323  std::swap(error, check.error);
324  std::swap(txdata, check.txdata);
325  }
326 
327  ScriptError GetScriptError() const { return error; }
328 };
329 
332 
336 bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
337 
340  const CChainParams& chainparams,
341  CChainState& chainstate,
342  const CBlock& block,
343  CBlockIndex* pindexPrev,
344  bool fCheckPOW = true,
345  bool fCheckMerkleRoot = true) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
346 
348 void UpdateUncommittedBlockStructures(CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams);
349 
351 std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams);
352 
354 class CVerifyDB {
355 public:
356  CVerifyDB();
357  ~CVerifyDB();
358  bool VerifyDB(
359  CChainState& chainstate,
360  const CChainParams& chainparams,
361  CCoinsView& coinsview,
362  int nCheckLevel,
363  int nCheckDepth) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
364 };
365 
367 {
368  DISCONNECT_OK, // All good.
369  DISCONNECT_UNCLEAN, // Rolled back, but UTXO set was inconsistent with block.
370  DISCONNECT_FAILED // Something else went wrong.
371 };
372 
373 class ConnectTrace;
374 
376 enum class FlushStateMode {
377  NONE,
378  IF_NEEDED,
379  PERIODIC,
380  ALWAYS
381 };
382 
384 {
385  bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const;
386 };
387 
396 {
397  friend CChainState;
398 
399 private:
400  /* Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */
401  void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight, int chain_tip_height);
402 
418  void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight, int chain_tip_height, int prune_height, bool is_ibd);
419 
420 public:
421  BlockMap m_block_index GUARDED_BY(cs_main);
422 
441  std::set<CBlockIndex*> m_failed_blocks;
442 
447  std::multimap<CBlockIndex*, CBlockIndex*> m_blocks_unlinked;
448 
457  bool LoadBlockIndex(
458  const Consensus::Params& consensus_params,
459  CBlockTreeDB& blocktree,
460  std::set<CBlockIndex*, CBlockIndexWorkComparator>& block_index_candidates)
462 
465 
469 
471  void PruneOneBlockFile(const int fileNumber) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
472 
477  bool AcceptBlockHeader(
478  const CBlockHeader& block,
479  BlockValidationState& state,
480  const CChainParams& chainparams,
482 
484 
487 
490 
497 
499  Unload();
500  }
501 };
502 
512 class CoinsViews {
513 
514 public:
517  CCoinsViewDB m_dbview GUARDED_BY(cs_main);
518 
521 
524  std::unique_ptr<CCoinsViewCache> m_cacheview GUARDED_BY(cs_main);
525 
532  CoinsViews(std::string ldb_name, size_t cache_size_bytes, bool in_memory, bool should_wipe);
533 
535  void InitCache() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
536 };
537 
539 {
541  CRITICAL = 2,
543  LARGE = 1,
544  OK = 0
545 };
546 
562 {
563 protected:
570  int32_t nBlockSequenceId = 1;
575 
581 
588  mutable std::atomic<bool> m_cached_finished_ibd{false};
589 
593 
595 
597  std::unique_ptr<CoinsViews> m_coins_views;
598 
599 public:
603 
604  explicit CChainState(
605  CTxMemPool* mempool,
606  BlockManager& blockman,
607  std::optional<uint256> from_snapshot_blockhash = std::nullopt);
608 
615  void InitCoinsDB(
616  size_t cache_size_bytes,
617  bool in_memory,
618  bool should_wipe,
619  std::string leveldb_name = "chainstate");
620 
623  void InitCoinsCache(size_t cache_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
624 
627  bool CanFlushToDisk() const EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
628  return m_coins_views && m_coins_views->m_cacheview;
629  }
630 
634 
640  const std::optional<uint256> m_from_snapshot_blockhash;
641 
647  std::set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexCandidates;
648 
651  {
652  assert(m_coins_views->m_cacheview);
653  return *m_coins_views->m_cacheview.get();
654  }
655 
658  {
659  return m_coins_views->m_dbview;
660  }
661 
665  {
666  return m_coins_views->m_catcherview;
667  }
668 
670  void ResetCoinsViews() { m_coins_views.reset(); }
671 
674 
677 
680  bool ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size)
682 
684  void LoadExternalBlockFile(FILE* fileIn, FlatFilePos* dbp = nullptr);
685 
697  bool FlushStateToDisk(
698  BlockValidationState& state,
699  FlushStateMode mode,
700  int nManualPruneHeight = 0);
701 
703  void ForceFlushStateToDisk();
704 
707  void PruneAndFlush();
708 
724  bool ActivateBestChain(
725  BlockValidationState& state,
726  std::shared_ptr<const CBlock> pblock = nullptr) LOCKS_EXCLUDED(cs_main);
727 
728  bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, BlockValidationState& state, CBlockIndex** ppindex, bool fRequested, const FlatFilePos* dbp, bool* fNewBlock) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
729 
730  // Block (dis)connection on a given view:
731  DisconnectResult DisconnectBlock(const CBlock& block, const CBlockIndex* pindex, CCoinsViewCache& view);
732  bool ConnectBlock(const CBlock& block, BlockValidationState& state, CBlockIndex* pindex,
733  CCoinsViewCache& view, bool fJustCheck = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
734 
735  // Apply the effects of a block disconnection on the UTXO set.
737 
738  // Manual block validity manipulation:
748 
750  bool ReplayBlocks();
751 
753  [[nodiscard]] bool NeedsRedownload() const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
755  bool LoadGenesisBlock();
756 
758 
759  void UnloadBlockIndex();
760 
762  bool IsInitialBlockDownload() const;
763 
769  void CheckBlockIndex();
770 
772  void LoadMempool(const ArgsManager& args);
773 
776 
780  CoinsCacheSizeState GetCoinsCacheSizeState() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
781 
782  CoinsCacheSizeState GetCoinsCacheSizeState(
783  size_t max_coins_cache_size_bytes,
784  size_t max_mempool_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
785 
787 
788 private:
789  bool ActivateBestChainStep(BlockValidationState& state, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs);
790  bool ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs);
791 
794  void ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pindexNew, const FlatFilePos& pos) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
795 
797 
800 
802 
805  {
806  return m_mempool ? &m_mempool->cs : nullptr;
807  }
808 
823  DisconnectedBlockTransactions& disconnectpool,
825 
827  void UpdateTip(const CBlockIndex* pindexNew)
829 
830  friend ChainstateManager;
831 };
832 
867 {
868 private:
884  std::unique_ptr<CChainState> m_ibd_chainstate GUARDED_BY(::cs_main);
885 
895  std::unique_ptr<CChainState> m_snapshot_chainstate GUARDED_BY(::cs_main);
896 
906  CChainState* m_active_chainstate GUARDED_BY(::cs_main) {nullptr};
907 
910  bool m_snapshot_validated{false};
911 
913  [[nodiscard]] bool PopulateAndValidateSnapshot(
914  CChainState& snapshot_chainstate,
915  CAutoFile& coins_file,
916  const SnapshotMetadata& metadata);
917 
918 public:
919  std::thread m_load_block;
922  BlockManager m_blockman GUARDED_BY(::cs_main);
923 
927  //
931 
936  // constructor
939  CChainState& InitializeChainstate(
940  CTxMemPool* mempool,
941  const std::optional<uint256>& snapshot_blockhash = std::nullopt)
943 
945  std::vector<CChainState*> GetAll();
946 
960  [[nodiscard]] bool ActivateSnapshot(
961  CAutoFile& coins_file, const SnapshotMetadata& metadata, bool in_memory);
962 
964  CChainState& ActiveChainstate() const;
966  int ActiveHeight() const { return ActiveChain().Height(); }
967  CBlockIndex* ActiveTip() const { return ActiveChain().Tip(); }
968 
970  {
971  return m_blockman.m_block_index;
972  }
973 
976  bool IsSnapshotActive() const;
977 
978  std::optional<uint256> SnapshotBlockhash() const;
979 
981  bool IsSnapshotValidated() const { return m_snapshot_validated; }
982 
985  bool IsBackgroundIBD(CChainState* chainstate) const;
986 
992 
994  CBlockIndex* ValidatedTip() const { return ValidatedChain().Tip(); }
995 
1015  bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<const CBlock>& block, bool force_processing, bool* new_block) LOCKS_EXCLUDED(cs_main);
1016 
1028  bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& block, BlockValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex = nullptr) LOCKS_EXCLUDED(cs_main);
1029 
1032 
1034  void Unload() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1035 
1037  void Reset();
1038 
1041  void MaybeRebalanceCaches() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1042 
1044  LOCK(::cs_main);
1045  UnloadBlockIndex(/* mempool */ nullptr, *this);
1046  Reset();
1047  }
1048 };
1049 
1051 extern std::unique_ptr<CBlockTreeDB> pblocktree;
1052 
1053 using FopenFn = std::function<FILE*(const fs::path&, const char*)>;
1054 
1056 bool DumpMempool(const CTxMemPool& pool, FopenFn mockable_fopen_function = fsbridge::fopen, bool skip_file_commit = false);
1057 
1059 bool LoadMempool(CTxMemPool& pool, CChainState& active_chainstate, FopenFn mockable_fopen_function = fsbridge::fopen);
1060 
1068 const AssumeutxoData* ExpectedAssumeutxo(const int height, const CChainParams& params);
1069 
1070 #endif // BITCOIN_VALIDATION_H
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:386
MempoolAcceptResult(std::list< CTransactionRef > &&replaced_txns, CAmount fees)
Constructor for success case.
Definition: validation.h:200
static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT
Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors.
Definition: validation.h:67
size_t m_coinstip_cache_size_bytes
The cache size of the in-memory coins view.
Definition: validation.h:676
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)
Definition: validation.h:77
bool LoadBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
bool CheckSequenceLocks(CBlockIndex *tip, const CCoinsView &coins_view, const CTransaction &tx, int flags, LockPoints *lp=nullptr, bool useExistingLockPoints=false)
Check if transaction will be BIP68 final in the next block to be created on top of tip...
Definition: validation.cpp:232
int GetSpendHeight(const CCoinsViewCache &inputs) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Return the spend height, which is one more than the inputs.GetBestBlock().
CBlockIndex * FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Return the tip of the chain with the most work in it, that isn&#39;t known to be invalid (it&#39;s however fa...
static const unsigned int DEFAULT_DESCENDANT_LIMIT
Default for -limitdescendantcount, max number of in-mempool descendants.
Definition: validation.h:69
bool LoadBlockIndex(const Consensus::Params &consensus_params, CBlockTreeDB &blocktree, std::set< CBlockIndex *, CBlockIndexWorkComparator > &block_index_candidates) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Load the blocktree off disk and into memory.
int64_t nMaxTipAge
If the tip is older than this (in seconds), the node is considered to be in initial block download...
Definition: validation.cpp:125
bool IsBackgroundIBD(CChainState *chainstate) const
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:102
bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const
Definition: validation.cpp:87
CChain m_chain
The current chain of blockheaders we consult and build on.
Definition: validation.h:633
CChainState & ValidatedChainstate() const
Return the most-work chainstate that has been fully validated.
void PruneBlockIndexCandidates()
Delete all entries in setBlockIndexCandidates that are worse than the current tip.
std::unique_ptr< CChainState > m_ibd_chainstate GUARDED_BY(::cs_main)
The chainstate used under normal operation (i.e.
assert(!tx.IsCoinBase())
FILE * fopen(const fs::path &p, const char *mode)
Definition: fs.cpp:24
enum ScriptError_t ScriptError
Describes a place in the block chain to another node such that if the other node doesn&#39;t have the sam...
Definition: block.h:114
CTransactionRef GetTransaction(const CBlockIndex *const block_index, const CTxMemPool *const mempool, const uint256 &hash, const Consensus::Params &consensusParams, uint256 &hashBlock)
Return transaction from the block at block_index.
void swap(CScriptCheck &check)
Definition: validation.h:317
Bilingual messages:
Definition: translation.h:16
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition: validation.h:395
Definition: block.h:62
The cache is at >= 90% capacity.
A convenience class for constructing the CCoinsView* hierarchy used to facilitate access to the UTXO ...
Definition: validation.h:512
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:866
void FindFilesToPrune(std::set< int > &setFilesToPrune, uint64_t nPruneAfterHeight, int chain_tip_height, int prune_height, bool is_ibd)
Prune block and undo files (blk???.dat and undo???.dat) so that the disk space used is less than a us...
An in-memory indexed chain of blocks.
Definition: chain.h:392
CBlockIndex * GetLastCheckpoint(const CCheckpointData &data) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Returns last CBlockIndex* that is a checkpoint.
const std::optional< std::list< CTransactionRef > > m_replaced_transactions
Mempool transactions replaced by the tx per BIP 125 rules.
Definition: validation.h:180
unsigned int nFlags
Definition: validation.h:305
static const int64_t DEFAULT_MAX_TIP_AGE
Definition: validation.h:78
void CheckBlockIndex()
Make various assertions about the state of the block index.
inv message data
Definition: protocol.h:485
std::function< FILE *(const fs::path &, const char *)> FopenFn
Definition: validation.h:1053
PackageMempoolAcceptResult(PackageValidationState state, std::map< const uint256, const MempoolAcceptResult > &&results)
Definition: validation.h:218
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition: packages.h:32
CBlockIndex * pindexBestHeader
Best header we&#39;ve seen so far (used for getheaders queries&#39; starting points).
Definition: validation.cpp:117
static const unsigned int MIN_BLOCKS_TO_KEEP
Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ::ChainActive().Tip() will not be pruned.
Definition: validation.h:88
static const unsigned int DEFAULT_ANCESTOR_LIMIT
Default for -limitancestorcount, max number of in-mempool ancestors.
Definition: validation.h:65
bool RollforwardBlock(const CBlockIndex *pindex, CCoinsViewCache &inputs) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Apply the effects of a block on the utxo cache, ignoring that it may already have been applied...
DisconnectResult
Definition: validation.h:366
unsigned int nHeight
CChain & ValidatedChain() const
Definition: validation.h:993
bool g_parallel_script_checks
Whether there are dedicated script-checking threads running.
Definition: validation.cpp:121
ResultType
Used to indicate the results of mempool validation.
Definition: validation.h:171
int Height() const
Return the maximal height in the chain.
Definition: chain.h:428
void ForceFlushStateToDisk()
Unconditionally flush all changes to disk.
std::map< const uint256, const MempoolAcceptResult > m_tx_results
Map from wtxid to finished MempoolAcceptResults.
Definition: validation.h:216
#define LOCK_RETURNED(x)
Definition: threadsafety.h:47
bool DumpMempool(const CTxMemPool &pool, FopenFn mockable_fopen_function=fsbridge::fopen, bool skip_file_commit=false)
Dump the mempool to disk.
The coins cache is in immediate need of a flush.
void ResetCoinsViews()
Destructs all objects related to accessing the UTXO set.
Definition: validation.h:670
CChainState stores and provides an API to update our local knowledge of the current best chain...
Definition: validation.h:561
PackageMempoolAcceptResult(const uint256 &wtxid, const MempoolAcceptResult &result)
Constructor to create a PackageMempoolAcceptResult from a single MempoolAcceptResult.
Definition: validation.h:223
const TxValidationState m_state
Definition: validation.h:176
bool PreciousBlock(BlockValidationState &state, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main)
Mark a block as precious and reorganize.
bool TestBlockValidity(BlockValidationState &state, const CChainParams &chainparams, CChainState &chainstate, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW=true, bool fCheckMerkleRoot=true) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Check a block is completely valid from start to finish (only works on top of our current best block) ...
static MempoolAcceptResult Success(std::list< CTransactionRef > &&replaced_txns, CAmount fees)
Definition: validation.h:187
const std::optional< CAmount > m_base_fees
Raw base fees in satoshis.
Definition: validation.h:182
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
Definition: chainparams.h:69
ScriptError error
Definition: validation.h:307
const ResultType m_result_type
Definition: validation.h:175
CBlockIndex * LookupBlockIndex(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition: validation.cpp:147
std::atomic< bool > m_cached_finished_ibd
Whether this chainstate is undergoing initial block download.
Definition: validation.h:588
bool DisconnectTip(BlockValidationState &state, DisconnectedBlockTransactions *disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
Disconnect m_chain&#39;s tip.
const std::vector< std::string > CHECKLEVEL_DOC
Documentation for argument &#39;checklevel&#39;.
Definition: validation.cpp:78
double GuessVerificationProgress(const ChainTxData &data, const CBlockIndex *pindex)
Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip).
bool ActivateBestChain(BlockValidationState &state, std::shared_ptr< const CBlock > pblock=nullptr) LOCKS_EXCLUDED(cs_main)
Find the best known block, and make it the tip of the block chain.
bool cacheStore
Definition: validation.h:306
MempoolAcceptResult AcceptToMemoryPool(CChainState &active_chainstate, CTxMemPool &pool, const CTransactionRef &tx, bool bypass_limits, bool test_accept=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
(Try to) add a transaction to the memory pool.
CTxOut m_tx_out
Definition: validation.h:302
Called by RandAddPeriodic()
bool AbortNode(BlockValidationState &state, const std::string &strMessage, const bilingual_str &userMessage=bilingual_str{})
CScriptCheck(const CTxOut &outIn, const CTransaction &txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData *txdataIn)
Definition: validation.h:312
friend CChainState
Definition: validation.h:397
Transaction validation functions.
Definition: params.h:12
void UpdateTip(const CBlockIndex *pindexNew) EXCLUSIVE_LOCKS_REQUIRED(frien ChainstateManager)
Check warning conditions and do some notifications on new chain tip set.
Definition: validation.h:827
void InvalidBlockFound(CBlockIndex *pindex, const BlockValidationState &state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Metadata describing a serialized version of a UTXO set from which an assumeutxo CChainState can be co...
Definition: utxo_snapshot.h:14
void LoadMempool(const ArgsManager &args)
Load the persisted mempool from disk.
const std::optional< uint256 > m_from_snapshot_blockhash
The blockhash which is the base of the snapshot this chainstate was created from. ...
Definition: validation.h:640
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
bool AcceptBlockHeader(const CBlockHeader &block, BlockValidationState &state, const CChainParams &chainparams, CBlockIndex **ppindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
If a block header hasn&#39;t already been seen, call CheckBlockHeader on it, ensure that it doesn&#39;t desce...
void PruneAndFlush()
Prune blockfiles from the disk if necessary and then flush chainstate changes if we pruned...
bool IsValid() const
Definition: validation.h:119
RecursiveMutex m_cs_chainstate
the ChainState CriticalSection A lock that must be held when modifying this ChainState - held in Acti...
Definition: validation.h:580
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition: string.h:79
CoinsViews(std::string ldb_name, size_t cache_size_bytes, bool in_memory, bool should_wipe)
This constructor initializes CCoinsViewDB and CCoinsViewErrorCatcher instances, but it does not creat...
static const bool DEFAULT_PERSIST_MEMPOOL
Default for -persistmempool.
Definition: validation.h:84
bool m_snapshot_validated
If true, the assumed-valid chainstate has been fully validated by the background validation chainstat...
Definition: validation.h:910
bool ActivateBestChainStep(BlockValidationState &state, CBlockIndex *pindexMostWork, const std::shared_ptr< const CBlock > &pblock, bool &fInvalidFound, ConnectTrace &connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main
Dictates whether we need to flush the cache to disk or not.
bool NeedsRedownload() const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Whether the chain state needs to be redownloaded due to lack of witness data.
void UpdateUncommittedBlockStructures(CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
Update uncommitted block structures (currently: only the witness reserved value). ...
bool IsSnapshotActive() const
CCoinsViewDB & CoinsDB() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition: validation.h:657
Access to the block database (blocks/index/)
Definition: txdb.h:74
Abstract view on the open txout dataset.
Definition: coins.h:157
bool PopulateAndValidateSnapshot(CChainState &snapshot_chainstate, CAutoFile &coins_file, const SnapshotMetadata &metadata)
Internal helper for ActivateSnapshot().
Validation result for package mempool acceptance.
Definition: validation.h:208
BlockMap m_block_index GUARDED_BY(cs_main)
CBlockIndex * InsertBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Create a new block index entry for a given block hash.
PackageMempoolAcceptResult ProcessNewPackage(CChainState &active_chainstate, CTxMemPool &pool, const Package &txns, bool test_accept) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Atomically test acceptance of a package.
void InitScriptExecutionCache()
Initializes the script-execution cache.
#define LOCK(cs)
Definition: sync.h:232
void MaybeUpdateMempoolForReorg(DisconnectedBlockTransactions &disconnectpool, bool fAddToMempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
Make mempool consistent after a reorg, by re-adding or recursively erasing disconnected block transac...
Definition: validation.cpp:332
bool LoadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Load the block tree and coins database from disk, initializing state if we&#39;re running with -reindex...
bool IsSnapshotValidated() const
Is there a snapshot in use and has it been fully validated?
Definition: validation.h:981
FlushStateMode
Definition: validation.h:376
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
Definition: validation.h:354
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE
Default for -minrelaytxfee, minimum relay fee for transactions.
Definition: validation.h:63
int ActiveHeight() const
Definition: validation.h:966
CChainState *m_active_chainstate GUARDED_BY(::cs_main)
Points to either the ibd or snapshot chainstate; indicates our most-work chain.
Definition: validation.h:906
Holds various statistics on transactions within a chain.
Definition: chainparams.h:59
const PackageValidationState m_state
Definition: validation.h:210
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT
Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants.
Definition: validation.h:71
static const unsigned int DEFAULT_MEMPOOL_EXPIRY
Default for -mempoolexpiry, expiration time for mempool transactions in hours.
Definition: validation.h:73
static constexpr bool DEFAULT_COINSTATSINDEX
Definition: validation.h:81
static const int DEFAULT_STOPATHEIGHT
Default for -stopatheight.
Definition: validation.h:86
CBlockIndex * AddToBlockIndex(const CBlockHeader &block) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
arith_uint256 nMinimumChainWork
Minimum work we will assume exists on some valid chain.
Definition: validation.cpp:128
Definition: net.h:747
An output of a transaction.
Definition: transaction.h:128
bool InvalidateBlock(BlockValidationState &state, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main)
Mark a block as invalid.
std::unique_ptr< CoinsViews > m_coins_views
Manages the UTXO set, which is a reflection of the contents of m_chain.
Definition: validation.h:597
const CChainParams & m_params
Definition: validation.h:594
void PruneBlockFilesManual(CChainState &active_chainstate, int nManualPruneHeight)
Prune block files up to a given height.
Parameters that influence chain consensus.
Definition: params.h:70
bool ProcessNewBlock(const CChainParams &chainparams, const std::shared_ptr< const CBlock > &block, bool force_processing, bool *new_block) LOCKS_EXCLUDED(cs_main)
Process an incoming block.
void ReceivedBlockTransactions(const CBlock &block, CBlockIndex *pindexNew, const FlatFilePos &pos) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS).
CChainState(CTxMemPool *mempool, BlockManager &blockman, std::optional< uint256 > from_snapshot_blockhash=std::nullopt)
bool LoadMempool(CTxMemPool &pool, CChainState &active_chainstate, FopenFn mockable_fopen_function=fsbridge::fopen)
Load the mempool from disk.
static const char *const DEFAULT_BLOCKFILTERINDEX
Definition: validation.h:82
arith_uint256 nLastPreciousChainwork
chainwork for the last block that preciousblock has been applied to.
Definition: validation.h:574
Validation result for a single transaction mempool acceptance.
Definition: validation.h:169
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
MempoolAcceptResult(TxValidationState state)
Constructor for failure case.
Definition: validation.h:194
#define Assume(val)
Assume is the identity function.
Definition: check.h:72
bool m_mempool cs
Definition: validation.h:736
256-bit unsigned big integer.
void StopScriptCheckWorkerThreads()
Stop all of the script checking worker threads.
std::thread m_load_block
Definition: validation.h:919
bool ReplayBlocks()
Replay blocks that aren&#39;t fully applied to the database.
int64_t m_total_coinstip_cache
The total number of bytes available for us to use across all in-memory coins caches.
Definition: validation.h:926
uint256 g_best_block
Definition: validation.cpp:120
Closure representing one script verification Note that this stores references to the spending transac...
Definition: validation.h:299
std::set< CBlockIndex * > m_failed_blocks
In order to efficiently track invalidity of headers, we keep the set of blocks which we tried to conn...
Definition: validation.h:441
bool AcceptBlock(const std::shared_ptr< const CBlock > &pblock, BlockValidationState &state, CBlockIndex **ppindex, bool fRequested, const FlatFilePos *dbp, bool *fNewBlock) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Store block on disk.
void UnloadBlockIndex()
bool ProcessNewBlockHeaders(const std::vector< CBlockHeader > &block, BlockValidationState &state, const CChainParams &chainparams, const CBlockIndex **ppindex=nullptr) LOCKS_EXCLUDED(cs_main)
Process incoming block headers.
int32_t nBlockSequenceId
Blocks loaded from disk are assigned id 0, so start the counter at 1.
Definition: validation.h:570
int flags
Definition: bitcoin-tx.cpp:512
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) ...
Definition: validation.cpp:130
std::condition_variable g_best_block_cv
Definition: validation.cpp:119
void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
256-bit opaque blob.
Definition: uint256.h:124
CoinsCacheSizeState
Definition: validation.h:538
const CTransaction * ptxTo
Definition: validation.h:303
CChainState &InitializeChainstate(CTxMemPool *mempool, const std::optional< uint256 > &snapshot_blockhash=std::nullopt) EXCLUSIVE_LOCKS_REQUIRED(std::vector< CChainState * GetAll)()
Instantiate a new chainstate and assign it based upon whether it is from a snapshot.
Definition: validation.h:945
DisconnectResult DisconnectBlock(const CBlock &block, const CBlockIndex *pindex, CCoinsViewCache &view)
Undo the effects of this block (with given index) on the UTXO set represented by coins.
bool ConnectBlock(const CBlock &block, BlockValidationState &state, CBlockIndex *pindex, CCoinsViewCache &view, bool fJustCheck=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Apply the effects of this block (with given index) on the UTXO set represented by coins...
static const bool DEFAULT_CHECKPOINTS_ENABLED
Definition: validation.h:79
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:477
int32_t nBlockReverseSequenceId
Decreasing counter (used by subsequent preciousblock calls).
Definition: validation.h:572
size_t m_coinsdb_cache_size_bytes
The cache size of the on-disk coins view.
Definition: validation.h:673
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:48
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
Definition: validation.cpp:115
bool fRequireStandard
Definition: validation.cpp:122
CCoinsViewDB m_dbview GUARDED_BY(cs_main)
The lowest level of the CoinsViews cache hierarchy sits in a leveldb database on disk.
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:137
const CChainParams & Params()
Return the currently selected parameters.
bool FlushStateToDisk(BlockValidationState &state, FlushStateMode mode, int nManualPruneHeight=0)
Update the on-disk chain state.
Undo information for a CBlock.
Definition: undo.h:63
static const signed int DEFAULT_CHECKBLOCKS
Definition: validation.h:89
CCoinsView backed by the coin database (chainstate/)
Definition: txdb.h:46
bool ActivateSnapshot(CAutoFile &coins_file, const SnapshotMetadata &metadata, bool in_memory)
Construct and activate a Chainstate on the basis of UTXO snapshot data.
void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, int nHeight)
Apply the effects of this transaction on the UTXO set represented by view.
uint256 hashAssumeValid
Block hash whose ancestors we will assume to have valid scripts without checking them.
Definition: validation.cpp:127
void Unload() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Clear all data members.
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
Definition: chain.h:403
bool IsInitialBlockDownload() const
Check whether we are doing an initial block download (synchronizing from disk or network) ...
std::set< CBlockIndex *, CBlockIndexWorkComparator > setBlockIndexCandidates
The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for itself and all ancestors) and a...
Definition: validation.h:647
std::vector< unsigned char > GenerateCoinbaseCommitment(CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
Produce the necessary coinbase commitment for a block (modifies the hash, don&#39;t call for mined blocks...
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:29
Holds configuration for use during UTXO snapshot load and validation.
Definition: chainparams.h:40
BlockManager & m_blockman
Reference to a BlockManager instance which itself is shared across all CChainState instances...
Definition: validation.h:602
bool TestLockPointValidity(CChain &active_chain, const LockPoints *lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Test whether the LockPoints height and time are still valid on the current chain. ...
Definition: validation.cpp:214
const AssumeutxoData * ExpectedAssumeutxo(const int height, const CChainParams &params)
Return the expected assumeutxo value for a given height, if one exists.
CBlockIndex * ValidatedTip() const
Definition: validation.h:994
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition: validation.h:650
unsigned int nIn
Definition: validation.h:304
std::multimap< CBlockIndex *, CBlockIndex * > m_blocks_unlinked
All pairs A->B, where A (or one of its ancestors) misses transactions, but B has transactions.
Definition: validation.h:447
bool CheckBlock(const CBlock &block, BlockValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW=true, bool fCheckMerkleRoot=true)
Functions for validating blocks and updating the block tree.
CChainState & ActiveChainstate() const
The most-work chain.
static MempoolAcceptResult Failure(TxValidationState state)
Definition: validation.h:183
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:259
std::optional< uint256 > SnapshotBlockhash() const
void UnloadBlockIndex(CTxMemPool *mempool, ChainstateManager &chainman)
Unload database information.
std::unordered_map< uint256, CBlockIndex *, BlockHasher > BlockMap
Definition: validation.h:109
int64_t m_total_coinsdb_cache
The total number of bytes available for us to use across all leveldb coins databases.
Definition: validation.h:930
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:213
bool LoadGenesisBlock()
Ensures we have a genesis block in the block tree, possibly writing one to disk.
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
Definition: validation.h:99
bool fCheckpointsEnabled
Definition: validation.cpp:124
CBlockIndex * FindForkInGlobalIndex(const CChain &chain, const CBlockLocator &locator) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Find the last common block between the parameter chain and a locator.
Definition: validation.cpp:154
void PruneOneBlockFile(const int fileNumber) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Mark one block file as pruned (modify associated database entries)
void InitCoinsDB(size_t cache_size_bytes, bool in_memory, bool should_wipe, std::string leveldb_name="chainstate")
Initialize the CoinsViews UTXO set database management data structures.
void StartScriptCheckWorkerThreads(int threads_num)
Run instances of script checking worker threads.
bool ConnectTip(BlockValidationState &state, CBlockIndex *pindexNew, const std::shared_ptr< const CBlock > &pblock, ConnectTrace &connectTrace, DisconnectedBlockTransactions &disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
Connect a new block to m_chain.
This is a minimally invasive approach to shutdown on LevelDB read errors from the chainstate...
Definition: coins.h:343
ScriptError GetScriptError() const
Definition: validation.h:327
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
std::unique_ptr< CBlockTreeDB > pblocktree
Global variable that points to the active block tree (protected by cs_main)
Definition: validation.cpp:173
bool LoadChainTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Update the chain tip based on database information, i.e.
void ResetBlockFailureFlags(CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Remove invalidity status from a block and its descendants.
static const bool DEFAULT_TXINDEX
Definition: validation.h:80
RecursiveMutex cs_nBlockSequenceId
Every received block is assigned a unique and increasing identifier, so we know which one to give pri...
Definition: validation.h:568
Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce value...
Definition: block.h:20
RecursiveMutex * MempoolMutex() const LOCK_RETURNED(m_mempool -> cs)
Indirection necessary to make lock annotations work with an optional mempool.
Definition: validation.h:804
CChain & ActiveChain() const
Definition: validation.h:965
CCoinsViewErrorCatcher & CoinsErrorCatcher() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition: validation.h:664
static const unsigned int DEFAULT_CHECKLEVEL
Definition: validation.h:90
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:564
bool fCheckBlockIndex
Definition: validation.cpp:123
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
Definition: txmempool.h:565
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.
Definition: validation.h:75
void InvalidChainFound(CBlockIndex *pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
bool CheckFinalTx(const CBlockIndex *active_chain_tip, const CTransaction &tx, int flags=-1) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Transaction validation functions.
Definition: validation.cpp:181
CBlockIndex * ActiveTip() const
Definition: validation.h:967
LockPoints lp
CTxMemPool * m_mempool
Optional mempool that is kept in sync with the chain.
Definition: validation.h:592
Used to track blocks whose transactions were applied to the UTXO state as a part of a single Activate...
void FindFilesToPruneManual(std::set< int > &setFilesToPrune, int nManualPruneHeight, int chain_tip_height)
Mutex g_best_block_mutex
Definition: validation.cpp:118
PrecomputedTransactionData * txdata
Definition: validation.h:308
BlockMap & BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:969