7#ifndef BITCOIN_VALIDATION_H
8#define BITCOIN_VALIDATION_H
10#if defined(HAVE_CONFIG_H)
11#include <config/bitcoin-config.h>
70class SnapshotMetadata;
82#define MIN_TRANSACTION_SIZE (::GetSerializeSize(CTransaction{}))
130 bool _checkPow =
true,
131 bool _checkMerkleRoot =
true)
168 int nManualPruneHeight);
239 const std::vector<TxId> &txids_fee_calculations) {
241 txids_fee_calculations);
247 const std::vector<TxId> &txids_fee_calculations) {
249 effective_feerate, txids_fee_calculations);
275 const std::vector<TxId> &txids_fee_calculations)
283 const std::vector<TxId> &txids_fee_calculations)
310 std::map<TxId, MempoolAcceptResult> &&results)
346 int64_t accept_time,
bool bypass_limits,
347 bool test_accept =
false,
unsigned int heightOverride = 0)
363 const
Package &txns,
bool test_accept)
378 auto newvalue = (remaining -= consumed);
379 return newvalue >= 0;
382 bool check() {
return remaining >= 0; }
423 size_t signature_cache_bytes);
465 bool sigCacheStore,
bool scriptCacheStore,
470 std::vector<CScriptCheck> *pvChecks)
479 bool sigCacheStore,
bool scriptCacheStore,
485 tx, state, view,
flags, sigCacheStore, scriptCacheStore, txdata,
486 validation_cache, nSigChecksOut, nSigChecksTxLimiter,
nullptr,
nullptr);
505std::optional<std::vector<Coin>>
564 uint32_t nFlagsIn,
bool cacheIn,
579 std::optional<std::pair<ScriptError, std::string>>
operator()();
585static_assert(std::is_nothrow_move_assignable_v<CScriptCheck>);
586static_assert(std::is_nothrow_move_constructible_v<CScriptCheck>);
587static_assert(std::is_nothrow_destructible_v<CScriptCheck>);
654 int nCheckLevel,
int nCheckDepth)
792 std::optional<BlockHash> from_snapshot_blockhash = std::nullopt);
806 void InitCoinsDB(
size_t cache_size_bytes,
bool in_memory,
bool should_wipe,
807 std::
string leveldb_name = "chainstate");
811 void InitCoinsCache(
size_t cache_size_bytes)
819 return m_coins_views && m_coins_views->m_cacheview;
832 const std::optional<BlockHash> m_from_snapshot_blockhash{};
854 return *
Assert(m_coins_views->m_cacheview);
860 return Assert(m_coins_views)->m_dbview;
871 return Assert(m_coins_views)->m_catcherview;
881 size_t m_coinsdb_cache_size_bytes{0};
884 size_t m_coinstip_cache_size_bytes{0};
888 bool ResizeCoinsCaches(
size_t coinstip_size,
size_t coinsdb_size)
903 int nManualPruneHeight = 0);
906 void ForceFlushStateToDisk();
910 void PruneAndFlush();
933 std::shared_ptr<const CBlock> pblock =
nullptr,
936 !cs_avalancheFinalizedBlockIndex)
947 Amount *blockFees =
nullptr,
bool fJustCheck = false)
964 !cs_avalancheFinalizedBlockIndex)
970 !cs_avalancheFinalizedBlockIndex);
975 !cs_avalancheFinalizedBlockIndex);
987 void ClearAvalancheFinalizedBlock()
993 bool IsBlockAvalancheFinalized(const
CBlockIndex *pindex) const
1003 template <typename F>
1006 template <typename F, typename C, typename AC>
1008 C fChild, AC fAncestorWasChanged)
1019 bool ReplayBlocks();
1025 bool LoadGenesisBlock();
1027 void TryAddBlockIndexCandidate(
CBlockIndex *pindex)
1030 void PruneBlockIndexCandidates();
1051 GetCoinsCacheSizeState(
size_t max_coins_cache_size_bytes,
1052 size_t max_mempool_size_bytes)
1060 return m_mempool ? &m_mempool->
cs :
nullptr;
1064 bool ActivateBestChainStep(
1066 const std::shared_ptr<const CBlock> &pblock,
bool &fInvalidFound,
1070 !cs_avalancheFinalizedBlockIndex);
1074 const std::shared_ptr<const CBlock> &pblock,
1079 !cs_avalancheFinalizedBlockIndex);
1084 FindMostWorkChain(
std::vector<const
CBlockIndex *> &blocksToReconcile,
1091 void UnparkBlockImpl(
CBlockIndex *pindex,
bool fClearChildren)
1097 !cs_avalancheFinalizedBlockIndex);
1100 void CheckForkWarningConditionsOnNewFork(
CBlockIndex *pindexNewForkTip)
1114 NodeClock::time_point m_next_write{NodeClock::time_point::max()};
1228 PopulateAndValidateSnapshot(
Chainstate &snapshot_chainstate,
1230 const
node::SnapshotMetadata &metadata);
1239 bool AcceptBlockHeader(
1253 return pchainstate && !pchainstate->m_disabled;
1286 std::function<void()> snapshot_download_completed = std::function<void()>();
1291 return m_options.config.GetChainParams();
1294 return m_options.config.GetChainParams().GetConsensus();
1296 bool ShouldCheckBlockIndex()
const;
1298 return *
Assert(m_options.minimum_chain_work);
1301 return *
Assert(m_options.assumed_valid_block);
1304 return m_options.notifications;
1345 mutable std::atomic<bool> m_cached_finished_ibd{
false};
1352 std::atomic<int32_t> nBlockSequenceId{1};
1355 int32_t nBlockReverseSequenceId = -1;
1363 nBlockSequenceId = 1;
1364 nBlockReverseSequenceId = -1;
1396 size_t m_total_coinstip_cache{0};
1400 size_t m_total_coinsdb_cache{0};
1426 ActivateSnapshot(
AutoFile &coins_file,
1446 return ActiveChainstate().m_chain;
1449 return ActiveChain().Height();
1452 return ActiveChain().Tip();
1455 const CBlockIndex *GetAvalancheFinalizedTip()
const;
1459 return IsUsable(m_snapshot_chainstate.get()) &&
1460 IsUsable(m_ibd_chainstate.get());
1466 return BackgroundSyncInProgress() ? m_ibd_chainstate->m_chain.Tip()
1472 return m_blockman.m_block_index;
1477 bool IsSnapshotActive()
const;
1479 std::optional<BlockHash> SnapshotBlockhash()
const;
1483 return m_snapshot_chainstate && m_ibd_chainstate &&
1484 m_ibd_chainstate->m_disabled;
1491 bool IsInitialBlockDownload()
const;
1525 std::multimap<BlockHash, FlatFilePos>
1526 *blocks_with_unknown_parent =
nullptr,
1556 bool ProcessNewBlock(
const std::shared_ptr<const CBlock> &block,
1557 bool force_processing,
bool min_pow_checked,
1577 bool ProcessNewBlockHeaders(
1601 bool AcceptBlock(const
std::shared_ptr<const
CBlock> &pblock,
1619 ProcessTransaction(const
CTransactionRef &tx,
bool test_accept = false)
1636 void ReportHeadersPresync(const
arith_uint256 &work, int64_t height,
1641 bool DetectSnapshotChainstate(
CTxMemPool *mempool)
1648 [[nodiscard]]
bool DeleteSnapshotChainstate()
1680 std::pair<
int,
int> GetPruneRange(const
Chainstate &chainstate,
1681 int last_height_can_prune)
1686 std::optional<
int> GetSnapshotBaseHeight() const
1697 bool DumpRecentHeadersTime(const
fs::path &filePath) const
1700 bool LoadRecentHeadersTime(const
fs::path &filePath)
1705template <typename DEP>
1711template <
typename DEP>
static void InvalidateBlock(ChainstateManager &chainman, avalanche::Processor *const avalanche, const BlockHash &block_hash)
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
#define Assume(val)
Assume is the identity function.
static void CheckBlockIndex(benchmark::Bench &bench)
Non-refcounted RAII wrapper for FILE*.
uint64_t getExcessiveBlockSize() const
BlockValidationOptions withCheckPoW(bool _checkPoW=true) const
BlockValidationOptions(uint64_t _excessiveBlockSize, bool _checkPow=true, bool _checkMerkleRoot=true)
BlockValidationOptions withCheckMerkleRoot(bool _checkMerkleRoot=true) const
bool shouldValidatePoW() const
uint64_t excessiveBlockSize
bool shouldValidateMerkleRoot() const
The block chain is a tree shaped structure starting with the genesis block at the root,...
An in-memory indexed chain of blocks.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
The verifications are represented by a type T, which must provide an operator(), returning an std::op...
CCoinsView that adds a memory cache for transactions to another CCoinsView.
CCoinsView backed by the coin database (chainstate/)
This is a minimally invasive approach to shutdown on LevelDB read errors from the chainstate,...
Abstract view on the open txout dataset.
Fee rate in satoshis per virtualbyte: Amount / vB the feerate is represented internally as FeeFrac.
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set.
A hasher class for SHA-256.
Closure representing one script verification.
CScriptCheck & operator=(CScriptCheck &&)=default
SignatureCache * m_signature_cache
ScriptExecutionMetrics GetScriptExecutionMetrics() const
CScriptCheck(const CScriptCheck &)=delete
TxSigCheckLimiter * pTxLimitSigChecks
ScriptExecutionMetrics metrics
CScriptCheck(CScriptCheck &&)=default
CScriptCheck(const CTxOut &outIn, const CTransaction &txToIn, SignatureCache &signature_cache, unsigned int nInIn, uint32_t nFlagsIn, bool cacheIn, const PrecomputedTransactionData &txdataIn, TxSigCheckLimiter *pTxLimitSigChecksIn=nullptr, CheckInputsLimiter *pBlockLimitSigChecksIn=nullptr)
std::optional< std::pair< ScriptError, std::string > > operator()()
PrecomputedTransactionData txdata
const CTransaction * ptxTo
CheckInputsLimiter * pBlockLimitSigChecks
CScriptCheck & operator=(const CScriptCheck &)=delete
The basic transaction that is broadcasted on the network and contained in blocks.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
An output of a transaction.
Restore the UTXO in a Coin at a given COutPoint.
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
VerifyDBResult VerifyDB(Chainstate &chainstate, CCoinsView &coinsview, int nCheckLevel, int nCheckDepth) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
kernel::Notifications & m_notifications
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Mutex m_chainstate_mutex
The ChainState Mutex.
CChain m_chain
The current chain of blockheaders we consult and build on.
bool HasCoinsViews() const
Does this chainstate have a UTXO set attached?
CTxMemPool * GetMempool()
CCoinsViewErrorCatcher & CoinsErrorCatcher() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Mutex cs_avalancheFinalizedBlockIndex
CTxMemPool * m_mempool
Optional mempool that is kept in sync with the chain.
bool m_disabled GUARDED_BY(::cs_main)
This toggle exists for use when doing background validation for UTXO snapshots.
CCoinsViewDB & CoinsDB() EXCLUSIVE_LOCKS_REQUIRED(
ChainstateManager & m_chainman
The chainstate manager that owns this chainstate.
std::unique_ptr< CoinsViews > m_coins_views
Manages the UTXO set, which is a reflection of the contents of m_chain.
void ResetCoinsViews()
Destructs all objects related to accessing the UTXO set.
const CBlockIndex *m_avalancheFinalizedBlockIndex GUARDED_BY(cs_avalancheFinalizedBlockIndex)
The best block via avalanche voting.
node::BlockManager & m_blockman
Reference to a BlockManager instance which itself is shared across all Chainstate instances.
const CBlockIndex *m_cached_snapshot_base GUARDED_BY(::cs_main)
Cached result of LookupBlockIndex(*m_from_snapshot_blockhash)
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
SteadyClock::duration GUARDED_BY(::cs_main) time_connect_total
std::unique_ptr< Chainstate > m_ibd_chainstate GUARDED_BY(::cs_main)
The chainstate used under normal operation (i.e.
node::BlockMap & BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(
CBlockIndex *m_best_header GUARDED_BY(::cs_main)
Best header we've seen so far (used for getheaders queries' starting points).
ValidationCache m_validation_cache
int64_t GUARDED_BY(::cs_main) num_blocks_total
SteadyClock::duration GUARDED_BY(::cs_main) time_index
const Config & GetConfig() const
const CBlockIndex * GetBackgroundSyncTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
The tip of the background sync chain.
SteadyClock::duration GUARDED_BY(::cs_main) time_post_connect
kernel::Notifications & GetNotifications() const
SteadyMilliseconds m_last_presync_update GUARDED_BY(::cs_main)
Most recent headers presync progress update, for rate-limiting.
SteadyClock::duration GUARDED_BY(::cs_main) time_check
Timers and counters used for benchmarking validation in both background and active chainstates.
RecursiveMutex & GetMutex() const LOCK_RETURNED(
Alias for cs_main.
SteadyClock::duration GUARDED_BY(::cs_main) time_total
SteadyClock::duration GUARDED_BY(::cs_main) time_chainstate
bool IsSnapshotValidated() const EXCLUSIVE_LOCKS_REQUIRED(
Is there a snapshot in use and has it been fully validated?
CCheckQueue< CScriptCheck > m_script_check_queue
A queue for script verifications that have to be performed by worker threads.
CBlockIndex * ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
CBlockIndex *m_best_invalid GUARDED_BY(::cs_main)
SteadyClock::duration GUARDED_BY(::cs_main) time_forks
bool BackgroundSyncInProgress() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
The state of a background sync (for net processing)
CBlockIndex *m_last_notified_header GUARDED_BY(GetMutex())
The last header for which a headerTip notification was issued.
const util::SignalInterrupt & m_interrupt
int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
const CChainParams & GetParams() const
const Consensus::Params & GetConsensus() const
CBlockIndex *m_best_parked GUARDED_BY(::cs_main)
const arith_uint256 & MinimumChainWork() const
SteadyClock::duration GUARDED_BY(::cs_main) time_verify
Chainstate *m_active_chainstate GUARDED_BY(::cs_main)
Points to either the ibd or snapshot chainstate; indicates our most-work chain.
const BlockHash & AssumedValidBlock() const
Chainstate &InitializeChainstate(CTxMemPool *mempool) EXCLUSIVE_LOCKS_REQUIRED(std::vector< Chainstate * GetAll)()
Instantiate a new chainstate.
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...
SteadyClock::duration GUARDED_BY(::cs_main) time_connect
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(
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
SteadyClock::duration GUARDED_BY(::cs_main) time_flush
A convenience class for constructing the CCoinsView* hierarchy used to facilitate access to the UTXO ...
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.
std::unique_ptr< CCoinsViewCache > m_connect_block_view GUARDED_BY(cs_main)
Temporary CCoinsViewCache layered on top of m_cacheview and passed to ConnectBlock().
CCoinsViewDB m_dbview GUARDED_BY(cs_main)
The lowest level of the CoinsViews cache hierarchy sits in a leveldb database on disk.
cache implements a cache with properties similar to a cuckoo-set.
Different type to mark Mutex at global scope.
Valid signature cache, to avoid doing expensive ECDSA signature checking twice for every transaction ...
static TxSigCheckLimiter getDisabled()
TxSigCheckLimiter & operator=(const TxSigCheckLimiter &rhs)
TxSigCheckLimiter(const TxSigCheckLimiter &rhs)
Convenience class for initializing and passing the script execution cache and signature cache.
CuckooCache::cache< ScriptCacheElement, ScriptCacheHasher > m_script_execution_cache
ValidationCache & operator=(const ValidationCache &)=delete
ValidationCache(const ValidationCache &)=delete
CSHA256 ScriptExecutionCacheHasher() const
Return a copy of the pre-initialized hasher.
CSHA256 m_script_execution_cache_hasher
Pre-initialized hasher to avoid having to recreate it for every hash calculation.
SignatureCache m_signature_cache
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...
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
static const uint64_t MAX_TX_SIGCHECKS
Allowed number of signature check operations per transaction.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
bool DeploymentActiveAfter(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::BuriedDeployment dep)
Determine if a deployment is active for the next block.
bool DeploymentActiveAt(const CBlockIndex &index, const Consensus::Params ¶ms, Consensus::BuriedDeployment dep)
Determine if a deployment is active for this block.
ChainstateRole
This enum describes the various roles a specific Chainstate instance can take.
static void LoadExternalBlockFile(benchmark::Bench &bench)
The LoadExternalBlockFile() function is used during -reindex and -loadblock.
Filesystem operations and types.
std::unordered_map< BlockHash, CBlockIndex, BlockHasher > BlockMap
Implement std::hash so RCUPtr can be used as a key for maps or sets.
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
std::shared_ptr< const CTransaction > CTransactionRef
Holds configuration for use during UTXO snapshot load and validation.
A BlockHash is a unqiue identifier for a block.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Holds various statistics on transactions within a chain.
User-controlled performance and debug options.
Parameters that influence chain consensus.
Application-specific storage settings.
Validation result for a transaction evaluated by MemPoolAccept (single or package).
const std::optional< int64_t > m_vsize
Virtual size as used by the mempool, calculated using serialized size and sigchecks.
MempoolAcceptResult(ResultType result_type, int64_t vsize, Amount fees, CFeeRate effective_feerate, const std::vector< TxId > &txids_fee_calculations)
Generic constructor for success cases.
const ResultType m_result_type
Result type.
const std::optional< std::vector< TxId > > m_txids_fee_calculations
Contains the txids of the transactions used for fee-related checks.
MempoolAcceptResult(TxValidationState state)
Constructor for failure case.
const TxValidationState m_state
Contains information about why the transaction failed.
MempoolAcceptResult(TxValidationState state, CFeeRate effective_feerate, const std::vector< TxId > &txids_fee_calculations)
Constructor for fee-related failure case.
ResultType
Used to indicate the results of mempool validation.
@ MEMPOOL_ENTRY
Valid, transaction was already in the mempool.
@ VALID
Fully validated, valid.
static MempoolAcceptResult Failure(TxValidationState state)
const std::optional< CFeeRate > m_effective_feerate
The feerate at which this transaction was considered.
static MempoolAcceptResult FeeFailure(TxValidationState state, CFeeRate effective_feerate, const std::vector< TxId > &txids_fee_calculations)
static MempoolAcceptResult Success(int64_t vsize, Amount fees, CFeeRate effective_feerate, const std::vector< TxId > &txids_fee_calculations)
Constructor for success case.
static MempoolAcceptResult MempoolTx(int64_t vsize, Amount fees)
Constructor for already-in-mempool case.
MempoolAcceptResult(int64_t vsize, Amount fees)
Constructor for already-in-mempool case.
const std::optional< Amount > m_base_fees
Raw base fees in satoshis.
Mockable clock in the context of tests, otherwise the system clock.
std::chrono::time_point< NodeClock > time_point
Validation result for package mempool acceptance.
PackageMempoolAcceptResult(const TxId &txid, const MempoolAcceptResult &result)
Constructor to create a PackageMempoolAcceptResult from a MempoolAcceptResult.
PackageMempoolAcceptResult(PackageValidationState state, std::map< TxId, MempoolAcceptResult > &&results)
PackageValidationState m_state
std::map< TxId, MempoolAcceptResult > m_tx_results
Map from txid to finished MempoolAcceptResults.
Precompute sighash midstate to avoid quadratic hashing.
Struct for holding cumulative results from executing a script or a sequence of scripts.
A TxId is the identifier of a transaction.
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 AssertLockHeld(cs)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
#define LOCKS_EXCLUDED(...)
std::chrono::time_point< std::chrono::steady_clock, std::chrono::milliseconds > SteadyMilliseconds
GlobalMutex g_best_block_mutex
bool TestBlockValidity(BlockValidationState &state, const CChainParams ¶ms, Chainstate &chainstate, const CBlock &block, CBlockIndex *pindexPrev, const std::function< NodeClock::time_point()> &adjusted_time_callback, BlockValidationOptions validationOptions) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Check a block is completely valid from start to finish (only works on top of our current best block)
static constexpr int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.
Amount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
std::condition_variable g_best_block_cv
std::optional< LockPoints > CalculateLockPointsAtTip(CBlockIndex *tip, const CCoinsView &coins_view, const CTransaction &tx)
Calculate LockPoints required to check if transaction will be BIP68 final in the next block to be cre...
static constexpr int DEFAULT_CHECKLEVEL
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.
double GuessVerificationProgress(const ChainTxData &data, const CBlockIndex *pindex)
Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip).
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev?...
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.
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...
const CBlockIndex * g_best_block
Used to notify getblocktemplate RPC of new tips.
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.
@ BASE_BLOCKHASH_MISMATCH
SynchronizationState
Current sync state passed to tip changed callbacks.
MempoolAcceptResult AcceptToMemoryPool(Chainstate &active_chainstate, const CTransactionRef &tx, int64_t accept_time, bool bypass_limits, bool test_accept=false, unsigned int heightOverride=0) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Try to add a transaction to the mempool.
void SpendCoins(CCoinsViewCache &view, const CTransaction &tx, CTxUndo &txundo, int nHeight)
Mark all the coins corresponding to a given transaction inputs as spent.
bool CheckBlock(const CBlock &block, BlockValidationState &state, const Consensus::Params ¶ms, BlockValidationOptions validationOptions)
Functions for validating blocks and updating the block tree.
const std::vector< std::string > CHECKLEVEL_DOC
Documentation for argument 'checklevel'.
void PruneBlockFilesManual(Chainstate &active_chainstate, int nManualPruneHeight)
Prune block files up to a given height.
bool IsBlockMutated(const CBlock &block)
Check if a block has been mutated (with respect to its merkle root).
@ LARGE
The cache is at >= 90% capacity.
@ CRITICAL
The coins cache is in immediate need of a flush.
bool CheckInputScripts(const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &view, const uint32_t flags, bool sigCacheStore, bool scriptCacheStore, const PrecomputedTransactionData &txdata, ValidationCache &validation_cache, int &nSigChecksOut, TxSigCheckLimiter &txLimitSigChecks, CheckInputsLimiter *pBlockLimitSigChecks, std::vector< CScriptCheck > *pvChecks) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Check whether all of this transaction's input scripts succeed.
std::optional< std::vector< Coin > > GetSpentCoins(const CTransactionRef &ptx, const CCoinsViewCache &coins_view)
Get the coins spent by ptx from the coins_view.
void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, CTxUndo &txundo, int nHeight)
Apply the effects of this transaction on the UTXO set represented by view.
arith_uint256 CalculateClaimedHeadersWork(const std::vector< CBlockHeader > &headers)
Return the sum of the claimed work on a given set of headers.
static const signed int DEFAULT_CHECKBLOCKS
bool FatalError(kernel::Notifications ¬ifications, BlockValidationState &state, const std::string &strMessage, const bilingual_str &userMessage={})