Bitcoin Core  26.1.0
P2P Digital Currency
validation.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2022 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 <arith_uint256.h>
14 #include <attributes.h>
15 #include <chain.h>
16 #include <kernel/chain.h>
17 #include <consensus/amount.h>
18 #include <deploymentstatus.h>
19 #include <kernel/chainparams.h>
21 #include <kernel/cs_main.h> // IWYU pragma: export
22 #include <node/blockstorage.h>
23 #include <policy/feerate.h>
24 #include <policy/packages.h>
25 #include <policy/policy.h>
26 #include <script/script_error.h>
27 #include <sync.h>
28 #include <txdb.h>
29 #include <txmempool.h> // For CTxMemPool::cs
30 #include <uint256.h>
31 #include <util/check.h>
32 #include <util/fs.h>
33 #include <util/hasher.h>
34 #include <util/result.h>
35 #include <util/translation.h>
36 #include <versionbits.h>
37 
38 #include <atomic>
39 #include <map>
40 #include <memory>
41 #include <optional>
42 #include <set>
43 #include <stdint.h>
44 #include <string>
45 #include <thread>
46 #include <type_traits>
47 #include <utility>
48 #include <vector>
49 
50 class Chainstate;
51 class CTxMemPool;
52 class ChainstateManager;
53 struct ChainTxData;
56 struct LockPoints;
57 struct AssumeutxoData;
58 namespace node {
59 class SnapshotMetadata;
60 } // namespace node
61 namespace Consensus {
62 struct Params;
63 } // namespace Consensus
64 namespace util {
65 class SignalInterrupt;
66 } // namespace util
67 
69 static const int MAX_SCRIPTCHECK_THREADS = 15;
71 static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
73 static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
74 static const signed int DEFAULT_CHECKBLOCKS = 6;
75 static constexpr int DEFAULT_CHECKLEVEL{3};
76 // Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev???.dat)
77 // At 1MB per block, 288 blocks = 288MB.
78 // Add 15% for Undo data = 331MB
79 // Add 20% for Orphan block rate = 397MB
80 // We want the low water mark after pruning to be at least 397 MB and since we prune in
81 // full block file chunks, we need the high water mark which triggers the prune to be
82 // one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB
83 // Setting the target to >= 550 MiB will make it likely we can respect the target.
84 static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;
85 
90  POST_INIT
91 };
92 
94 extern std::condition_variable g_best_block_cv;
96 extern uint256 g_best_block;
97 
99 extern const std::vector<std::string> CHECKLEVEL_DOC;
100 
102 void StartScriptCheckWorkerThreads(int threads_num);
105 
106 CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
107 
108 bool FatalError(kernel::Notifications& notifications, BlockValidationState& state, const std::string& strMessage, const bilingual_str& userMessage = {});
109 
111 double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pindex);
112 
114 void PruneBlockFilesManual(Chainstate& active_chainstate, int nManualPruneHeight);
115 
121  enum class ResultType {
122  VALID,
123  INVALID,
124  MEMPOOL_ENTRY,
126  };
129 
132 
133  // The following fields are only present when m_result_type = ResultType::VALID or MEMPOOL_ENTRY
135  const std::optional<std::list<CTransactionRef>> m_replaced_transactions;
137  const std::optional<int64_t> m_vsize;
139  const std::optional<CAmount> m_base_fees;
146  const std::optional<CFeeRate> m_effective_feerate;
152  const std::optional<std::vector<uint256>> m_wtxids_fee_calculations;
153 
154  // The following field is only present when m_result_type = ResultType::DIFFERENT_WITNESS
156  const std::optional<uint256> m_other_wtxid;
157 
159  return MempoolAcceptResult(state);
160  }
161 
162  static MempoolAcceptResult Success(std::list<CTransactionRef>&& replaced_txns,
163  int64_t vsize,
164  CAmount fees,
165  CFeeRate effective_feerate,
166  const std::vector<uint256>& wtxids_fee_calculations) {
167  return MempoolAcceptResult(std::move(replaced_txns), vsize, fees,
168  effective_feerate, wtxids_fee_calculations);
169  }
170 
171  static MempoolAcceptResult MempoolTx(int64_t vsize, CAmount fees) {
172  return MempoolAcceptResult(vsize, fees);
173  }
174 
176  return MempoolAcceptResult(other_wtxid);
177  }
178 
179 // Private constructors. Use static methods MempoolAcceptResult::Success, etc. to construct.
180 private:
183  : m_result_type(ResultType::INVALID), m_state(state) {
184  Assume(!state.IsValid()); // Can be invalid or error
185  }
186 
188  explicit MempoolAcceptResult(std::list<CTransactionRef>&& replaced_txns,
189  int64_t vsize,
190  CAmount fees,
191  CFeeRate effective_feerate,
192  const std::vector<uint256>& wtxids_fee_calculations)
193  : m_result_type(ResultType::VALID),
194  m_replaced_transactions(std::move(replaced_txns)),
195  m_vsize{vsize},
196  m_base_fees(fees),
197  m_effective_feerate(effective_feerate),
198  m_wtxids_fee_calculations(wtxids_fee_calculations) {}
199 
201  explicit MempoolAcceptResult(int64_t vsize, CAmount fees)
202  : m_result_type(ResultType::MEMPOOL_ENTRY), m_vsize{vsize}, m_base_fees(fees) {}
203 
205  explicit MempoolAcceptResult(const uint256& other_wtxid)
206  : m_result_type(ResultType::DIFFERENT_WITNESS), m_other_wtxid(other_wtxid) {}
207 };
208 
213 {
221  std::map<uint256, MempoolAcceptResult> m_tx_results;
222 
224  std::map<uint256, MempoolAcceptResult>&& results)
225  : m_state{state}, m_tx_results(std::move(results)) {}
226 
228  std::map<uint256, MempoolAcceptResult>&& results)
229  : m_state{state}, m_tx_results(std::move(results)) {}
230 
232  explicit PackageMempoolAcceptResult(const uint256& wtxid, const MempoolAcceptResult& result)
233  : m_tx_results{ {wtxid, result} } {}
234 };
235 
251  int64_t accept_time, bool bypass_limits, bool test_accept)
253 
263  const Package& txns, bool test_accept)
265 
266 /* Mempool validation helper functions */
267 
271 bool CheckFinalTxAtTip(const CBlockIndex& active_chain_tip, const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
272 
291 std::optional<LockPoints> CalculateLockPointsAtTip(
292  CBlockIndex* tip,
293  const CCoinsView& coins_view,
294  const CTransaction& tx);
295 
306  const LockPoints& lock_points);
307 
313 {
314 private:
317  unsigned int nIn;
318  unsigned int nFlags;
322 
323 public:
324  CScriptCheck(const CTxOut& outIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData* txdataIn) :
325  m_tx_out(outIn), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), txdata(txdataIn) { }
326 
327  CScriptCheck(const CScriptCheck&) = delete;
328  CScriptCheck& operator=(const CScriptCheck&) = delete;
329  CScriptCheck(CScriptCheck&&) = default;
330  CScriptCheck& operator=(CScriptCheck&&) = default;
331 
332  bool operator()();
333 
334  ScriptError GetScriptError() const { return error; }
335 };
336 
337 // CScriptCheck is used a lot in std::vector, make sure that's efficient
338 static_assert(std::is_nothrow_move_assignable_v<CScriptCheck>);
339 static_assert(std::is_nothrow_move_constructible_v<CScriptCheck>);
340 static_assert(std::is_nothrow_destructible_v<CScriptCheck>);
341 
343 [[nodiscard]] bool InitScriptExecutionCache(size_t max_size_bytes);
344 
348 bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
349 
352  const CChainParams& chainparams,
353  Chainstate& chainstate,
354  const CBlock& block,
355  CBlockIndex* pindexPrev,
356  const std::function<NodeClock::time_point()>& adjusted_time_callback,
357  bool fCheckPOW = true,
358  bool fCheckMerkleRoot = true) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
359 
361 bool HasValidProofOfWork(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams);
362 
364 bool IsBlockMutated(const CBlock& block, bool check_witness_root);
365 
367 arith_uint256 CalculateHeadersWork(const std::vector<CBlockHeader>& headers);
368 
369 enum class VerifyDBResult {
370  SUCCESS,
372  INTERRUPTED,
375 };
376 
379 {
380 private:
382 
383 public:
384  explicit CVerifyDB(kernel::Notifications& notifications);
385  ~CVerifyDB();
386  [[nodiscard]] VerifyDBResult VerifyDB(
387  Chainstate& chainstate,
388  const Consensus::Params& consensus_params,
389  CCoinsView& coinsview,
390  int nCheckLevel,
391  int nCheckDepth) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
392 };
393 
395 {
396  DISCONNECT_OK, // All good.
397  DISCONNECT_UNCLEAN, // Rolled back, but UTXO set was inconsistent with block.
398  DISCONNECT_FAILED // Something else went wrong.
399 };
400 
401 class ConnectTrace;
402 
404 enum class FlushStateMode {
405  NONE,
406  IF_NEEDED,
407  PERIODIC,
408  ALWAYS
409 };
410 
420 class CoinsViews {
421 
422 public:
425  CCoinsViewDB m_dbview GUARDED_BY(cs_main);
426 
429 
432  std::unique_ptr<CCoinsViewCache> m_cacheview GUARDED_BY(cs_main);
433 
440  CoinsViews(DBParams db_params, CoinsViewOptions options);
441 
443  void InitCache() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
444 };
445 
447 {
449  CRITICAL = 2,
451  LARGE = 1,
452  OK = 0
453 };
454 
470 {
471 protected:
478 
482 
484  std::unique_ptr<CoinsViews> m_coins_views;
485 
497  bool m_disabled GUARDED_BY(::cs_main) {false};
498 
500  const CBlockIndex* m_cached_snapshot_base GUARDED_BY(::cs_main) {nullptr};
501 
502 public:
506 
511 
512  explicit Chainstate(
513  CTxMemPool* mempool,
514  node::BlockManager& blockman,
515  ChainstateManager& chainman,
516  std::optional<uint256> from_snapshot_blockhash = std::nullopt);
517 
523 
530  void InitCoinsDB(
531  size_t cache_size_bytes,
532  bool in_memory,
533  bool should_wipe,
534  fs::path leveldb_name = "chainstate");
535 
538  void InitCoinsCache(size_t cache_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
539 
542  bool CanFlushToDisk() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
543  {
545  return m_coins_views && m_coins_views->m_cacheview;
546  }
547 
551 
557  const std::optional<uint256> m_from_snapshot_blockhash;
558 
564  const CBlockIndex* SnapshotBase() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
565 
572  std::set<CBlockIndex*, node::CBlockIndexWorkComparator> setBlockIndexCandidates;
573 
576  {
579  return *Assert(m_coins_views->m_cacheview);
580  }
581 
584  {
586  return Assert(m_coins_views)->m_dbview;
587  }
588 
591  {
592  return m_mempool;
593  }
594 
598  {
600  return Assert(m_coins_views)->m_catcherview;
601  }
602 
604  void ResetCoinsViews() { m_coins_views.reset(); }
605 
607  bool HasCoinsViews() const { return (bool)m_coins_views; }
608 
611 
614 
617  bool ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size)
619 
631  bool FlushStateToDisk(
632  BlockValidationState& state,
633  FlushStateMode mode,
634  int nManualPruneHeight = 0);
635 
637  void ForceFlushStateToDisk();
638 
641  void PruneAndFlush();
642 
664  bool ActivateBestChain(
665  BlockValidationState& state,
666  std::shared_ptr<const CBlock> pblock = nullptr)
669 
670  // Block (dis)connection on a given view:
671  DisconnectResult DisconnectBlock(const CBlock& block, const CBlockIndex* pindex, CCoinsViewCache& view)
673  bool ConnectBlock(const CBlock& block, BlockValidationState& state, CBlockIndex* pindex,
674  CCoinsViewCache& view, bool fJustCheck = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
675 
676  // Apply the effects of a block disconnection on the UTXO set.
678 
679  // Manual block validity manipulation:
684  bool PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
687 
689  bool InvalidateBlock(BlockValidationState& state, CBlockIndex* pindex)
692 
695 
697  bool ReplayBlocks();
698 
700  [[nodiscard]] bool NeedsRedownload() const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
702  bool LoadGenesisBlock();
703 
705 
707 
708  void ClearBlockIndexCandidates() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
709 
711  const CBlockIndex* FindForkInGlobalIndex(const CBlockLocator& locator) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
712 
715 
719  CoinsCacheSizeState GetCoinsCacheSizeState() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
720 
721  CoinsCacheSizeState GetCoinsCacheSizeState(
722  size_t max_coins_cache_size_bytes,
723  size_t max_mempool_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
724 
726 
728  RecursiveMutex* MempoolMutex() const LOCK_RETURNED(m_mempool->cs)
729  {
730  return m_mempool ? &m_mempool->cs : nullptr;
731  }
732 
733 private:
734  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);
735  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);
736 
739 
741 
744 
759  DisconnectedBlockTransactions& disconnectpool,
761 
763  void UpdateTip(const CBlockIndex* pindexNew)
765 
766  SteadyClock::time_point m_last_write{};
767  SteadyClock::time_point m_last_flush{};
768 
773  [[nodiscard]] util::Result<void> InvalidateCoinsDBOnDisk() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
774 
775  friend ChainstateManager;
776 };
777 
778 
780  SUCCESS,
781  SKIPPED,
782 
783  // Expected assumeutxo configuration data is not found for the height of the
784  // base block.
786 
787  // Failed to generate UTXO statistics (to check UTXO set hash) for the background
788  // chainstate.
789  STATS_FAILED,
790 
791  // The UTXO set hash of the background validation chainstate does not match
792  // the one expected by assumeutxo chainparams.
794 
795  // The blockhash of the current tip of the background validation chainstate does
796  // not match the one expected by the snapshot chainstate.
798 };
799 
828 {
829 private:
846  std::unique_ptr<Chainstate> m_ibd_chainstate GUARDED_BY(::cs_main);
847 
858  std::unique_ptr<Chainstate> m_snapshot_chainstate GUARDED_BY(::cs_main);
859 
862  Chainstate* m_active_chainstate GUARDED_BY(::cs_main) {nullptr};
863 
864  CBlockIndex* m_best_invalid GUARDED_BY(::cs_main){nullptr};
865 
867  [[nodiscard]] bool PopulateAndValidateSnapshot(
868  Chainstate& snapshot_chainstate,
869  AutoFile& coins_file,
870  const node::SnapshotMetadata& metadata);
871 
879  bool AcceptBlockHeader(
880  const CBlockHeader& block,
881  BlockValidationState& state,
882  CBlockIndex** ppindex,
883  bool min_pow_checked) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
884  friend Chainstate;
885 
887  std::chrono::time_point<std::chrono::steady_clock> m_last_presync_update GUARDED_BY(::cs_main) {};
888 
889  std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> m_warningcache GUARDED_BY(::cs_main);
890 
896  bool IsUsable(const Chainstate* const cs) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
897  return cs && !cs->m_disabled;
898  }
899 
900 public:
902 
903  explicit ChainstateManager(const util::SignalInterrupt& interrupt, Options options, node::BlockManager::Options blockman_options);
904 
907  std::function<void()> restart_indexes = std::function<void()>();
908 
909  const CChainParams& GetParams() const { return m_options.chainparams; }
910  const Consensus::Params& GetConsensus() const { return m_options.chainparams.GetConsensus(); }
911  bool ShouldCheckBlockIndex() const { return *Assert(m_options.check_block_index); }
912  const arith_uint256& MinimumChainWork() const { return *Assert(m_options.minimum_chain_work); }
913  const uint256& AssumedValidBlock() const { return *Assert(m_options.assumed_valid_block); }
914  kernel::Notifications& GetNotifications() const { return m_options.notifications; };
915 
921  void CheckBlockIndex();
922 
935 
938  std::thread m_thread_load;
942 
950  mutable std::atomic<bool> m_cached_finished_ibd{false};
951 
957  int32_t nBlockSequenceId GUARDED_BY(::cs_main) = 1;
959  int32_t nBlockReverseSequenceId = -1;
961  arith_uint256 nLastPreciousChainwork = 0;
962 
963  // Reset the memory-only sequence counters we use to track block arrival
964  // (used by tests to reset state)
966  {
968  nBlockSequenceId = 1;
969  nBlockReverseSequenceId = -1;
970  }
971 
972 
992  std::set<CBlockIndex*> m_failed_blocks;
993 
995  CBlockIndex* m_best_header GUARDED_BY(::cs_main){nullptr};
996 
999  int64_t m_total_coinstip_cache{0};
1000  //
1003  int64_t m_total_coinsdb_cache{0};
1004 
1008  // constructor
1009  Chainstate& InitializeChainstate(CTxMemPool* mempool) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1010 
1012  std::vector<Chainstate*> GetAll();
1013 
1027  [[nodiscard]] bool ActivateSnapshot(
1028  AutoFile& coins_file, const node::SnapshotMetadata& metadata, bool in_memory);
1029 
1037  SnapshotCompletionResult MaybeCompleteSnapshotValidation() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1038 
1040  const CBlockIndex* GetSnapshotBaseBlock() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1041 
1043  Chainstate& ActiveChainstate() const;
1044  CChain& ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChainstate().m_chain; }
1045  int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChain().Height(); }
1046  CBlockIndex* ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChain().Tip(); }
1047 
1050  return IsUsable(m_snapshot_chainstate.get()) && IsUsable(m_ibd_chainstate.get());
1051  }
1052 
1055  return BackgroundSyncInProgress() ? m_ibd_chainstate->m_chain.Tip() : nullptr;
1056  }
1057 
1059  {
1061  return m_blockman.m_block_index;
1062  }
1063 
1068 
1071  bool IsSnapshotActive() const;
1072 
1073  std::optional<uint256> SnapshotBlockhash() const;
1074 
1077  {
1078  return m_snapshot_chainstate && m_ibd_chainstate && m_ibd_chainstate->m_disabled;
1079  }
1080 
1082  bool IsInitialBlockDownload() const;
1083 
1110  void LoadExternalBlockFile(
1111  CAutoFile& file_in,
1112  FlatFilePos* dbp = nullptr,
1113  std::multimap<uint256, FlatFilePos>* blocks_with_unknown_parent = nullptr);
1114 
1139  bool ProcessNewBlock(const std::shared_ptr<const CBlock>& block, bool force_processing, bool min_pow_checked, bool* new_block) LOCKS_EXCLUDED(cs_main);
1140 
1152  bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& block, bool min_pow_checked, BlockValidationState& state, const CBlockIndex** ppindex = nullptr) LOCKS_EXCLUDED(cs_main);
1153 
1173  bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, BlockValidationState& state, CBlockIndex** ppindex, bool fRequested, const FlatFilePos* dbp, bool* fNewBlock, bool min_pow_checked) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
1174 
1175  void ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pindexNew, const FlatFilePos& pos) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
1176 
1183  [[nodiscard]] MempoolAcceptResult ProcessTransaction(const CTransactionRef& tx, bool test_accept=false)
1185 
1187  bool LoadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
1188 
1191  void MaybeRebalanceCaches() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1192 
1194  void UpdateUncommittedBlockStructures(CBlock& block, const CBlockIndex* pindexPrev) const;
1195 
1197  std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBlockIndex* pindexPrev) const;
1198 
1203  void ReportHeadersPresync(const arith_uint256& work, int64_t height, int64_t timestamp);
1204 
1207  bool DetectSnapshotChainstate() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1208 
1209  void ResetChainstates() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1210 
1213  [[nodiscard]] bool DeleteSnapshotChainstate() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1214 
1217  Chainstate& ActivateExistingSnapshot(uint256 base_blockhash) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1218 
1228  bool ValidatedSnapshotCleanup() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1229 
1238  Chainstate& GetChainstateForIndexing() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1239 
1243  std::pair<int, int> GetPruneRange(
1244  const Chainstate& chainstate, int last_height_can_prune) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1245 
1248  std::optional<int> GetSnapshotBaseHeight() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1249 
1251 };
1252 
1254 template<typename DEP>
1255 bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const ChainstateManager& chainman, DEP dep)
1256 {
1257  return DeploymentActiveAfter(pindexPrev, chainman.GetConsensus(), dep, chainman.m_versionbitscache);
1258 }
1259 
1260 template<typename DEP>
1261 bool DeploymentActiveAt(const CBlockIndex& index, const ChainstateManager& chainman, DEP dep)
1262 {
1263  return DeploymentActiveAt(index, chainman.GetConsensus(), dep, chainman.m_versionbitscache);
1264 }
1265 
1266 template<typename DEP>
1267 bool DeploymentEnabled(const ChainstateManager& chainman, DEP dep)
1268 {
1269  return DeploymentEnabled(chainman.GetConsensus(), dep);
1270 }
1271 
1273 bool IsBIP30Repeat(const CBlockIndex& block_index);
1274 
1276 bool IsBIP30Unspendable(const CBlockIndex& block_index);
1277 
1278 #endif // BITCOIN_VALIDATION_H
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:421
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:575
std::thread m_thread_load
Definition: validation.h:938
const std::optional< CFeeRate > m_effective_feerate
The feerate at which this transaction was considered.
Definition: validation.h:146
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)
Definition: validation.h:71
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
Definition: validation.h:941
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:557
const uint256 & AssumedValidBlock() const
Definition: validation.h:913
void InvalidChainFound(CBlockIndex *pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
CTxMemPool * m_mempool
Optional mempool that is kept in sync with the chain.
Definition: validation.h:481
bool ReplayBlocks()
Replay blocks that aren&#39;t fully applied to the database.
CScriptCheck & operator=(const CScriptCheck &)=delete
bool DeploymentActiveAfter(const CBlockIndex *pindexPrev, const ChainstateManager &chainman, DEP dep)
Deployment* info via ChainstateManager.
Definition: validation.h:1255
std::chrono::time_point< NodeClock > time_point
Definition: time.h:17
bool DeploymentActiveAt(const CBlockIndex &index, const ChainstateManager &chainman, DEP dep)
Definition: validation.h:1261
AssertLockHeld(pool.cs)
bool TestBlockValidity(BlockValidationState &state, const CChainParams &chainparams, Chainstate &chainstate, const CBlock &block, CBlockIndex *pindexPrev, const std::function< NodeClock::time_point()> &adjusted_time_callback, 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) ...
SteadyClock::time_point m_last_flush
Definition: validation.h:767
const Options m_options
Definition: validation.h:937
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:87
bool LoadGenesisBlock()
Ensures we have a genesis block in the block tree, possibly writing one to disk.
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:123
MempoolAcceptResult(std::list< CTransactionRef > &&replaced_txns, int64_t vsize, CAmount fees, CFeeRate effective_feerate, const std::vector< uint256 > &wtxids_fee_calculations)
Constructor for success case.
Definition: validation.h:188
CBlockIndex *m_best_invalid GUARDED_BY(::cs_main)
Definition: validation.h:864
GlobalMutex g_best_block_mutex
Definition: validation.cpp:108
Valid, transaction was already in the mempool.
node::BlockManager & m_blockman
Reference to a BlockManager instance which itself is shared across all Chainstate instances...
Definition: validation.h:500
Bilingual messages:
Definition: translation.h:18
bool InitScriptExecutionCache(size_t max_size_bytes)
Initializes the script-execution cache.
Definition: block.h:68
The cache is at >= 90% capacity.
A convenience class for constructing the CCoinsView* hierarchy used to facilitate access to the UTXO ...
Definition: validation.h:420
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:827
An in-memory indexed chain of blocks.
Definition: chain.h:441
bool ShouldCheckBlockIndex() const
Definition: validation.h:911
const std::optional< std::list< CTransactionRef > > m_replaced_transactions
Mempool transactions replaced by the tx.
Definition: validation.h:135
unsigned int nFlags
Definition: validation.h:318
PackageMempoolAcceptResult(PackageValidationState state, std::map< uint256, MempoolAcceptResult > &&results)
Definition: validation.h:223
size_t m_coinsdb_cache_size_bytes
The cache size of the on-disk coins view.
Definition: validation.h:610
VerifyDBResult VerifyDB(Chainstate &chainstate, const Consensus::Params &consensus_params, CCoinsView &coinsview, int nCheckLevel, int nCheckDepth) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition: packages.h:48
static const unsigned int MIN_BLOCKS_TO_KEEP
Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ActiveChain().Tip() will not be pr...
Definition: validation.h:73
DisconnectResult
Definition: validation.h:394
std::unique_ptr< CoinsViews > m_coins_views
Manages the UTXO set, which is a reflection of the contents of m_chain.
Definition: validation.h:484
unsigned int nHeight
static constexpr int DEFAULT_CHECKLEVEL
Definition: validation.h:75
ResultType
Used to indicate the results of mempool validation.
Definition: validation.h:121
std::unordered_map< uint256, CBlockIndex, BlockHasher > BlockMap
Definition: blockstorage.h:85
#define LOCK_RETURNED(x)
Definition: threadsafety.h:47
std::chrono::time_point< std::chrono::steady_clock > m_last_presync_update GUARDED_BY(::cs_main)
Most recent headers presync progress update, for rate-limiting.
Definition: validation.h:887
bool CheckFinalTxAtTip(const CBlockIndex &active_chain_tip, const CTransaction &tx)
Definition: validation.cpp:138
Chainstate *m_active_chainstate GUARDED_BY(::cs_main)
Points to either the ibd or snapshot chainstate; indicates our most-work chain.
Definition: validation.h:862
The coins cache is in immediate need of a flush.
An options struct for ChainstateManager, more ergonomically referred to as ChainstateManager::Options...
bool HasValidProofOfWork(const std::vector< CBlockHeader > &headers, const Consensus::Params &consensusParams)
Check with the proof of work on each blockheader matches the value in nBits.
PackageMempoolAcceptResult(const uint256 &wtxid, const MempoolAcceptResult &result)
Constructor to create a PackageMempoolAcceptResult from a single MempoolAcceptResult.
Definition: validation.h:232
const std::optional< int64_t > m_vsize
Virtual size as used by the mempool, calculated using serialized size and sigops. ...
Definition: validation.h:137
const TxValidationState m_state
Contains information about why the transaction failed.
Definition: validation.h:131
std::map< uint256, MempoolAcceptResult > m_tx_results
Map from wtxid to finished MempoolAcceptResults.
Definition: validation.h:221
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:992
const std::optional< CAmount > m_base_fees
Raw base fees in satoshis.
Definition: validation.h:139
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
Definition: chainparams.h:80
User-controlled performance and debug options.
Definition: txdb.h:44
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.
ScriptError error
Definition: validation.h:320
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:292
const ResultType m_result_type
Result type.
Definition: validation.h:128
void InvalidBlockFound(CBlockIndex *pindex, const BlockValidationState &state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
bool DeploymentEnabled(const ChainstateManager &chainman, DEP dep)
Definition: validation.h:1267
const std::vector< std::string > CHECKLEVEL_DOC
Documentation for argument &#39;checklevel&#39;.
Definition: validation.cpp:93
CChain m_chain
The current chain of blockheaders we consult and build on.
Definition: validation.h:550
double GuessVerificationProgress(const ChainTxData &data, const CBlockIndex *pindex)
Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip).
bool cacheStore
Definition: validation.h:319
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:470
CBlockIndex *m_best_header GUARDED_BY(::cs_main)
Best header we&#39;ve seen so far (used for getheaders queries&#39; starting points).
Definition: validation.h:995
bool HasCoinsViews() const
Does this chainstate have a UTXO set attached?
Definition: validation.h:607
CTxOut m_tx_out
Definition: validation.h:315
Filesystem operations and types.
void ResetCoinsViews()
Destructs all objects related to accessing the UTXO set.
Definition: validation.h:604
PackageMempoolAcceptResult(PackageValidationState state, CFeeRate feerate, std::map< uint256, MempoolAcceptResult > &&results)
Definition: validation.h:227
Called by RandAddPeriodic()
const util::SignalInterrupt & m_interrupt
Definition: validation.h:936
CScriptCheck(const CTxOut &outIn, const CTransaction &txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData *txdataIn)
Definition: validation.h:324
CVerifyDB(kernel::Notifications &notifications)
Transaction validation functions.
VersionBitsCache m_versionbitscache
Track versionbit status.
Definition: validation.h:1067
CoinsViews(DBParams db_params, CoinsViewOptions options)
This constructor initializes CCoinsViewDB and CCoinsViewErrorCatcher instances, but it does not creat...
bool IsUsable(const Chainstate *const cs) const EXCLUSIVE_LOCKS_REQUIRED(
Return true if a chainstate is considered usable.
Definition: validation.h:896
void PruneBlockFilesManual(Chainstate &active_chainstate, int nManualPruneHeight)
Prune block files up to a given height.
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
void PruneAndFlush()
Prune blockfiles from the disk if necessary and then flush chainstate changes if we pruned...
void UpdateTip(const CBlockIndex *pindexNew) EXCLUSIVE_LOCKS_REQUIRED(SteadyClock::time_poin m_last_write)
Check warning conditions and do some notifications on new chain tip set.
Definition: validation.h:766
bool IsValid() const
Definition: validation.h:121
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition: string.h:109
ChainstateManager & m_chainman
The chainstate manager that owns this chainstate.
Definition: validation.h:510
bool DisconnectTip(BlockValidationState &state, DisconnectedBlockTransactions *disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
Disconnect m_chain&#39;s tip.
An options struct for BlockManager, more ergonomically referred to as BlockManager::Options due to th...
util::Result< void > InvalidateCoinsDBOnDisk() EXCLUSIVE_LOCKS_REQUIRED(friend ChainstateManager
In case of an invalid snapshot, rename the coins leveldb directory so that it can be examined for iss...
Definition: validation.h:773
bool BackgroundSyncInProgress() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
The state of a background sync (for net processing)
Definition: validation.h:1049
Chainstate stores and provides an API to update our local knowledge of the current best chain...
Definition: validation.h:469
bool IsBIP30Repeat(const CBlockIndex &block_index)
Identifies blocks that overwrote an existing coinbase output in the UTXO set (see BIP30) ...
std::chrono::steady_clock SteadyClock
Definition: time.h:25
Abstract view on the open txout dataset.
Definition: coins.h:172
ChainstateRole
This enum describes the various roles a specific Chainstate instance can take.
Definition: chain.h:25
static void LoadExternalBlockFile(benchmark::Bench &bench)
The LoadExternalBlockFile() function is used during -reindex and -loadblock.
Validation result for package mempool acceptance.
Definition: validation.h:212
bool ActivateBestChain(BlockValidationState &state, std::shared_ptr< const CBlock > pblock=nullptr) LOCKS_EXCLUDED(DisconnectResult DisconnectBlock(const CBlock &block, const CBlockIndex *pindex, CCoinsViewCache &view) EXCLUSIVE_LOCKS_REQUIRED(boo ConnectBlock)(const CBlock &block, BlockValidationState &state, CBlockIndex *pindex, CCoinsViewCache &view, bool fJustCheck=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Find the best known block, and make it the tip of the block chain.
Definition: validation.h:673
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...
bool m_disabled GUARDED_BY(::cs_main)
This toggle exists for use when doing background validation for UTXO snapshots.
Definition: validation.h:497
SnapshotCompletionResult
Definition: validation.h:779
FlushStateMode
Definition: validation.h:404
Chainstate(CTxMemPool *mempool, node::BlockManager &blockman, ChainstateManager &chainman, std::optional< uint256 > from_snapshot_blockhash=std::nullopt)
kernel::Notifications & GetNotifications() const
Definition: validation.h:914
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
Definition: validation.h:378
bool NeedsRedownload() const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Whether the chain state needs to be redownloaded due to lack of witness data.
Holds various statistics on transactions within a chain.
Definition: chainparams.h:70
const Consensus::Params & GetConsensus() const
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
Try to make some progress towards making pindexMostWork the active block.
CBlockIndex * ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Definition: validation.h:1046
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition: blockstorage.h:136
CCoinsViewDB & CoinsDB() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:583
static MempoolAcceptResult Success(std::list< CTransactionRef > &&replaced_txns, int64_t vsize, CAmount fees, CFeeRate effective_feerate, const std::vector< uint256 > &wtxids_fee_calculations)
Definition: validation.h:162
void ForceFlushStateToDisk()
Unconditionally flush all changes to disk.
CCoinsViewErrorCatcher & CoinsErrorCatcher() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:597
bool operator()()
An output of a transaction.
Definition: transaction.h:157
bool LoadChainTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Update the chain tip based on database information, i.e.
RecursiveMutex & GetMutex() const LOCK_RETURNED(
Alias for cs_main.
Definition: validation.h:934
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...
Parameters that influence chain consensus.
Definition: params.h:74
A base class defining functions for notifying about certain kernel events.
void TryAddBlockIndexCandidate(CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
bool CheckFinalTxAtTip(const CBlockIndex &active_chain_tip, const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(std::optional< LockPoints > CalculateLockPointsAtTip(CBlockIndex *tip, const CCoinsView &coins_view, const CTransaction &tx)
Check if transaction will be final in the next block to be created.
Definition: validation.h:291
MempoolAcceptResult AcceptToMemoryPool(Chainstate &active_chainstate, const CTransactionRef &tx, int64_t accept_time, bool bypass_limits, bool test_accept) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Try to add a transaction to the mempool.
DisconnectedBlockTransactions.
Chainstate &InitializeChainstate(CTxMemPool *mempool) EXCLUSIVE_LOCKS_REQUIRED(std::vector< Chainstate * GetAll)()
Instantiate a new chainstate.
Definition: validation.h:1012
Validation result for a single transaction mempool acceptance.
Definition: validation.h:119
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
MempoolAcceptResult(TxValidationState state)
Constructor for failure case.
Definition: validation.h:182
static MempoolAcceptResult MempoolTx(int64_t vsize, CAmount fees)
Definition: validation.h:171
#define Assume(val)
Assume is the identity function.
Definition: check.h:85
256-bit unsigned big integer.
void StopScriptCheckWorkerThreads()
Stop all of the script checking worker threads.
const std::optional< uint256 > m_other_wtxid
The wtxid of the transaction in the mempool which has the same txid but different witness...
Definition: validation.h:156
BIP 9 allows multiple softforks to be deployed in parallel.
Definition: versionbits.h:80
node::BlockMap & BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:1058
uint256 g_best_block
Used to notify getblocktemplate RPC of new tips.
Definition: validation.cpp:110
Closure representing one script verification Note that this stores references to the spending transac...
Definition: validation.h:312
Definition: init.h:25
const CBlockIndex *SnapshotBase() EXCLUSIVE_LOCKS_REQUIRED(std::set< CBlockIndex *, node::CBlockIndexWorkComparator > setBlockIndexCandidates
The base of the snapshot this chainstate was created from.
Definition: validation.h:564
PackageMempoolAcceptResult ProcessNewPackage(Chainstate &active_chainstate, CTxMemPool &pool, const Package &txns, bool test_accept) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Validate (and maybe submit) a package to the mempool.
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
std::condition_variable g_best_block_cv
Definition: validation.cpp:109
const CChainParams & GetParams() const
Definition: validation.h:909
arith_uint256 CalculateHeadersWork(const std::vector< CBlockHeader > &headers)
Return the sum of the work on a given set of headers.
PackageValidationState m_state
Definition: validation.h:214
256-bit opaque blob.
Definition: uint256.h:106
CoinsCacheSizeState
Definition: validation.h:446
const CTransaction * ptxTo
Definition: validation.h:316
const arith_uint256 & MinimumChainWork() const
Definition: validation.h:912
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
bool FatalError(kernel::Notifications &notifications, BlockValidationState &state, const std::string &strMessage, const bilingual_str &userMessage={})
kernel::Notifications & m_notifications
Definition: validation.h:381
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:301
MempoolAcceptResult(const uint256 &other_wtxid)
Constructor for witness-swapped case.
Definition: validation.h:205
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:48
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:144
const CChainParams & Params()
Return the currently selected parameters.
static const signed int DEFAULT_CHECKBLOCKS
Definition: validation.h:74
CCoinsView backed by the coin database (chainstate/)
Definition: txdb.h:53
void PruneBlockIndexCandidates()
Delete all entries in setBlockIndexCandidates that are worse than the current tip.
bool m_mempool cs
Definition: validation.h:677
void ResetBlockSequenceCounters() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:965
VerifyDBResult
Definition: validation.h:369
int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Definition: validation.h:1045
Application-specific storage settings.
Definition: dbwrapper.h:33
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
Definition: feerate.h:32
Holds configuration for use during UTXO snapshot load and validation.
Definition: chainparams.h:47
const CBlockIndex * GetBackgroundSyncTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
The tip of the background sync chain.
Definition: validation.h:1054
unsigned int nIn
Definition: validation.h:317
size_t m_coinstip_cache_size_bytes
The cache size of the in-memory coins view.
Definition: validation.h:613
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.
Mutex m_chainstate_mutex
The ChainState Mutex A lock that must be held when modifying this ChainState - held in ActivateBestCh...
Definition: validation.h:477
const std::optional< std::vector< uint256 > > m_wtxids_fee_calculations
Contains the wtxids of the transactions used for fee-related checks.
Definition: validation.h:152
static MempoolAcceptResult Failure(TxValidationState state)
Definition: validation.h:158
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:294
Different type to mark Mutex at global scope.
Definition: sync.h:141
void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
bool IsBIP30Unspendable(const CBlockIndex &block_index)
Identifies blocks which coinbase output was subsequently overwritten in the UTXO set (see BIP30) ...
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:228
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
Definition: validation.h:84
MempoolAcceptResult(int64_t vsize, CAmount fees)
Constructor for already-in-mempool case.
Definition: validation.h:201
void StartScriptCheckWorkerThreads(int threads_num)
Run instances of script checking worker threads.
This is a minimally invasive approach to shutdown on LevelDB read errors from the chainstate...
Definition: coins.h:375
bool PreciousBlock(BlockValidationState &state, CBlockIndex *pindex) LOCKS_EXCLUDED(bool InvalidateBlock(BlockValidationState &state, CBlockIndex *pindex) LOCKS_EXCLUDED(voi ResetBlockFailureFlags)(CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Mark a block as precious and reorganize.
Definition: validation.h:694
ScriptError GetScriptError() const
Definition: validation.h:334
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
Definition: cs_main.cpp:8
bool CheckSequenceLocksAtTip(CBlockIndex *tip, const LockPoints &lock_points)
Check if transaction will be BIP68 final in the next block to be created on top of tip...
Definition: validation.cpp:241
Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce value...
Definition: block.h:21
static MempoolAcceptResult MempoolTxDifferentWitness(const uint256 &other_wtxid)
Definition: validation.h:175
CTxMemPool * GetMempool()
Definition: validation.h:590
bool IsSnapshotValidated() const EXCLUSIVE_LOCKS_REQUIRED(
Is there a snapshot in use and has it been fully validated?
Definition: validation.h:1076
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
Definition: txmempool.h:391
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.
Definition: validation.h:69
#define Assert(val)
Identity function.
Definition: check.h:73
Used to track blocks whose transactions were applied to the UTXO state as a part of a single Activate...
Metadata describing a serialized version of a UTXO set from which an assumeutxo Chainstate can be con...
Definition: utxo_snapshot.h:24
bool IsBlockMutated(const CBlock &block, bool check_witness_root)
Check if a block has been mutated (with respect to its merkle root and witness commitments).
PrecomputedTransactionData * txdata
Definition: validation.h:321