Bitcoin Core 29.99.0
P2P Digital Currency
validation.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-present 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 <consensus/amount.h>
14#include <cuckoocache.h>
15#include <deploymentstatus.h>
16#include <kernel/chain.h>
17#include <kernel/chainparams.h>
19#include <kernel/cs_main.h> // IWYU pragma: export
20#include <node/blockstorage.h>
21#include <policy/feerate.h>
22#include <policy/packages.h>
23#include <policy/policy.h>
24#include <script/script_error.h>
25#include <script/sigcache.h>
26#include <sync.h>
27#include <txdb.h>
28#include <txmempool.h>
29#include <uint256.h>
30#include <util/check.h>
31#include <util/fs.h>
32#include <util/hasher.h>
33#include <util/result.h>
34#include <util/time.h>
35#include <util/translation.h>
36#include <versionbits.h>
37
38#include <atomic>
39#include <cstdint>
40#include <map>
41#include <memory>
42#include <optional>
43#include <set>
44#include <span>
45#include <string>
46#include <type_traits>
47#include <utility>
48#include <vector>
49
50class Chainstate;
51class CTxMemPool;
53struct ChainTxData;
56struct LockPoints;
57struct AssumeutxoData;
58namespace node {
59class SnapshotMetadata;
60} // namespace node
61namespace Consensus {
62struct Params;
63} // namespace Consensus
64namespace util {
65class SignalInterrupt;
66} // namespace util
67
69static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
70static const signed int DEFAULT_CHECKBLOCKS = 6;
71static constexpr int DEFAULT_CHECKLEVEL{3};
72// Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev???.dat)
73// At 1MB per block, 288 blocks = 288MB.
74// Add 15% for Undo data = 331MB
75// Add 20% for Orphan block rate = 397MB
76// We want the low water mark after pruning to be at least 397 MB and since we prune in
77// full block file chunks, we need the high water mark which triggers the prune to be
78// one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB
79// Setting the target to >= 550 MiB will make it likely we can respect the target.
80static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;
81
83static constexpr int MAX_SCRIPTCHECK_THREADS{15};
84
90};
91
93extern const std::vector<std::string> CHECKLEVEL_DOC;
94
95CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
96
97bool FatalError(kernel::Notifications& notifications, BlockValidationState& state, const bilingual_str& message);
98
100void PruneBlockFilesManual(Chainstate& active_chainstate, int nManualPruneHeight);
101
126 enum class ResultType {
127 VALID,
128 INVALID,
129 MEMPOOL_ENTRY,
130 DIFFERENT_WITNESS,
131 };
134
137
139 const std::list<CTransactionRef> m_replaced_transactions;
141 const std::optional<int64_t> m_vsize;
143 const std::optional<CAmount> m_base_fees;
149 const std::optional<CFeeRate> m_effective_feerate;
155 const std::optional<std::vector<Wtxid>> m_wtxids_fee_calculations;
156
158 const std::optional<Wtxid> m_other_wtxid;
159
161 return MempoolAcceptResult(state);
162 }
163
165 CFeeRate effective_feerate,
166 const std::vector<Wtxid>& wtxids_fee_calculations) {
167 return MempoolAcceptResult(state, effective_feerate, wtxids_fee_calculations);
168 }
169
170 static MempoolAcceptResult Success(std::list<CTransactionRef>&& replaced_txns,
171 int64_t vsize,
172 CAmount fees,
173 CFeeRate effective_feerate,
174 const std::vector<Wtxid>& wtxids_fee_calculations) {
175 return MempoolAcceptResult(std::move(replaced_txns), vsize, fees,
176 effective_feerate, wtxids_fee_calculations);
177 }
178
179 static MempoolAcceptResult MempoolTx(int64_t vsize, CAmount fees) {
180 return MempoolAcceptResult(vsize, fees);
181 }
182
184 return MempoolAcceptResult(other_wtxid);
185 }
186
187// Private constructors. Use static methods MempoolAcceptResult::Success, etc. to construct.
188private:
191 : m_result_type(ResultType::INVALID), m_state(state) {
192 Assume(!state.IsValid()); // Can be invalid or error
193 }
194
196 explicit MempoolAcceptResult(std::list<CTransactionRef>&& replaced_txns,
197 int64_t vsize,
198 CAmount fees,
199 CFeeRate effective_feerate,
200 const std::vector<Wtxid>& wtxids_fee_calculations)
201 : m_result_type(ResultType::VALID),
202 m_replaced_transactions(std::move(replaced_txns)),
203 m_vsize{vsize},
204 m_base_fees(fees),
205 m_effective_feerate(effective_feerate),
206 m_wtxids_fee_calculations(wtxids_fee_calculations) {}
207
210 CFeeRate effective_feerate,
211 const std::vector<Wtxid>& wtxids_fee_calculations)
212 : m_result_type(ResultType::INVALID),
213 m_state(state),
214 m_effective_feerate(effective_feerate),
215 m_wtxids_fee_calculations(wtxids_fee_calculations) {}
216
218 explicit MempoolAcceptResult(int64_t vsize, CAmount fees)
219 : m_result_type(ResultType::MEMPOOL_ENTRY), m_vsize{vsize}, m_base_fees(fees) {}
220
222 explicit MempoolAcceptResult(const Wtxid& other_wtxid)
223 : m_result_type(ResultType::DIFFERENT_WITNESS), m_other_wtxid(other_wtxid) {}
224};
225
230{
238 std::map<Wtxid, MempoolAcceptResult> m_tx_results;
239
241 std::map<Wtxid, MempoolAcceptResult>&& results)
242 : m_state{state}, m_tx_results(std::move(results)) {}
243
245 std::map<Wtxid, MempoolAcceptResult>&& results)
246 : m_state{state}, m_tx_results(std::move(results)) {}
247
249 explicit PackageMempoolAcceptResult(const Wtxid& wtxid, const MempoolAcceptResult& result)
250 : m_tx_results{ {wtxid, result} } {}
251};
252
268 int64_t accept_time, bool bypass_limits, bool test_accept)
270
282 const Package& txns, bool test_accept, const std::optional<CFeeRate>& client_maxfeerate)
284
285/* Mempool validation helper functions */
286
290bool CheckFinalTxAtTip(const CBlockIndex& active_chain_tip, const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
291
310std::optional<LockPoints> CalculateLockPointsAtTip(
311 CBlockIndex* tip,
312 const CCoinsView& coins_view,
313 const CTransaction& tx);
314
325 const LockPoints& lock_points);
326
332{
333private:
336 unsigned int nIn;
337 unsigned int nFlags;
341
342public:
343 CScriptCheck(const CTxOut& outIn, const CTransaction& txToIn, SignatureCache& signature_cache, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData* txdataIn) :
344 m_tx_out(outIn), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), txdata(txdataIn), m_signature_cache(&signature_cache) { }
345
346 CScriptCheck(const CScriptCheck&) = delete;
350
351 std::optional<std::pair<ScriptError, std::string>> operator()();
352};
353
354// CScriptCheck is used a lot in std::vector, make sure that's efficient
355static_assert(std::is_nothrow_move_assignable_v<CScriptCheck>);
356static_assert(std::is_nothrow_move_constructible_v<CScriptCheck>);
357static_assert(std::is_nothrow_destructible_v<CScriptCheck>);
358
364{
365private:
368
369public:
372
373 ValidationCache(size_t script_execution_cache_bytes, size_t signature_cache_bytes);
374
377
380};
381
385bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
386
405 Chainstate& chainstate,
406 const CBlock& block,
407 bool check_pow,
408 bool check_merkle_root) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
409
411bool HasValidProofOfWork(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams);
412
414bool IsBlockMutated(const CBlock& block, bool check_witness_root);
415
417arith_uint256 CalculateClaimedHeadersWork(std::span<const CBlockHeader> headers);
418
419enum class VerifyDBResult {
420 SUCCESS,
422 INTERRUPTED,
425};
426
429{
430private:
432
433public:
434 explicit CVerifyDB(kernel::Notifications& notifications);
435 ~CVerifyDB();
436 [[nodiscard]] VerifyDBResult VerifyDB(
437 Chainstate& chainstate,
438 const Consensus::Params& consensus_params,
439 CCoinsView& coinsview,
440 int nCheckLevel,
441 int nCheckDepth) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
442};
443
445{
446 DISCONNECT_OK, // All good.
447 DISCONNECT_UNCLEAN, // Rolled back, but UTXO set was inconsistent with block.
448 DISCONNECT_FAILED // Something else went wrong.
450
451class ConnectTrace;
452
454inline constexpr std::array FlushStateModeNames{"NONE", "IF_NEEDED", "PERIODIC", "ALWAYS"};
455enum class FlushStateMode: uint8_t {
456 NONE,
457 IF_NEEDED,
458 PERIODIC,
459 ALWAYS
460};
461
472
473public:
477
480
483 std::unique_ptr<CCoinsViewCache> m_cacheview GUARDED_BY(cs_main);
484
491 CoinsViews(DBParams db_params, CoinsViewOptions options);
492
494 void InitCache() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
495};
496
498{
500 CRITICAL = 2,
502 LARGE = 1,
503 OK = 0
504};
505
521{
522protected:
529
533
535 std::unique_ptr<CoinsViews> m_coins_views;
536
548 bool m_disabled GUARDED_BY(::cs_main) {false};
549
551 mutable const CBlockIndex* m_cached_snapshot_base GUARDED_BY(::cs_main){nullptr};
552
553public:
557
562
563 explicit Chainstate(
564 CTxMemPool* mempool,
565 node::BlockManager& blockman,
566 ChainstateManager& chainman,
567 std::optional<uint256> from_snapshot_blockhash = std::nullopt);
568
574
581 void InitCoinsDB(
582 size_t cache_size_bytes,
583 bool in_memory,
584 bool should_wipe,
585 fs::path leveldb_name = "chainstate");
586
589 void InitCoinsCache(size_t cache_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
590
593 bool CanFlushToDisk() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
594 {
596 return m_coins_views && m_coins_views->m_cacheview;
597 }
598
602
608 const std::optional<uint256> m_from_snapshot_blockhash;
609
615 const CBlockIndex* SnapshotBase() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
616
624 std::set<CBlockIndex*, node::CBlockIndexWorkComparator> setBlockIndexCandidates;
625
628 {
630 Assert(m_coins_views);
631 return *Assert(m_coins_views->m_cacheview);
632 }
633
636 {
638 return Assert(m_coins_views)->m_dbview;
639 }
640
643 {
644 return m_mempool;
645 }
646
650 {
652 return Assert(m_coins_views)->m_catcherview;
653 }
654
656 void ResetCoinsViews() { m_coins_views.reset(); }
657
659 bool HasCoinsViews() const { return (bool)m_coins_views; }
660
662 size_t m_coinsdb_cache_size_bytes{0};
663
665 size_t m_coinstip_cache_size_bytes{0};
666
669 bool ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size)
671
683 bool FlushStateToDisk(
685 FlushStateMode mode,
686 int nManualPruneHeight = 0);
687
689 void ForceFlushStateToDisk();
690
693 void PruneAndFlush();
694
716 bool ActivateBestChain(
718 std::shared_ptr<const CBlock> pblock = nullptr)
719 EXCLUSIVE_LOCKS_REQUIRED(!m_chainstate_mutex)
721
722 // Block (dis)connection on a given view:
723 DisconnectResult DisconnectBlock(const CBlock& block, const CBlockIndex* pindex, CCoinsViewCache& view)
725 bool ConnectBlock(const CBlock& block, BlockValidationState& state, CBlockIndex* pindex,
726 CCoinsViewCache& view, bool fJustCheck = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
727
728 // Apply the effects of a block disconnection on the UTXO set.
729 bool DisconnectTip(BlockValidationState& state, DisconnectedBlockTransactions* disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs);
730
731 // Manual block validity manipulation:
736 bool PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
737 EXCLUSIVE_LOCKS_REQUIRED(!m_chainstate_mutex)
739
742 EXCLUSIVE_LOCKS_REQUIRED(!m_chainstate_mutex)
744
746 void SetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
747
749 void ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
750
752 bool ReplayBlocks();
753
755 [[nodiscard]] bool NeedsRedownload() const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
757 bool LoadGenesisBlock();
758
759 void TryAddBlockIndexCandidate(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
760
761 void PruneBlockIndexCandidates();
762
763 void ClearBlockIndexCandidates() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
764
766 const CBlockIndex* FindForkInGlobalIndex(const CBlockLocator& locator) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
767
769 bool LoadChainTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
770
774 CoinsCacheSizeState GetCoinsCacheSizeState() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
775
776 CoinsCacheSizeState GetCoinsCacheSizeState(
777 size_t max_coins_cache_size_bytes,
778 size_t max_mempool_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
779
781
783 RecursiveMutex* MempoolMutex() const LOCK_RETURNED(m_mempool->cs)
784 {
785 return m_mempool ? &m_mempool->cs : nullptr;
786 }
787
788private:
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
792 void InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
793 CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
794
795 bool RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& inputs) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
796
797 void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
798 void InvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
799
813 void MaybeUpdateMempoolForReorg(
814 DisconnectedBlockTransactions& disconnectpool,
815 bool fAddToMempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs);
816
818 void UpdateTip(const CBlockIndex* pindexNew)
820
821 NodeClock::time_point m_next_write{NodeClock::time_point::max()};
822
827 [[nodiscard]] util::Result<void> InvalidateCoinsDBOnDisk() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
828
830};
831
833 SUCCESS,
834 SKIPPED,
835
836 // Expected assumeutxo configuration data is not found for the height of the
837 // base block.
839
840 // Failed to generate UTXO statistics (to check UTXO set hash) for the background
841 // chainstate.
843
844 // The UTXO set hash of the background validation chainstate does not match
845 // the one expected by assumeutxo chainparams.
847
848 // The blockhash of the current tip of the background validation chainstate does
849 // not match the one expected by the snapshot chainstate.
851};
852
881{
882private:
899 std::unique_ptr<Chainstate> m_ibd_chainstate GUARDED_BY(::cs_main);
900
911 std::unique_ptr<Chainstate> m_snapshot_chainstate GUARDED_BY(::cs_main);
912
915 Chainstate* m_active_chainstate GUARDED_BY(::cs_main) {nullptr};
916
917 CBlockIndex* m_best_invalid GUARDED_BY(::cs_main){nullptr};
918
920 CBlockIndex* m_last_notified_header GUARDED_BY(GetMutex()){nullptr};
921
922 bool NotifyHeaderTip() LOCKS_EXCLUDED(GetMutex());
923
931 [[nodiscard]] util::Result<void> PopulateAndValidateSnapshot(
932 Chainstate& snapshot_chainstate,
933 AutoFile& coins_file,
934 const node::SnapshotMetadata& metadata);
935
943 bool AcceptBlockHeader(
944 const CBlockHeader& block,
946 CBlockIndex** ppindex,
947 bool min_pow_checked) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
949
951 MockableSteadyClock::time_point m_last_presync_update GUARDED_BY(GetMutex()){};
952
959 return cs && !cs->m_disabled;
960 }
961
964
967 SteadyClock::duration GUARDED_BY(::cs_main) time_check{};
968 SteadyClock::duration GUARDED_BY(::cs_main) time_forks{};
969 SteadyClock::duration GUARDED_BY(::cs_main) time_connect{};
970 SteadyClock::duration GUARDED_BY(::cs_main) time_verify{};
971 SteadyClock::duration GUARDED_BY(::cs_main) time_undo{};
972 SteadyClock::duration GUARDED_BY(::cs_main) time_index{};
973 SteadyClock::duration GUARDED_BY(::cs_main) time_total{};
974 int64_t GUARDED_BY(::cs_main) num_blocks_total{0};
975 SteadyClock::duration GUARDED_BY(::cs_main) time_connect_total{};
976 SteadyClock::duration GUARDED_BY(::cs_main) time_flush{};
977 SteadyClock::duration GUARDED_BY(::cs_main) time_chainstate{};
978 SteadyClock::duration GUARDED_BY(::cs_main) time_post_connect{};
979
980public:
982
983 explicit ChainstateManager(const util::SignalInterrupt& interrupt, Options options, node::BlockManager::Options blockman_options);
984
987 std::function<void()> snapshot_download_completed = std::function<void()>();
988
989 const CChainParams& GetParams() const { return m_options.chainparams; }
990 const Consensus::Params& GetConsensus() const { return m_options.chainparams.GetConsensus(); }
991 bool ShouldCheckBlockIndex() const;
992 const arith_uint256& MinimumChainWork() const { return *Assert(m_options.minimum_chain_work); }
993 const uint256& AssumedValidBlock() const { return *Assert(m_options.assumed_valid_block); }
994 kernel::Notifications& GetNotifications() const { return m_options.notifications; };
995
1001 void CheckBlockIndex() const;
1002
1015
1021
1023
1031 mutable std::atomic<bool> m_cached_finished_ibd{false};
1032
1038 int32_t nBlockSequenceId GUARDED_BY(::cs_main) = 1;
1040 int32_t nBlockReverseSequenceId = -1;
1042 arith_uint256 nLastPreciousChainwork = 0;
1043
1044 // Reset the memory-only sequence counters we use to track block arrival
1045 // (used by tests to reset state)
1047 {
1049 nBlockSequenceId = 1;
1050 nBlockReverseSequenceId = -1;
1051 }
1052
1053
1058 CBlockIndex* m_best_header GUARDED_BY(::cs_main){nullptr};
1059
1062 size_t m_total_coinstip_cache{0};
1063 //
1066 size_t m_total_coinsdb_cache{0};
1067
1071 // constructor
1072 Chainstate& InitializeChainstate(CTxMemPool* mempool) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1073
1075 std::vector<Chainstate*> GetAll();
1076
1089 [[nodiscard]] util::Result<CBlockIndex*> ActivateSnapshot(
1090 AutoFile& coins_file, const node::SnapshotMetadata& metadata, bool in_memory);
1091
1099 SnapshotCompletionResult MaybeCompleteSnapshotValidation() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1100
1102 const CBlockIndex* GetSnapshotBaseBlock() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1103
1105 Chainstate& ActiveChainstate() const;
1106 CChain& ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChainstate().m_chain; }
1107 int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChain().Height(); }
1108 CBlockIndex* ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChain().Tip(); }
1109
1112 return IsUsable(m_snapshot_chainstate.get()) && IsUsable(m_ibd_chainstate.get());
1113 }
1114
1117 return BackgroundSyncInProgress() ? m_ibd_chainstate->m_chain.Tip() : nullptr;
1118 }
1119
1121 {
1123 return m_blockman.m_block_index;
1124 }
1125
1130
1133 bool IsSnapshotActive() const;
1134
1135 std::optional<uint256> SnapshotBlockhash() const;
1136
1139 {
1140 return m_snapshot_chainstate && m_ibd_chainstate && m_ibd_chainstate->m_disabled;
1141 }
1142
1144 bool IsInitialBlockDownload() const;
1145
1147 double GuessVerificationProgress(const CBlockIndex* pindex) const EXCLUSIVE_LOCKS_REQUIRED(GetMutex());
1148
1176 AutoFile& file_in,
1177 FlatFilePos* dbp = nullptr,
1178 std::multimap<uint256, FlatFilePos>* blocks_with_unknown_parent = nullptr);
1179
1204 bool ProcessNewBlock(const std::shared_ptr<const CBlock>& block, bool force_processing, bool min_pow_checked, bool* new_block) LOCKS_EXCLUDED(cs_main);
1205
1218 bool ProcessNewBlockHeaders(std::span<const CBlockHeader> headers, bool min_pow_checked, BlockValidationState& state, const CBlockIndex** ppindex = nullptr) LOCKS_EXCLUDED(cs_main);
1219
1239 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);
1240
1241 void ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pindexNew, const FlatFilePos& pos) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
1242
1249 [[nodiscard]] MempoolAcceptResult ProcessTransaction(const CTransactionRef& tx, bool test_accept=false)
1251
1253 bool LoadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
1254
1257 void MaybeRebalanceCaches() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1258
1260 void UpdateUncommittedBlockStructures(CBlock& block, const CBlockIndex* pindexPrev) const;
1261
1263 std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBlockIndex* pindexPrev) const;
1264
1269 void ReportHeadersPresync(const arith_uint256& work, int64_t height, int64_t timestamp);
1270
1273 bool DetectSnapshotChainstate() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1274
1275 void ResetChainstates() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1276
1279 [[nodiscard]] bool DeleteSnapshotChainstate() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1280
1283 Chainstate& ActivateExistingSnapshot(uint256 base_blockhash) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1284
1294 bool ValidatedSnapshotCleanup() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1295
1304 Chainstate& GetChainstateForIndexing() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1305
1309 std::pair<int, int> GetPruneRange(
1310 const Chainstate& chainstate, int last_height_can_prune) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1311
1314 std::optional<int> GetSnapshotBaseHeight() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1315
1319 void RecalculateBestHeader() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
1320
1321 CCheckQueue<CScriptCheck>& GetCheckQueue() { return m_script_check_queue; }
1322
1324};
1325
1327template<typename DEP>
1328bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const ChainstateManager& chainman, DEP dep)
1329{
1330 return DeploymentActiveAfter(pindexPrev, chainman.GetConsensus(), dep, chainman.m_versionbitscache);
1331}
1332
1333template<typename DEP>
1334bool DeploymentActiveAt(const CBlockIndex& index, const ChainstateManager& chainman, DEP dep)
1335{
1336 return DeploymentActiveAt(index, chainman.GetConsensus(), dep, chainman.m_versionbitscache);
1337}
1338
1339template<typename DEP>
1340bool DeploymentEnabled(const ChainstateManager& chainman, DEP dep)
1341{
1342 return DeploymentEnabled(chainman.GetConsensus(), dep);
1343}
1344
1346bool IsBIP30Repeat(const CBlockIndex& block_index);
1347
1349bool IsBIP30Unspendable(const uint256& block_hash, int block_height);
1350
1351#endif // BITCOIN_VALIDATION_H
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
void InvalidateBlock(ChainstateManager &chainman, const uint256 block_hash)
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
Definition: check.h:106
#define Assume(val)
Assume is the identity function.
Definition: check.h:118
static void CheckBlockIndex(benchmark::Bench &bench)
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:393
Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce value...
Definition: block.h:22
Definition: block.h:69
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:141
An in-memory indexed chain of blocks.
Definition: chain.h:417
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:69
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:363
CCoinsView backed by the coin database (chainstate/)
Definition: txdb.h:38
This is a minimally invasive approach to shutdown on LevelDB read errors from the chainstate,...
Definition: coins.h:512
Abstract view on the open txout dataset.
Definition: coins.h:310
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
Definition: feerate.h:33
A hasher class for SHA-256.
Definition: sha256.h:14
Closure representing one script verification Note that this stores references to the spending transac...
Definition: validation.h:332
CScriptCheck & operator=(CScriptCheck &&)=default
SignatureCache * m_signature_cache
Definition: validation.h:340
CScriptCheck(const CScriptCheck &)=delete
PrecomputedTransactionData * txdata
Definition: validation.h:339
CTxOut m_tx_out
Definition: validation.h:334
CScriptCheck(CScriptCheck &&)=default
bool cacheStore
Definition: validation.h:338
std::optional< std::pair< ScriptError, std::string > > operator()()
unsigned int nFlags
Definition: validation.h:337
CScriptCheck(const CTxOut &outIn, const CTransaction &txToIn, SignatureCache &signature_cache, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData *txdataIn)
Definition: validation.h:343
const CTransaction * ptxTo
Definition: validation.h:335
unsigned int nIn
Definition: validation.h:336
CScriptCheck & operator=(const CScriptCheck &)=delete
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:296
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:304
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Definition: txmempool.h:390
An output of a transaction.
Definition: transaction.h:150
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
Definition: validation.h:429
VerifyDBResult VerifyDB(Chainstate &chainstate, const Consensus::Params &consensus_params, CCoinsView &coinsview, int nCheckLevel, int nCheckDepth) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
kernel::Notifications & m_notifications
Definition: validation.h:431
CVerifyDB(kernel::Notifications &notifications)
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Definition: validation.h:521
Mutex m_chainstate_mutex
The ChainState Mutex A lock that must be held when modifying this ChainState - held in ActivateBestCh...
Definition: validation.h:528
CChain m_chain
The current chain of blockheaders we consult and build on.
Definition: validation.h:601
bool HasCoinsViews() const
Does this chainstate have a UTXO set attached?
Definition: validation.h:659
CTxMemPool * GetMempool()
Definition: validation.h:642
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:608
CTxMemPool * m_mempool
Optional mempool that is kept in sync with the chain.
Definition: validation.h:532
bool m_disabled GUARDED_BY(::cs_main)
This toggle exists for use when doing background validation for UTXO snapshots.
Definition: validation.h:548
CCoinsViewDB & CoinsDB() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:635
ChainstateManager & m_chainman
The chainstate manager that owns this chainstate.
Definition: validation.h:561
std::unique_ptr< CoinsViews > m_coins_views
Manages the UTXO set, which is a reflection of the contents of m_chain.
Definition: validation.h:535
void ResetCoinsViews()
Destructs all objects related to accessing the UTXO set.
Definition: validation.h:656
node::BlockManager & m_blockman
Reference to a BlockManager instance which itself is shared across all Chainstate instances.
Definition: validation.h:556
const CBlockIndex *m_cached_snapshot_base GUARDED_BY(::cs_main)
Cached result of LookupBlockIndex(*m_from_snapshot_blockhash)
Definition: validation.h:551
CCoinsViewErrorCatcher & CoinsErrorCatcher() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:649
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:881
SteadyClock::duration GUARDED_BY(::cs_main) time_connect_total
Definition: validation.h:975
std::unique_ptr< Chainstate > m_ibd_chainstate GUARDED_BY(::cs_main)
The chainstate used under normal operation (i.e.
const uint256 & AssumedValidBlock() const
Definition: validation.h:993
node::BlockMap & BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:1120
CBlockIndex *m_best_header GUARDED_BY(::cs_main)
Best header we've seen so far for which the block is not known to be invalid (used,...
Definition: validation.h:1058
ValidationCache m_validation_cache
Definition: validation.h:1022
int64_t GUARDED_BY(::cs_main) num_blocks_total
Definition: validation.h:974
SteadyClock::duration GUARDED_BY(::cs_main) time_undo
Definition: validation.h:971
SteadyClock::duration GUARDED_BY(::cs_main) time_index
Definition: validation.h:972
const CBlockIndex * GetBackgroundSyncTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
The tip of the background sync chain.
Definition: validation.h:1116
SteadyClock::duration GUARDED_BY(::cs_main) time_post_connect
Definition: validation.h:978
kernel::Notifications & GetNotifications() const
Definition: validation.h:994
SteadyClock::duration GUARDED_BY(::cs_main) time_check
Timers and counters used for benchmarking validation in both background and active chainstates.
Definition: validation.h:967
RecursiveMutex & GetMutex() const LOCK_RETURNED(
Alias for cs_main.
Definition: validation.h:1014
SteadyClock::duration GUARDED_BY(::cs_main) time_total
Definition: validation.h:973
SteadyClock::duration GUARDED_BY(::cs_main) time_chainstate
Definition: validation.h:977
bool IsSnapshotValidated() const EXCLUSIVE_LOCKS_REQUIRED(
Is there a snapshot in use and has it been fully validated?
Definition: validation.h:1138
CCheckQueue< CScriptCheck > m_script_check_queue
A queue for script verifications that have to be performed by worker threads.
Definition: validation.h:963
CBlockIndex * ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Definition: validation.h:1108
CBlockIndex *m_best_invalid GUARDED_BY(::cs_main)
Definition: validation.h:917
SteadyClock::duration GUARDED_BY(::cs_main) time_forks
Definition: validation.h:968
bool BackgroundSyncInProgress() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
The state of a background sync (for net processing)
Definition: validation.h:1111
CBlockIndex *m_last_notified_header GUARDED_BY(GetMutex())
The last header for which a headerTip notification was issued.
Definition: validation.h:920
const util::SignalInterrupt & m_interrupt
Definition: validation.h:1016
int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Definition: validation.h:1107
VersionBitsCache m_versionbitscache
Track versionbit status.
Definition: validation.h:1129
const CChainParams & GetParams() const
Definition: validation.h:989
const Consensus::Params & GetConsensus() const
Definition: validation.h:990
const arith_uint256 & MinimumChainWork() const
Definition: validation.h:992
const Options m_options
Definition: validation.h:1017
int32_t nBlockSequenceId GUARDED_BY(::cs_main)
Every received block is assigned a unique and increasing identifier, so we know which one to give pri...
SteadyClock::duration GUARDED_BY(::cs_main) time_verify
Definition: validation.h:970
Chainstate *m_active_chainstate GUARDED_BY(::cs_main)
Points to either the ibd or snapshot chainstate; indicates our most-work chain.
Definition: validation.h:915
Chainstate &InitializeChainstate(CTxMemPool *mempool) EXCLUSIVE_LOCKS_REQUIRED(std::vector< Chainstate * GetAll)()
Instantiate a new chainstate.
Definition: validation.h:1075
SteadyClock::duration GUARDED_BY(::cs_main) time_connect
Definition: validation.h:969
bool IsUsable(const Chainstate *const cs) const EXCLUSIVE_LOCKS_REQUIRED(
Return true if a chainstate is considered usable.
Definition: validation.h:958
std::unique_ptr< Chainstate > m_snapshot_chainstate GUARDED_BY(::cs_main)
A chainstate initialized on the basis of a UTXO snapshot.
void ResetBlockSequenceCounters() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:1046
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
Definition: validation.h:1020
SteadyClock::duration GUARDED_BY(::cs_main) time_flush
Definition: validation.h:976
A convenience class for constructing the CCoinsView* hierarchy used to facilitate access to the UTXO ...
Definition: validation.h:471
std::unique_ptr< CCoinsViewCache > m_cacheview GUARDED_BY(cs_main)
This is the top layer of the cache hierarchy - it keeps as many coins in memory as can fit per the db...
CCoinsViewErrorCatcher m_catcherview GUARDED_BY(cs_main)
This view wraps access to the leveldb instance and handles read errors gracefully.
CCoinsViewDB m_dbview GUARDED_BY(cs_main)
The lowest level of the CoinsViews cache hierarchy sits in a leveldb database on disk.
CoinsViews(DBParams db_params, CoinsViewOptions options)
This constructor initializes CCoinsViewDB and CCoinsViewErrorCatcher instances, but it does not creat...
Used to track blocks whose transactions were applied to the UTXO state as a part of a single Activate...
DisconnectedBlockTransactions.
Valid signature cache, to avoid doing expensive ECDSA signature checking twice for every transaction ...
Definition: sigcache.h:39
Convenience class for initializing and passing the script execution cache and signature cache.
Definition: validation.h:364
ValidationCache(size_t script_execution_cache_bytes, size_t signature_cache_bytes)
CuckooCache::cache< uint256, SignatureCacheHasher > m_script_execution_cache
Definition: validation.h:370
ValidationCache & operator=(const ValidationCache &)=delete
ValidationCache(const ValidationCache &)=delete
CSHA256 ScriptExecutionCacheHasher() const
Return a copy of the pre-initialized hasher.
Definition: validation.h:379
CSHA256 m_script_execution_cache_hasher
Pre-initialized hasher to avoid having to recreate it for every hash calculation.
Definition: validation.h:367
SignatureCache m_signature_cache
Definition: validation.h:371
bool IsValid() const
Definition: validation.h:105
BIP 9 allows multiple softforks to be deployed in parallel.
Definition: versionbits.h:77
256-bit unsigned big integer.
A base class defining functions for notifying about certain kernel events.
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition: blockstorage.h:139
Metadata describing a serialized version of a UTXO set from which an assumeutxo Chainstate can be con...
Definition: utxo_snapshot.h:34
transaction_identifier represents the two canonical transaction identifier types (txid,...
256-bit opaque blob.
Definition: uint256.h:196
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: cs_main.cpp:8
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.
unsigned int nHeight
static void pool cs
Transaction validation functions.
Definition: messages.h:20
std::unordered_map< uint256, CBlockIndex, BlockHasher > BlockMap
Definition: blockstorage.h:87
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition: string.h:233
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition: packages.h:50
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:423
@ OK
The message verification was successful.
Holds configuration for use during UTXO snapshot load and validation.
Definition: chainparams.h:35
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Definition: block.h:124
Holds various statistics on transactions within a chain.
Definition: chainparams.h:58
User-controlled performance and debug options.
Definition: txdb.h:28
Parameters that influence chain consensus.
Definition: params.h:83
Application-specific storage settings.
Definition: dbwrapper.h:34
Validation result for a transaction evaluated by MemPoolAccept (single or package).
Definition: validation.h:124
const std::optional< int64_t > m_vsize
Virtual size as used by the mempool, calculated using serialized size and sigops.
Definition: validation.h:141
const ResultType m_result_type
Result type.
Definition: validation.h:133
MempoolAcceptResult(int64_t vsize, CAmount fees)
Constructor for already-in-mempool case.
Definition: validation.h:218
const std::optional< CAmount > m_base_fees
Raw base fees in satoshis.
Definition: validation.h:143
MempoolAcceptResult(TxValidationState state)
Constructor for failure case.
Definition: validation.h:190
const TxValidationState m_state
Contains information about why the transaction failed.
Definition: validation.h:136
ResultType
Used to indicate the results of mempool validation.
Definition: validation.h:126
static MempoolAcceptResult Failure(TxValidationState state)
Definition: validation.h:160
static MempoolAcceptResult FeeFailure(TxValidationState state, CFeeRate effective_feerate, const std::vector< Wtxid > &wtxids_fee_calculations)
Definition: validation.h:164
const std::optional< CFeeRate > m_effective_feerate
The feerate at which this transaction was considered.
Definition: validation.h:149
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:196
const std::optional< Wtxid > m_other_wtxid
The wtxid of the transaction in the mempool which has the same txid but different witness.
Definition: validation.h:158
const std::list< CTransactionRef > m_replaced_transactions
Mempool transactions replaced by the tx.
Definition: validation.h:139
MempoolAcceptResult(const Wtxid &other_wtxid)
Constructor for witness-swapped case.
Definition: validation.h:222
static MempoolAcceptResult MempoolTxDifferentWitness(const Wtxid &other_wtxid)
Definition: validation.h:183
static MempoolAcceptResult MempoolTx(int64_t vsize, CAmount fees)
Definition: validation.h:179
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:170
MempoolAcceptResult(TxValidationState state, CFeeRate effective_feerate, const std::vector< Wtxid > &wtxids_fee_calculations)
Constructor for fee-related failure case.
Definition: validation.h:209
const std::optional< std::vector< Wtxid > > m_wtxids_fee_calculations
Contains the wtxids of the transactions used for fee-related checks.
Definition: validation.h:155
Version of SteadyClock that is mockable in the context of tests (set the current value with SetMockTi...
Definition: time.h:38
Mockable clock in the context of tests, otherwise the system clock.
Definition: time.h:18
Validation result for package mempool acceptance.
Definition: validation.h:230
PackageValidationState m_state
Definition: validation.h:231
PackageMempoolAcceptResult(const Wtxid &wtxid, const MempoolAcceptResult &result)
Constructor to create a PackageMempoolAcceptResult from a single MempoolAcceptResult.
Definition: validation.h:249
PackageMempoolAcceptResult(PackageValidationState state, CFeeRate feerate, std::map< Wtxid, MempoolAcceptResult > &&results)
Definition: validation.h:244
PackageMempoolAcceptResult(PackageValidationState state, std::map< Wtxid, MempoolAcceptResult > &&results)
Definition: validation.h:240
std::map< Wtxid, MempoolAcceptResult > m_tx_results
Map from wtxid to finished MempoolAcceptResults.
Definition: validation.h:238
Bilingual messages:
Definition: translation.h:24
An options struct for BlockManager, more ergonomically referred to as BlockManager::Options due to th...
An options struct for ChainstateManager, more ergonomically referred to as ChainstateManager::Options...
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:50
#define LOCK_RETURNED(x)
Definition: threadsafety.h:49
bool CheckFinalTxAtTip(const CBlockIndex &active_chain_tip, const CTransaction &tx)
Definition: validation.cpp:148
AssertLockHeld(pool.cs)
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).
static constexpr int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.
Definition: validation.h:83
static constexpr int DEFAULT_CHECKLEVEL
Definition: validation.h:71
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
Definition: validation.h:80
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
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:247
bool FatalError(kernel::Notifications &notifications, BlockValidationState &state, const bilingual_str &message)
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:69
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.
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.
bool DeploymentActiveAfter(const CBlockIndex *pindexPrev, const ChainstateManager &chainman, DEP dep)
Deployment* info via ChainstateManager.
Definition: validation.h:1328
BlockValidationState TestBlockValidity(Chainstate &chainstate, const CBlock &block, bool check_pow, bool check_merkle_root) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Verify a block, including transactions.
SnapshotCompletionResult
Definition: validation.h:832
bool DeploymentEnabled(const ChainstateManager &chainman, DEP dep)
Definition: validation.h:1340
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:86
constexpr std::array FlushStateModeNames
Definition: validation.h:454
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:310
PackageMempoolAcceptResult ProcessNewPackage(Chainstate &active_chainstate, CTxMemPool &pool, const Package &txns, bool test_accept, const std::optional< CFeeRate > &client_maxfeerate) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Validate (and maybe submit) a package to the mempool.
arith_uint256 CalculateClaimedHeadersWork(std::span< const CBlockHeader > headers)
Return the sum of the claimed work on a given set of headers.
VerifyDBResult
Definition: validation.h:419
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.
const std::vector< std::string > CHECKLEVEL_DOC
Documentation for argument 'checklevel'.
Definition: validation.cpp:101
void PruneBlockFilesManual(Chainstate &active_chainstate, int nManualPruneHeight)
Prune block files up to a given height.
FlushStateMode
Definition: validation.h:455
CoinsCacheSizeState
Definition: validation.h:498
@ LARGE
The cache is at >= 90% capacity.
@ CRITICAL
The coins cache is in immediate need of a flush.
bool DeploymentActiveAt(const CBlockIndex &index, const ChainstateManager &chainman, DEP dep)
Definition: validation.h:1334
bool IsBIP30Repeat(const CBlockIndex &block_index)
Identifies blocks that overwrote an existing coinbase output in the UTXO set (see BIP30)
static const signed int DEFAULT_CHECKBLOCKS
Definition: validation.h:70
DisconnectResult
Definition: validation.h:445
@ DISCONNECT_FAILED
Definition: validation.h:448
@ DISCONNECT_UNCLEAN
Definition: validation.h:447
@ DISCONNECT_OK
Definition: validation.h:446
bool IsBIP30Unspendable(const uint256 &block_hash, int block_height)
Identifies blocks which coinbase output was subsequently overwritten in the UTXO set (see BIP30)