Bitcoin Core  27.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 #include <arith_uint256.h>
10 #include <attributes.h>
11 #include <chain.h>
12 #include <checkqueue.h>
13 #include <kernel/chain.h>
14 #include <consensus/amount.h>
15 #include <deploymentstatus.h>
16 #include <kernel/chainparams.h>
18 #include <kernel/cs_main.h> // IWYU pragma: export
19 #include <node/blockstorage.h>
20 #include <policy/feerate.h>
21 #include <policy/packages.h>
22 #include <policy/policy.h>
23 #include <script/script_error.h>
24 #include <sync.h>
25 #include <txdb.h>
26 #include <txmempool.h> // For CTxMemPool::cs
27 #include <uint256.h>
28 #include <util/check.h>
29 #include <util/fs.h>
30 #include <util/hasher.h>
31 #include <util/result.h>
32 #include <util/translation.h>
33 #include <versionbits.h>
34 
35 #include <atomic>
36 #include <map>
37 #include <memory>
38 #include <optional>
39 #include <set>
40 #include <stdint.h>
41 #include <string>
42 #include <thread>
43 #include <type_traits>
44 #include <utility>
45 #include <vector>
46 
47 class Chainstate;
48 class CTxMemPool;
49 class ChainstateManager;
50 struct ChainTxData;
53 struct LockPoints;
54 struct AssumeutxoData;
55 namespace node {
56 class SnapshotMetadata;
57 } // namespace node
58 namespace Consensus {
59 struct Params;
60 } // namespace Consensus
61 namespace util {
62 class SignalInterrupt;
63 } // namespace util
64 
66 static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
67 static const signed int DEFAULT_CHECKBLOCKS = 6;
68 static constexpr int DEFAULT_CHECKLEVEL{3};
69 // Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev???.dat)
70 // At 1MB per block, 288 blocks = 288MB.
71 // Add 15% for Undo data = 331MB
72 // Add 20% for Orphan block rate = 397MB
73 // We want the low water mark after pruning to be at least 397 MB and since we prune in
74 // full block file chunks, we need the high water mark which triggers the prune to be
75 // one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB
76 // Setting the target to >= 550 MiB will make it likely we can respect the target.
77 static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;
78 
83  POST_INIT
84 };
85 
87 extern std::condition_variable g_best_block_cv;
89 extern uint256 g_best_block;
90 
92 extern const std::vector<std::string> CHECKLEVEL_DOC;
93 
94 CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
95 
96 bool FatalError(kernel::Notifications& notifications, BlockValidationState& state, const std::string& strMessage, const bilingual_str& userMessage = {});
97 
99 double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pindex);
100 
102 void PruneBlockFilesManual(Chainstate& active_chainstate, int nManualPruneHeight);
103 
129  enum class ResultType {
130  VALID,
131  INVALID,
132  MEMPOOL_ENTRY,
134  };
137 
140 
142  const std::optional<std::list<CTransactionRef>> m_replaced_transactions;
144  const std::optional<int64_t> m_vsize;
146  const std::optional<CAmount> m_base_fees;
152  const std::optional<CFeeRate> m_effective_feerate;
158  const std::optional<std::vector<Wtxid>> m_wtxids_fee_calculations;
159 
161  const std::optional<uint256> m_other_wtxid;
162 
164  return MempoolAcceptResult(state);
165  }
166 
168  CFeeRate effective_feerate,
169  const std::vector<Wtxid>& wtxids_fee_calculations) {
170  return MempoolAcceptResult(state, effective_feerate, wtxids_fee_calculations);
171  }
172 
173  static MempoolAcceptResult Success(std::list<CTransactionRef>&& replaced_txns,
174  int64_t vsize,
175  CAmount fees,
176  CFeeRate effective_feerate,
177  const std::vector<Wtxid>& wtxids_fee_calculations) {
178  return MempoolAcceptResult(std::move(replaced_txns), vsize, fees,
179  effective_feerate, wtxids_fee_calculations);
180  }
181 
182  static MempoolAcceptResult MempoolTx(int64_t vsize, CAmount fees) {
183  return MempoolAcceptResult(vsize, fees);
184  }
185 
187  return MempoolAcceptResult(other_wtxid);
188  }
189 
190 // Private constructors. Use static methods MempoolAcceptResult::Success, etc. to construct.
191 private:
194  : m_result_type(ResultType::INVALID), m_state(state) {
195  Assume(!state.IsValid()); // Can be invalid or error
196  }
197 
199  explicit MempoolAcceptResult(std::list<CTransactionRef>&& replaced_txns,
200  int64_t vsize,
201  CAmount fees,
202  CFeeRate effective_feerate,
203  const std::vector<Wtxid>& wtxids_fee_calculations)
204  : m_result_type(ResultType::VALID),
205  m_replaced_transactions(std::move(replaced_txns)),
206  m_vsize{vsize},
207  m_base_fees(fees),
208  m_effective_feerate(effective_feerate),
209  m_wtxids_fee_calculations(wtxids_fee_calculations) {}
210 
213  CFeeRate effective_feerate,
214  const std::vector<Wtxid>& wtxids_fee_calculations)
215  : m_result_type(ResultType::INVALID),
216  m_state(state),
217  m_effective_feerate(effective_feerate),
218  m_wtxids_fee_calculations(wtxids_fee_calculations) {}
219 
221  explicit MempoolAcceptResult(int64_t vsize, CAmount fees)
222  : m_result_type(ResultType::MEMPOOL_ENTRY), m_vsize{vsize}, m_base_fees(fees) {}
223 
225  explicit MempoolAcceptResult(const uint256& other_wtxid)
226  : m_result_type(ResultType::DIFFERENT_WITNESS), m_other_wtxid(other_wtxid) {}
227 };
228 
233 {
241  std::map<uint256, MempoolAcceptResult> m_tx_results;
242 
244  std::map<uint256, MempoolAcceptResult>&& results)
245  : m_state{state}, m_tx_results(std::move(results)) {}
246 
248  std::map<uint256, MempoolAcceptResult>&& results)
249  : m_state{state}, m_tx_results(std::move(results)) {}
250 
252  explicit PackageMempoolAcceptResult(const uint256& wtxid, const MempoolAcceptResult& result)
253  : m_tx_results{ {wtxid, result} } {}
254 };
255 
271  int64_t accept_time, bool bypass_limits, bool test_accept)
273 
283  const Package& txns, bool test_accept)
285 
286 /* Mempool validation helper functions */
287 
291 bool CheckFinalTxAtTip(const CBlockIndex& active_chain_tip, const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
292 
311 std::optional<LockPoints> CalculateLockPointsAtTip(
312  CBlockIndex* tip,
313  const CCoinsView& coins_view,
314  const CTransaction& tx);
315 
326  const LockPoints& lock_points);
327 
333 {
334 private:
337  unsigned int nIn;
338  unsigned int nFlags;
342 
343 public:
344  CScriptCheck(const CTxOut& outIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData* txdataIn) :
345  m_tx_out(outIn), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), txdata(txdataIn) { }
346 
347  CScriptCheck(const CScriptCheck&) = delete;
348  CScriptCheck& operator=(const CScriptCheck&) = delete;
349  CScriptCheck(CScriptCheck&&) = default;
350  CScriptCheck& operator=(CScriptCheck&&) = default;
351 
352  bool operator()();
353 
354  ScriptError GetScriptError() const { return error; }
355 };
356 
357 // CScriptCheck is used a lot in std::vector, make sure that's efficient
358 static_assert(std::is_nothrow_move_assignable_v<CScriptCheck>);
359 static_assert(std::is_nothrow_move_constructible_v<CScriptCheck>);
360 static_assert(std::is_nothrow_destructible_v<CScriptCheck>);
361 
363 [[nodiscard]] bool InitScriptExecutionCache(size_t max_size_bytes);
364 
368 bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
369 
372  const CChainParams& chainparams,
373  Chainstate& chainstate,
374  const CBlock& block,
375  CBlockIndex* pindexPrev,
376  bool fCheckPOW = true,
377  bool fCheckMerkleRoot = true) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
378 
380 bool HasValidProofOfWork(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams);
381 
383 bool IsBlockMutated(const CBlock& block, bool check_witness_root);
384 
386 arith_uint256 CalculateHeadersWork(const std::vector<CBlockHeader>& headers);
387 
388 enum class VerifyDBResult {
389  SUCCESS,
391  INTERRUPTED,
394 };
395 
398 {
399 private:
401 
402 public:
403  explicit CVerifyDB(kernel::Notifications& notifications);
404  ~CVerifyDB();
405  [[nodiscard]] VerifyDBResult VerifyDB(
406  Chainstate& chainstate,
407  const Consensus::Params& consensus_params,
408  CCoinsView& coinsview,
409  int nCheckLevel,
410  int nCheckDepth) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
411 };
412 
414 {
415  DISCONNECT_OK, // All good.
416  DISCONNECT_UNCLEAN, // Rolled back, but UTXO set was inconsistent with block.
417  DISCONNECT_FAILED // Something else went wrong.
418 };
419 
420 class ConnectTrace;
421 
423 enum class FlushStateMode {
424  NONE,
425  IF_NEEDED,
426  PERIODIC,
427  ALWAYS
428 };
429 
439 class CoinsViews {
440 
441 public:
444  CCoinsViewDB m_dbview GUARDED_BY(cs_main);
445 
448 
451  std::unique_ptr<CCoinsViewCache> m_cacheview GUARDED_BY(cs_main);
452 
459  CoinsViews(DBParams db_params, CoinsViewOptions options);
460 
462  void InitCache() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
463 };
464 
466 {
468  CRITICAL = 2,
470  LARGE = 1,
471  OK = 0
472 };
473 
489 {
490 protected:
497 
501 
503  std::unique_ptr<CoinsViews> m_coins_views;
504 
516  bool m_disabled GUARDED_BY(::cs_main) {false};
517 
519  const CBlockIndex* m_cached_snapshot_base GUARDED_BY(::cs_main) {nullptr};
520 
521 public:
525 
530 
531  explicit Chainstate(
532  CTxMemPool* mempool,
533  node::BlockManager& blockman,
534  ChainstateManager& chainman,
535  std::optional<uint256> from_snapshot_blockhash = std::nullopt);
536 
542 
549  void InitCoinsDB(
550  size_t cache_size_bytes,
551  bool in_memory,
552  bool should_wipe,
553  fs::path leveldb_name = "chainstate");
554 
557  void InitCoinsCache(size_t cache_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
558 
561  bool CanFlushToDisk() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
562  {
564  return m_coins_views && m_coins_views->m_cacheview;
565  }
566 
570 
576  const std::optional<uint256> m_from_snapshot_blockhash;
577 
583  const CBlockIndex* SnapshotBase() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
584 
591  std::set<CBlockIndex*, node::CBlockIndexWorkComparator> setBlockIndexCandidates;
592 
595  {
598  return *Assert(m_coins_views->m_cacheview);
599  }
600 
603  {
605  return Assert(m_coins_views)->m_dbview;
606  }
607 
610  {
611  return m_mempool;
612  }
613 
617  {
619  return Assert(m_coins_views)->m_catcherview;
620  }
621 
623  void ResetCoinsViews() { m_coins_views.reset(); }
624 
626  bool HasCoinsViews() const { return (bool)m_coins_views; }
627 
630 
633 
636  bool ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size)
638 
650  bool FlushStateToDisk(
651  BlockValidationState& state,
652  FlushStateMode mode,
653  int nManualPruneHeight = 0);
654 
656  void ForceFlushStateToDisk();
657 
660  void PruneAndFlush();
661 
683  bool ActivateBestChain(
684  BlockValidationState& state,
685  std::shared_ptr<const CBlock> pblock = nullptr)
688 
689  // Block (dis)connection on a given view:
690  DisconnectResult DisconnectBlock(const CBlock& block, const CBlockIndex* pindex, CCoinsViewCache& view)
692  bool ConnectBlock(const CBlock& block, BlockValidationState& state, CBlockIndex* pindex,
693  CCoinsViewCache& view, bool fJustCheck = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
694 
695  // Apply the effects of a block disconnection on the UTXO set.
697 
698  // Manual block validity manipulation:
703  bool PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
706 
708  bool InvalidateBlock(BlockValidationState& state, CBlockIndex* pindex)
711 
714 
716  bool ReplayBlocks();
717 
719  [[nodiscard]] bool NeedsRedownload() const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
721  bool LoadGenesisBlock();
722 
724 
726 
727  void ClearBlockIndexCandidates() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
728 
730  const CBlockIndex* FindForkInGlobalIndex(const CBlockLocator& locator) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
731 
734 
738  CoinsCacheSizeState GetCoinsCacheSizeState() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
739 
740  CoinsCacheSizeState GetCoinsCacheSizeState(
741  size_t max_coins_cache_size_bytes,
742  size_t max_mempool_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
743 
745 
747  RecursiveMutex* MempoolMutex() const LOCK_RETURNED(m_mempool->cs)
748  {
749  return m_mempool ? &m_mempool->cs : nullptr;
750  }
751 
752 private:
753  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);
754  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);
755 
758 
760 
763 
778  DisconnectedBlockTransactions& disconnectpool,
780 
782  void UpdateTip(const CBlockIndex* pindexNew)
784 
785  SteadyClock::time_point m_last_write{};
786  SteadyClock::time_point m_last_flush{};
787 
792  [[nodiscard]] util::Result<void> InvalidateCoinsDBOnDisk() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
793 
794  friend ChainstateManager;
795 };
796 
797 
799  SUCCESS,
800  SKIPPED,
801 
802  // Expected assumeutxo configuration data is not found for the height of the
803  // base block.
805 
806  // Failed to generate UTXO statistics (to check UTXO set hash) for the background
807  // chainstate.
808  STATS_FAILED,
809 
810  // The UTXO set hash of the background validation chainstate does not match
811  // the one expected by assumeutxo chainparams.
813 
814  // The blockhash of the current tip of the background validation chainstate does
815  // not match the one expected by the snapshot chainstate.
817 };
818 
847 {
848 private:
865  std::unique_ptr<Chainstate> m_ibd_chainstate GUARDED_BY(::cs_main);
866 
877  std::unique_ptr<Chainstate> m_snapshot_chainstate GUARDED_BY(::cs_main);
878 
881  Chainstate* m_active_chainstate GUARDED_BY(::cs_main) {nullptr};
882 
883  CBlockIndex* m_best_invalid GUARDED_BY(::cs_main){nullptr};
884 
886  [[nodiscard]] bool PopulateAndValidateSnapshot(
887  Chainstate& snapshot_chainstate,
888  AutoFile& coins_file,
889  const node::SnapshotMetadata& metadata);
890 
898  bool AcceptBlockHeader(
899  const CBlockHeader& block,
900  BlockValidationState& state,
901  CBlockIndex** ppindex,
902  bool min_pow_checked) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
903  friend Chainstate;
904 
906  std::chrono::time_point<std::chrono::steady_clock> m_last_presync_update GUARDED_BY(::cs_main) {};
907 
908  std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> m_warningcache GUARDED_BY(::cs_main);
909 
915  bool IsUsable(const Chainstate* const cs) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
916  return cs && !cs->m_disabled;
917  }
918 
921 
922 public:
924 
925  explicit ChainstateManager(const util::SignalInterrupt& interrupt, Options options, node::BlockManager::Options blockman_options);
926 
929  std::function<void()> restart_indexes = std::function<void()>();
930 
931  const CChainParams& GetParams() const { return m_options.chainparams; }
932  const Consensus::Params& GetConsensus() const { return m_options.chainparams.GetConsensus(); }
933  bool ShouldCheckBlockIndex() const { return *Assert(m_options.check_block_index); }
934  const arith_uint256& MinimumChainWork() const { return *Assert(m_options.minimum_chain_work); }
935  const uint256& AssumedValidBlock() const { return *Assert(m_options.assumed_valid_block); }
936  kernel::Notifications& GetNotifications() const { return m_options.notifications; };
937 
943  void CheckBlockIndex();
944 
957 
960  std::thread m_thread_load;
964 
972  mutable std::atomic<bool> m_cached_finished_ibd{false};
973 
979  int32_t nBlockSequenceId GUARDED_BY(::cs_main) = 1;
981  int32_t nBlockReverseSequenceId = -1;
983  arith_uint256 nLastPreciousChainwork = 0;
984 
985  // Reset the memory-only sequence counters we use to track block arrival
986  // (used by tests to reset state)
988  {
990  nBlockSequenceId = 1;
991  nBlockReverseSequenceId = -1;
992  }
993 
994 
1014  std::set<CBlockIndex*> m_failed_blocks;
1015 
1017  CBlockIndex* m_best_header GUARDED_BY(::cs_main){nullptr};
1018 
1021  int64_t m_total_coinstip_cache{0};
1022  //
1025  int64_t m_total_coinsdb_cache{0};
1026 
1030  // constructor
1031  Chainstate& InitializeChainstate(CTxMemPool* mempool) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1032 
1034  std::vector<Chainstate*> GetAll();
1035 
1049  [[nodiscard]] bool ActivateSnapshot(
1050  AutoFile& coins_file, const node::SnapshotMetadata& metadata, bool in_memory);
1051 
1059  SnapshotCompletionResult MaybeCompleteSnapshotValidation() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1060 
1062  const CBlockIndex* GetSnapshotBaseBlock() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1063 
1065  Chainstate& ActiveChainstate() const;
1066  CChain& ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChainstate().m_chain; }
1067  int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChain().Height(); }
1068  CBlockIndex* ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChain().Tip(); }
1069 
1072  return IsUsable(m_snapshot_chainstate.get()) && IsUsable(m_ibd_chainstate.get());
1073  }
1074 
1077  return BackgroundSyncInProgress() ? m_ibd_chainstate->m_chain.Tip() : nullptr;
1078  }
1079 
1081  {
1083  return m_blockman.m_block_index;
1084  }
1085 
1090 
1093  bool IsSnapshotActive() const;
1094 
1095  std::optional<uint256> SnapshotBlockhash() const;
1096 
1099  {
1100  return m_snapshot_chainstate && m_ibd_chainstate && m_ibd_chainstate->m_disabled;
1101  }
1102 
1104  bool IsInitialBlockDownload() const;
1105 
1132  void LoadExternalBlockFile(
1133  AutoFile& file_in,
1134  FlatFilePos* dbp = nullptr,
1135  std::multimap<uint256, FlatFilePos>* blocks_with_unknown_parent = nullptr);
1136 
1161  bool ProcessNewBlock(const std::shared_ptr<const CBlock>& block, bool force_processing, bool min_pow_checked, bool* new_block) LOCKS_EXCLUDED(cs_main);
1162 
1174  bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& block, bool min_pow_checked, BlockValidationState& state, const CBlockIndex** ppindex = nullptr) LOCKS_EXCLUDED(cs_main);
1175 
1195  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);
1196 
1197  void ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pindexNew, const FlatFilePos& pos) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
1198 
1205  [[nodiscard]] MempoolAcceptResult ProcessTransaction(const CTransactionRef& tx, bool test_accept=false)
1207 
1209  bool LoadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
1210 
1213  void MaybeRebalanceCaches() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1214 
1216  void UpdateUncommittedBlockStructures(CBlock& block, const CBlockIndex* pindexPrev) const;
1217 
1219  std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBlockIndex* pindexPrev) const;
1220 
1225  void ReportHeadersPresync(const arith_uint256& work, int64_t height, int64_t timestamp);
1226 
1229  bool DetectSnapshotChainstate() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1230 
1231  void ResetChainstates() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1232 
1235  [[nodiscard]] bool DeleteSnapshotChainstate() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1236 
1239  Chainstate& ActivateExistingSnapshot(uint256 base_blockhash) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1240 
1250  bool ValidatedSnapshotCleanup() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1251 
1260  Chainstate& GetChainstateForIndexing() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1261 
1265  std::pair<int, int> GetPruneRange(
1266  const Chainstate& chainstate, int last_height_can_prune) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1267 
1270  std::optional<int> GetSnapshotBaseHeight() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1271 
1272  CCheckQueue<CScriptCheck>& GetCheckQueue() { return m_script_check_queue; }
1273 
1274  ~ChainstateManager();
1275 };
1276 
1278 template<typename DEP>
1279 bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const ChainstateManager& chainman, DEP dep)
1280 {
1281  return DeploymentActiveAfter(pindexPrev, chainman.GetConsensus(), dep, chainman.m_versionbitscache);
1282 }
1283 
1284 template<typename DEP>
1285 bool DeploymentActiveAt(const CBlockIndex& index, const ChainstateManager& chainman, DEP dep)
1286 {
1287  return DeploymentActiveAt(index, chainman.GetConsensus(), dep, chainman.m_versionbitscache);
1288 }
1289 
1290 template<typename DEP>
1291 bool DeploymentEnabled(const ChainstateManager& chainman, DEP dep)
1292 {
1293  return DeploymentEnabled(chainman.GetConsensus(), dep);
1294 }
1295 
1297 bool IsBIP30Repeat(const CBlockIndex& block_index);
1298 
1300 bool IsBIP30Unspendable(const CBlockIndex& block_index);
1301 
1302 #endif // BITCOIN_VALIDATION_H
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:423
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:594
std::thread m_thread_load
Definition: validation.h:960
const std::optional< CFeeRate > m_effective_feerate
The feerate at which this transaction was considered.
Definition: validation.h:152
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
Definition: validation.h:963
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:576
const uint256 & AssumedValidBlock() const
Definition: validation.h:935
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:500
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:1279
bool DeploymentActiveAt(const CBlockIndex &index, const ChainstateManager &chainman, DEP dep)
Definition: validation.h:1285
AssertLockHeld(pool.cs)
SteadyClock::time_point m_last_flush
Definition: validation.h:786
const Options m_options
Definition: validation.h:959
static MempoolAcceptResult FeeFailure(TxValidationState state, CFeeRate effective_feerate, const std::vector< Wtxid > &wtxids_fee_calculations)
Definition: validation.h:167
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:80
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
const std::optional< std::vector< Wtxid > > m_wtxids_fee_calculations
Contains the wtxids of the transactions used for fee-related checks.
Definition: validation.h:158
CBlockIndex *m_best_invalid GUARDED_BY(::cs_main)
Definition: validation.h:883
GlobalMutex g_best_block_mutex
Definition: validation.cpp:112
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:519
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:439
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:846
An in-memory indexed chain of blocks.
Definition: chain.h:446
bool ShouldCheckBlockIndex() const
Definition: validation.h:933
const std::optional< std::list< CTransactionRef > > m_replaced_transactions
Mempool transactions replaced by the tx.
Definition: validation.h:142
unsigned int nFlags
Definition: validation.h:338
PackageMempoolAcceptResult(PackageValidationState state, std::map< uint256, MempoolAcceptResult > &&results)
Definition: validation.h:243
size_t m_coinsdb_cache_size_bytes
The cache size of the on-disk coins view.
Definition: validation.h:629
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:50
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:66
DisconnectResult
Definition: validation.h:413
std::unique_ptr< CoinsViews > m_coins_views
Manages the UTXO set, which is a reflection of the contents of m_chain.
Definition: validation.h:503
unsigned int nHeight
static constexpr int DEFAULT_CHECKLEVEL
Definition: validation.h:68
ResultType
Used to indicate the results of mempool validation.
Definition: validation.h:129
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:906
bool CheckFinalTxAtTip(const CBlockIndex &active_chain_tip, const CTransaction &tx)
Definition: validation.cpp:142
Chainstate *m_active_chainstate GUARDED_BY(::cs_main)
Points to either the ibd or snapshot chainstate; indicates our most-work chain.
Definition: validation.h:881
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:252
const std::optional< int64_t > m_vsize
Virtual size as used by the mempool, calculated using serialized size and sigops. ...
Definition: validation.h:144
const TxValidationState m_state
Contains information about why the transaction failed.
Definition: validation.h:139
std::map< uint256, MempoolAcceptResult > m_tx_results
Map from wtxid to finished MempoolAcceptResults.
Definition: validation.h:241
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:1014
const std::optional< CAmount > m_base_fees
Raw base fees in satoshis.
Definition: validation.h:146
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:340
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:296
const ResultType m_result_type
Result type.
Definition: validation.h:136
void InvalidBlockFound(CBlockIndex *pindex, const BlockValidationState &state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
bool DeploymentEnabled(const ChainstateManager &chainman, DEP dep)
Definition: validation.h:1291
const std::vector< std::string > CHECKLEVEL_DOC
Documentation for argument &#39;checklevel&#39;.
Definition: validation.cpp:97
CChain m_chain
The current chain of blockheaders we consult and build on.
Definition: validation.h:569
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:339
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:388
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:1017
bool HasCoinsViews() const
Does this chainstate have a UTXO set attached?
Definition: validation.h:626
CTxOut m_tx_out
Definition: validation.h:335
Filesystem operations and types.
void ResetCoinsViews()
Destructs all objects related to accessing the UTXO set.
Definition: validation.h:623
PackageMempoolAcceptResult(PackageValidationState state, CFeeRate feerate, std::map< uint256, MempoolAcceptResult > &&results)
Definition: validation.h:247
Called by RandAddPeriodic()
const util::SignalInterrupt & m_interrupt
Definition: validation.h:958
CScriptCheck(const CTxOut &outIn, const CTransaction &txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData *txdataIn)
Definition: validation.h:344
CVerifyDB(kernel::Notifications &notifications)
Transaction validation functions.
VersionBitsCache m_versionbitscache
Track versionbit status.
Definition: validation.h:1089
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:915
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:785
bool IsValid() const
Definition: validation.h:122
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:529
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:792
bool BackgroundSyncInProgress() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
The state of a background sync (for net processing)
Definition: validation.h:1071
Chainstate stores and provides an API to update our local knowledge of the current best chain...
Definition: validation.h:488
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:232
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:692
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:516
SnapshotCompletionResult
Definition: validation.h:798
FlushStateMode
Definition: validation.h:423
Chainstate(CTxMemPool *mempool, node::BlockManager &blockman, ChainstateManager &chainman, std::optional< uint256 > from_snapshot_blockhash=std::nullopt)
kernel::Notifications & GetNotifications() const
Definition: validation.h:936
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
Definition: validation.h:397
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:932
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:1068
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:602
void ForceFlushStateToDisk()
Unconditionally flush all changes to disk.
CCoinsViewErrorCatcher & CoinsErrorCatcher() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:616
bool operator()()
An output of a transaction.
Definition: transaction.h:149
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:956
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:311
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:1034
Validation result for a transaction evaluated by MemPoolAccept (single or package).
Definition: validation.h:127
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
MempoolAcceptResult(TxValidationState state)
Constructor for failure case.
Definition: validation.h:193
static MempoolAcceptResult MempoolTx(int64_t vsize, CAmount fees)
Definition: validation.h:182
#define Assume(val)
Assume is the identity function.
Definition: check.h:89
256-bit unsigned big integer.
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:161
BIP 9 allows multiple softforks to be deployed in parallel.
Definition: versionbits.h:80
node::BlockMap & BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:1080
uint256 g_best_block
Used to notify getblocktemplate RPC of new tips.
Definition: validation.cpp:114
Closure representing one script verification Note that this stores references to the spending transac...
Definition: validation.h:332
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:583
MempoolAcceptResult(TxValidationState state, CFeeRate effective_feerate, const std::vector< Wtxid > &wtxids_fee_calculations)
Constructor for fee-related failure case.
Definition: validation.h:212
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:113
const CChainParams & GetParams() const
Definition: validation.h:931
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:234
256-bit opaque blob.
Definition: uint256.h:106
CoinsCacheSizeState
Definition: validation.h:465
const CTransaction * ptxTo
Definition: validation.h:336
const arith_uint256 & MinimumChainWork() const
Definition: validation.h:934
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
bool FatalError(kernel::Notifications &notifications, BlockValidationState &state, const std::string &strMessage, const bilingual_str &userMessage={})
bool TestBlockValidity(BlockValidationState &state, const CChainParams &chainparams, Chainstate &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) ...
kernel::Notifications & m_notifications
Definition: validation.h:400
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:299
MempoolAcceptResult(const uint256 &other_wtxid)
Constructor for witness-swapped case.
Definition: validation.h:225
#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:149
const CChainParams & Params()
Return the currently selected parameters.
static const signed int DEFAULT_CHECKBLOCKS
Definition: validation.h:67
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.
CCheckQueue< CScriptCheck > m_script_check_queue
A queue for script verifications that have to be performed by worker threads.
Definition: validation.h:920
bool m_mempool cs
Definition: validation.h:696
void ResetBlockSequenceCounters() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:987
VerifyDBResult
Definition: validation.h:388
int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Definition: validation.h:1067
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:1076
unsigned int nIn
Definition: validation.h:337
size_t m_coinstip_cache_size_bytes
The cache size of the in-memory coins view.
Definition: validation.h:632
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.
MempoolAcceptResult(std::list< CTransactionRef > &&replaced_txns, int64_t vsize, CAmount fees, CFeeRate effective_feerate, const std::vector< Wtxid > &wtxids_fee_calculations)
Constructor for success case.
Definition: validation.h:199
Mutex m_chainstate_mutex
The ChainState Mutex A lock that must be held when modifying this ChainState - held in ActivateBestCh...
Definition: validation.h:496
static MempoolAcceptResult Failure(TxValidationState state)
Definition: validation.h:163
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:295
Different type to mark Mutex at global scope.
Definition: sync.h:140
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:77
MempoolAcceptResult(int64_t vsize, CAmount fees)
Constructor for already-in-mempool case.
Definition: validation.h:221
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:713
ScriptError GetScriptError() const
Definition: validation.h:354
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:245
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:186
CTxMemPool * GetMempool()
Definition: validation.h:609
bool IsSnapshotValidated() const EXCLUSIVE_LOCKS_REQUIRED(
Is there a snapshot in use and has it been fully validated?
Definition: validation.h:1098
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
Definition: txmempool.h:388
#define Assert(val)
Identity function.
Definition: check.h:77
static MempoolAcceptResult Success(std::list< CTransactionRef > &&replaced_txns, int64_t vsize, CAmount fees, CFeeRate effective_feerate, const std::vector< Wtxid > &wtxids_fee_calculations)
Definition: validation.h:173
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:341