Bitcoin Core  23.99.0
P2P Digital Currency
Classes | Macros | Functions | Variables
validation.cpp File Reference
#include <validation.h>
#include <kernel/coinstats.h>
#include <kernel/mempool_persist.h>
#include <arith_uint256.h>
#include <chain.h>
#include <chainparams.h>
#include <checkqueue.h>
#include <consensus/amount.h>
#include <consensus/consensus.h>
#include <consensus/merkle.h>
#include <consensus/tx_check.h>
#include <consensus/tx_verify.h>
#include <consensus/validation.h>
#include <cuckoocache.h>
#include <flatfile.h>
#include <fs.h>
#include <hash.h>
#include <logging.h>
#include <logging/timer.h>
#include <node/blockstorage.h>
#include <node/interface_ui.h>
#include <node/utxo_snapshot.h>
#include <policy/policy.h>
#include <policy/rbf.h>
#include <policy/settings.h>
#include <pow.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <random.h>
#include <reverse_iterator.h>
#include <script/script.h>
#include <script/sigcache.h>
#include <shutdown.h>
#include <signet.h>
#include <tinyformat.h>
#include <txdb.h>
#include <txmempool.h>
#include <uint256.h>
#include <undo.h>
#include <util/check.h>
#include <util/hasher.h>
#include <util/moneystr.h>
#include <util/rbf.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <util/time.h>
#include <util/trace.h>
#include <util/translation.h>
#include <validationinterface.h>
#include <warnings.h>
#include <algorithm>
#include <cassert>
#include <chrono>
#include <deque>
#include <numeric>
#include <optional>
#include <string>

Go to the source code of this file.

Classes

class  WarningBitsConditionChecker
 Threshold condition checker that triggers when unknown versionbits are seen on the network. More...
 
struct  PerBlockConnectTrace
 
class  ConnectTrace
 Used to track blocks whose transactions were applied to the UTXO state as a part of a single ActivateBestChainStep call. More...
 

Macros

#define MICRO   0.000001
 
#define MILLI   0.001
 

Functions

bool CheckInputScripts (const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &inputs, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData &txdata, std::vector< CScriptCheck > *pvChecks)
 Check whether all of this transaction's input scripts succeed. More...
 
bool CheckFinalTxAtTip (const CBlockIndex *active_chain_tip, const CTransaction &tx)
 
bool CheckSequenceLocksAtTip (CBlockIndex *tip, const CCoinsView &coins_view, const CTransaction &tx, LockPoints *lp, bool useExistingLockPoints)
 
static unsigned int GetBlockScriptFlags (const CBlockIndex &block_index, const ChainstateManager &chainman)
 
static void LimitMempoolSize (CTxMemPool &pool, CCoinsViewCache &coins_cache) EXCLUSIVE_LOCKS_REQUIRED(
 
static bool IsCurrentForFeeEstimation (CChainState &active_chainstate) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static bool CheckInputsFromMempoolAndCache (const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &view, const CTxMemPool &pool, unsigned int flags, PrecomputedTransactionData &txdata, CCoinsViewCache &coins_tip) EXCLUSIVE_LOCKS_REQUIRED(cs_main
 Checks to avoid mempool polluting consensus critical paths since cached signature and script validity results will be reused if we validate this transaction again during block validation. More...
 
 AssertLockHeld (pool.cs)
 
 assert (!tx.IsCoinBase())
 
 for (const CTxIn &txin :tx.vin)
 
return CheckInputScripts (tx, state, view, flags, true, true, txdata)
 
MempoolAcceptResult AcceptToMemoryPool (CChainState &active_chainstate, const CTransactionRef &tx, int64_t accept_time, bool bypass_limits, bool test_accept) EXCLUSIVE_LOCKS_REQUIRED(
 Try to add a transaction to the mempool. More...
 
PackageMempoolAcceptResult ProcessNewPackage (CChainState &active_chainstate, CTxMemPool &pool, const Package &package, bool test_accept)
 Validate (and maybe submit) a package to the mempool. More...
 
CAmount GetBlockSubsidy (int nHeight, const Consensus::Params &consensusParams)
 
static void AlertNotify (const std::string &strMessage)
 
void UpdateCoins (const CTransaction &tx, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
 
bool InitScriptExecutionCache (size_t max_size_bytes)
 Initializes the script-execution cache. More...
 
bool AbortNode (BlockValidationState &state, const std::string &strMessage, const bilingual_str &userMessage)
 
int ApplyTxInUndo (Coin &&undo, CCoinsViewCache &view, const COutPoint &out)
 Restore the UTXO in a Coin at a given COutPoint. More...
 
void StartScriptCheckWorkerThreads (int threads_num)
 Run instances of script checking worker threads. More...
 
void StopScriptCheckWorkerThreads ()
 Stop all of the script checking worker threads. More...
 
static std::array< ThresholdConditionCache, VERSIONBITS_NUM_BITS > warningcache GUARDED_BY (cs_main)
 
static void DoWarning (const bilingual_str &warning)
 
static void AppendWarning (bilingual_str &res, const bilingual_str &warn)
 Private helper function that concatenates warning messages. More...
 
static void UpdateTipLog (const CCoinsViewCache &coins_tip, const CBlockIndex *tip, const CChainParams &params, const std::string &func_name, const std::string &prefix, const std::string &warning_messages) EXCLUSIVE_LOCKS_REQUIRED(
 
static SynchronizationState GetSynchronizationState (bool init)
 
static bool NotifyHeaderTip (CChainState &chainstate) LOCKS_EXCLUDED(cs_main)
 
static void LimitValidationInterfaceQueue () LOCKS_EXCLUDED(cs_main)
 
static bool CheckBlockHeader (const CBlockHeader &block, BlockValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW=true)
 
bool CheckBlock (const CBlock &block, BlockValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW, bool fCheckMerkleRoot)
 Functions for validating blocks and updating the block tree. More...
 
static bool ContextualCheckBlockHeader (const CBlockHeader &block, BlockValidationState &state, BlockManager &blockman, const ChainstateManager &chainman, const CBlockIndex *pindexPrev, int64_t nAdjustedTime) EXCLUSIVE_LOCKS_REQUIRED(
 Context-dependent validity checks. More...
 
static bool ContextualCheckBlock (const CBlock &block, BlockValidationState &state, const ChainstateManager &chainman, const CBlockIndex *pindexPrev)
 NOTE: This function is not currently invoked by ConnectBlock(), so we should consider upgrade issues if we change which consensus rules are enforced in this function (eg by adding a new consensus rule). More...
 
bool TestBlockValidity (BlockValidationState &state, const CChainParams &chainparams, CChainState &chainstate, const CBlock &block, CBlockIndex *pindexPrev, const std::function< int64_t()> &adjusted_time_callback, bool fCheckPOW, bool fCheckMerkleRoot)
 Check a block is completely valid from start to finish (only works on top of our current best block) More...
 
void PruneBlockFilesManual (CChainState &active_chainstate, int nManualPruneHeight)
 Prune block files up to a given height. More...
 
double GuessVerificationProgress (const ChainTxData &data, const CBlockIndex *pindex)
 Guess how far we are in the verification process at the given block index require cs_main if pindex has not been validated yet (because nChainTx might be unset) More...
 
const AssumeutxoDataExpectedAssumeutxo (const int height, const CChainParams &chainparams)
 Return the expected assumeutxo value for a given height, if one exists. More...
 
static void FlushSnapshotToDisk (CCoinsViewCache &coins_cache, bool snapshot_loaded)
 

Variables

static const unsigned int MAX_DISCONNECTED_TX_POOL_SIZE = 20000
 Maximum kilobytes for transactions to store for processing during reorg. More...
 
static constexpr std::chrono::hours DATABASE_WRITE_INTERVAL {1}
 Time to wait between writing blocks/block index to disk. More...
 
static constexpr std::chrono::hours DATABASE_FLUSH_INTERVAL {24}
 Time to wait between flushing chainstate to disk. More...
 
static constexpr std::chrono::hours MAX_FEE_ESTIMATION_TIP_AGE {3}
 Maximum age of our tip for us to be considered current for fee estimation. More...
 
const std::vector< std::string > CHECKLEVEL_DOC
 Documentation for argument 'checklevel'. More...
 
static constexpr int PRUNE_LOCK_BUFFER {10}
 The number of blocks to keep below the deepest prune lock. More...
 
RecursiveMutex cs_main
 Mutex to guard access to validation specific variables, such as reading or changing the chainstate. More...
 
GlobalMutex g_best_block_mutex
 
std::condition_variable g_best_block_cv
 
uint256 g_best_block
 Used to notify getblocktemplate RPC of new tips. More...
 
bool g_parallel_script_checks {false}
 Whether there are dedicated script-checking threads running. More...
 
bool fCheckBlockIndex = false
 
bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED
 
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE
 If the tip is older than this (in seconds), the node is considered to be in initial block download. More...
 
uint256 hashAssumeValid
 Block hash whose ancestors we will assume to have valid scripts without checking them. More...
 
arith_uint256 nMinimumChainWork
 Minimum work we will assume exists on some valid chain. More...
 
static bool pool cs
 
static CuckooCache::cache< uint256, SignatureCacheHasherg_scriptExecutionCache
 
static CSHA256 g_scriptExecutionCacheHasher
 
static CCheckQueue< CScriptCheckscriptcheckqueue (128)
 
static int64_t nTimeCheck = 0
 
static int64_t nTimeForks = 0
 
static int64_t nTimeConnect = 0
 
static int64_t nTimeVerify = 0
 
static int64_t nTimeUndo = 0
 
static int64_t nTimeIndex = 0
 
static int64_t nTimeTotal = 0
 
static int64_t nBlocksTotal = 0
 
static int64_t nTimeReadFromDiskTotal = 0
 
static int64_t nTimeConnectTotal = 0
 
static int64_t nTimeFlush = 0
 
static int64_t nTimeChainState = 0
 
static int64_t nTimePostConnect = 0
 

Macro Definition Documentation

◆ MICRO

#define MICRO   0.000001

Definition at line 85 of file validation.cpp.

◆ MILLI

#define MILLI   0.001

Definition at line 86 of file validation.cpp.

Function Documentation

◆ AbortNode()

bool AbortNode ( BlockValidationState state,
const std::string &  strMessage,
const bilingual_str userMessage 
)

Definition at line 1785 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AcceptToMemoryPool()

MempoolAcceptResult AcceptToMemoryPool ( CChainState active_chainstate,
const CTransactionRef tx,
int64_t  accept_time,
bool  bypass_limits,
bool  test_accept 
)

Try to add a transaction to the mempool.

This is an internal function and is exposed only for testing. Client code should use ChainstateManager::ProcessTransaction()

Parameters
[in]active_chainstateReference to the active chainstate.
[in]txThe transaction to submit for mempool acceptance.
[in]accept_timeThe timestamp for adding the transaction to the mempool. It is also used to determine when the entry expires.
[in]bypass_limitsWhen true, don't enforce mempool fee and capacity limits.
[in]test_acceptWhen true, run validation checks but don't submit to mempool.
Returns
a MempoolAcceptResult indicating whether the transaction was accepted/rejected with reason.

Definition at line 1415 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AlertNotify()

static void AlertNotify ( const std::string &  strMessage)
static

Definition at line 1561 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AppendWarning()

static void AppendWarning ( bilingual_str res,
const bilingual_str warn 
)
static

Private helper function that concatenates warning messages.

Definition at line 2496 of file validation.cpp.

Here is the call graph for this function:

◆ ApplyTxInUndo()

int ApplyTxInUndo ( Coin &&  undo,
CCoinsViewCache view,
const COutPoint out 
)

Restore the UTXO in a Coin at a given COutPoint.

Parameters
undoThe Coin to be restored.
viewThe coins view to which to apply the changes.
outThe out point that corresponds to the tx input.
Returns
A DisconnectResult as an int

Definition at line 1798 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assert()

assert ( !tx.  IsCoinBase())

◆ AssertLockHeld()

AssertLockHeld ( pool.  cs)

◆ CheckBlock()

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.

Context-independent validity checks

Definition at line 3323 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckBlockHeader()

static bool CheckBlockHeader ( const CBlockHeader block,
BlockValidationState state,
const Consensus::Params consensusParams,
bool  fCheckPOW = true 
)
static

Definition at line 3314 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckFinalTxAtTip()

bool CheckFinalTxAtTip ( const CBlockIndex active_chain_tip,
const CTransaction tx 
)

Definition at line 160 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckInputScripts() [1/2]

bool CheckInputScripts ( const CTransaction tx,
TxValidationState state,
const CCoinsViewCache inputs,
unsigned int  flags,
bool  cacheSigStore,
bool  cacheFullScriptStore,
PrecomputedTransactionData txdata,
std::vector< CScriptCheck > *  pvChecks 
)

Check whether all of this transaction's input scripts succeed.

This involves ECDSA signature checks so can be computationally intensive. This function should only be called after the cheap sanity checks in CheckTxInputs passed.

If pvChecks is not nullptr, script checks are pushed onto it instead of being performed inline. Any script checks which are not necessary (eg due to script execution cache hits) are, obviously, not pushed onto pvChecks/run.

Setting cacheSigStore/cacheFullScriptStore to false will remove elements from the corresponding cache which are matched. This is useful for checking blocks where we will likely never need the cache entry again.

Note that we may set state.reason to NOT_STANDARD for extra soft-fork flags in flags, block-checking callers should probably reset it to CONSENSUS in such cases.

Non-static (and re-declared) in src/test/txvalidationcache_tests.cpp

Definition at line 1697 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckInputScripts() [2/2]

return CheckInputScripts ( tx  ,
state  ,
view  ,
flags  ,
true  ,
true  ,
txdata   
)

◆ CheckInputsFromMempoolAndCache()

static bool CheckInputsFromMempoolAndCache ( const CTransaction tx,
TxValidationState state,
const CCoinsViewCache view,
const CTxMemPool pool,
unsigned int  flags,
PrecomputedTransactionData txdata,
CCoinsViewCache coins_tip 
)
static

Checks to avoid mempool polluting consensus critical paths since cached signature and script validity results will be reused if we validate this transaction again during block validation.

◆ CheckSequenceLocksAtTip()

bool CheckSequenceLocksAtTip ( CBlockIndex tip,
const CCoinsView coins_view,
const CTransaction tx,
LockPoints lp,
bool  useExistingLockPoints 
)

Definition at line 183 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ContextualCheckBlock()

static bool ContextualCheckBlock ( const CBlock block,
BlockValidationState state,
const ChainstateManager chainman,
const CBlockIndex pindexPrev 
)
static

NOTE: This function is not currently invoked by ConnectBlock(), so we should consider upgrade issues if we change which consensus rules are enforced in this function (eg by adding a new consensus rule).

See comment in ConnectBlock(). Note that -reindex-chainstate skips the validation that happens here!

Definition at line 3493 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ContextualCheckBlockHeader()

static bool ContextualCheckBlockHeader ( const CBlockHeader block,
BlockValidationState state,
BlockManager blockman,
const ChainstateManager chainman,
const CBlockIndex pindexPrev,
int64_t  nAdjustedTime 
)
static

Context-dependent validity checks.

By "context", we mean only the previous block headers, but not the UTXO set; UTXO-related validity checks are done in ConnectBlock(). NOTE: This function is not currently invoked by ConnectBlock(), so we should consider upgrade issues if we change which consensus rules are enforced in this function (eg by adding a new consensus rule). See comment in ConnectBlock(). Note that -reindex-chainstate skips the validation that happens here!

Definition at line 3445 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoWarning()

static void DoWarning ( const bilingual_str warning)
static

Definition at line 2485 of file validation.cpp.

Here is the call graph for this function:

◆ ExpectedAssumeutxo()

const AssumeutxoData* ExpectedAssumeutxo ( const int  height,
const CChainParams params 
)

Return the expected assumeutxo value for a given height, if one exists.

Parameters
[in]heightGet the assumeutxo value for this height.
Returns
empty if no assumeutxo configuration exists for the given height.

Definition at line 4725 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FlushSnapshotToDisk()

static void FlushSnapshotToDisk ( CCoinsViewCache coins_cache,
bool  snapshot_loaded 
)
static

Definition at line 4820 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ for()

for ( const CTxIn &txin :tx.  vin)

Definition at line 395 of file validation.cpp.

Here is the call graph for this function:

◆ GetBlockScriptFlags()

static unsigned int GetBlockScriptFlags ( const CBlockIndex block_index,
const ChainstateManager chainman 
)
static

Definition at line 1927 of file validation.cpp.

Here is the call graph for this function:

◆ GetBlockSubsidy()

CAmount GetBlockSubsidy ( int  nHeight,
const Consensus::Params consensusParams 
)

Definition at line 1474 of file validation.cpp.

Here is the caller graph for this function:

◆ GetSynchronizationState()

static SynchronizationState GetSynchronizationState ( bool  init)
static

Definition at line 2924 of file validation.cpp.

Here is the caller graph for this function:

◆ GUARDED_BY()

static std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> warningcache GUARDED_BY ( cs_main  )
static

◆ GuessVerificationProgress()

double GuessVerificationProgress ( const ChainTxData data,
const CBlockIndex pindex 
)

Guess how far we are in the verification process at the given block index require cs_main if pindex has not been validated yet (because nChainTx might be unset)

Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip).

Definition at line 4658 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitScriptExecutionCache()

bool InitScriptExecutionCache ( size_t  max_size_bytes)

Initializes the script-execution cache.

Definition at line 1659 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsCurrentForFeeEstimation()

static bool IsCurrentForFeeEstimation ( CChainState active_chainstate)
static

Definition at line 277 of file validation.cpp.

Here is the call graph for this function:

◆ LimitMempoolSize()

static void LimitMempoolSize ( CTxMemPool pool,
CCoinsViewCache coins_cache 
)
static

Definition at line 261 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LimitValidationInterfaceQueue()

static void LimitValidationInterfaceQueue ( )
static

Definition at line 2953 of file validation.cpp.

Here is the call graph for this function:

◆ NotifyHeaderTip()

static bool NotifyHeaderTip ( CChainState chainstate)
static

Definition at line 2931 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessNewPackage()

PackageMempoolAcceptResult ProcessNewPackage ( CChainState active_chainstate,
CTxMemPool pool,
const Package txns,
bool  test_accept 
)

Validate (and maybe submit) a package to the mempool.

See doc/policy/packages.md for full details on package validation rules.

Parameters
[in]test_acceptWhen true, run validation checks but don't submit to mempool.
Returns
a PackageMempoolAcceptResult which includes a MempoolAcceptResult for each transaction. If a transaction fails, validation will exit early and some results may be missing. It is also possible for the package to be partially submitted.

Definition at line 1442 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PruneBlockFilesManual()

void PruneBlockFilesManual ( CChainState active_chainstate,
int  nManualPruneHeight 
)

Prune block files up to a given height.

Definition at line 3864 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartScriptCheckWorkerThreads()

void StartScriptCheckWorkerThreads ( int  threads_num)

Run instances of script checking worker threads.

Definition at line 1889 of file validation.cpp.

Here is the caller graph for this function:

◆ StopScriptCheckWorkerThreads()

void StopScriptCheckWorkerThreads ( )

Stop all of the script checking worker threads.

Definition at line 1894 of file validation.cpp.

Here is the caller graph for this function:

◆ TestBlockValidity()

bool TestBlockValidity ( BlockValidationState state,
const CChainParams chainparams,
CChainState chainstate,
const CBlock block,
CBlockIndex pindexPrev,
const std::function< int64_t()> &  adjusted_time_callback,
bool  fCheckPOW,
bool  fCheckMerkleRoot 
)

Check a block is completely valid from start to finish (only works on top of our current best block)

Definition at line 3830 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateCoins()

void UpdateCoins ( const CTransaction tx,
CCoinsViewCache inputs,
CTxUndo txundo,
int  nHeight 
)

Definition at line 1635 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateTipLog()

static void UpdateTipLog ( const CCoinsViewCache coins_tip,
const CBlockIndex tip,
const CChainParams params,
const std::string &  func_name,
const std::string &  prefix,
const std::string &  warning_messages 
)
static

Definition at line 2502 of file validation.cpp.

Here is the call graph for this function:

Variable Documentation

◆ CHECKLEVEL_DOC

const std::vector<std::string> CHECKLEVEL_DOC
Initial value:
{
"level 0 reads the blocks from disk",
"level 1 verifies block validity",
"level 2 verifies undo data",
"level 3 checks disconnection of tip blocks",
"level 4 tries to reconnect the blocks",
"each level includes the checks of the previous levels",
}

Documentation for argument 'checklevel'.

Definition at line 96 of file validation.cpp.

◆ cs

bool pool cs
Initial value:

Definition at line 390 of file validation.cpp.

◆ cs_main

RecursiveMutex cs_main

Mutex to guard access to validation specific variables, such as reading or changing the chainstate.

This may also need to be locked when updating the transaction pool, e.g. on AcceptToMemoryPool. See CTxMemPool::cs comment for details.

The transaction pool has a separate lock to allow reading from it and the chainstate at the same time.

Definition at line 121 of file validation.cpp.

◆ DATABASE_FLUSH_INTERVAL

constexpr std::chrono::hours DATABASE_FLUSH_INTERVAL {24}
staticconstexpr

Time to wait between flushing chainstate to disk.

Definition at line 93 of file validation.cpp.

◆ DATABASE_WRITE_INTERVAL

constexpr std::chrono::hours DATABASE_WRITE_INTERVAL {1}
staticconstexpr

Time to wait between writing blocks/block index to disk.

Definition at line 91 of file validation.cpp.

◆ fCheckBlockIndex

bool fCheckBlockIndex = false

Definition at line 127 of file validation.cpp.

◆ fCheckpointsEnabled

bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED

Definition at line 128 of file validation.cpp.

◆ g_best_block

uint256 g_best_block

Used to notify getblocktemplate RPC of new tips.

Definition at line 125 of file validation.cpp.

◆ g_best_block_cv

std::condition_variable g_best_block_cv

Definition at line 124 of file validation.cpp.

◆ g_best_block_mutex

GlobalMutex g_best_block_mutex

Definition at line 123 of file validation.cpp.

◆ g_parallel_script_checks

bool g_parallel_script_checks {false}

Whether there are dedicated script-checking threads running.

False indicates all script checking is done on the main threadMessageHandler thread.

Definition at line 126 of file validation.cpp.

◆ g_scriptExecutionCache

CuckooCache::cache<uint256, SignatureCacheHasher> g_scriptExecutionCache
static

Definition at line 1656 of file validation.cpp.

◆ g_scriptExecutionCacheHasher

CSHA256 g_scriptExecutionCacheHasher
static

Definition at line 1657 of file validation.cpp.

◆ hashAssumeValid

uint256 hashAssumeValid

Block hash whose ancestors we will assume to have valid scripts without checking them.

Definition at line 131 of file validation.cpp.

◆ MAX_DISCONNECTED_TX_POOL_SIZE

const unsigned int MAX_DISCONNECTED_TX_POOL_SIZE = 20000
static

Maximum kilobytes for transactions to store for processing during reorg.

Definition at line 89 of file validation.cpp.

◆ MAX_FEE_ESTIMATION_TIP_AGE

constexpr std::chrono::hours MAX_FEE_ESTIMATION_TIP_AGE {3}
staticconstexpr

Maximum age of our tip for us to be considered current for fee estimation.

Definition at line 95 of file validation.cpp.

◆ nBlocksTotal

int64_t nBlocksTotal = 0
static

Definition at line 1976 of file validation.cpp.

◆ nMaxTipAge

int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE

If the tip is older than this (in seconds), the node is considered to be in initial block download.

Definition at line 129 of file validation.cpp.

◆ nMinimumChainWork

arith_uint256 nMinimumChainWork

Minimum work we will assume exists on some valid chain.

Definition at line 132 of file validation.cpp.

◆ nTimeChainState

int64_t nTimeChainState = 0
static

Definition at line 2646 of file validation.cpp.

◆ nTimeCheck

int64_t nTimeCheck = 0
static

Definition at line 1969 of file validation.cpp.

◆ nTimeConnect

int64_t nTimeConnect = 0
static

Definition at line 1971 of file validation.cpp.

◆ nTimeConnectTotal

int64_t nTimeConnectTotal = 0
static

Definition at line 2644 of file validation.cpp.

◆ nTimeFlush

int64_t nTimeFlush = 0
static

Definition at line 2645 of file validation.cpp.

◆ nTimeForks

int64_t nTimeForks = 0
static

Definition at line 1970 of file validation.cpp.

◆ nTimeIndex

int64_t nTimeIndex = 0
static

Definition at line 1974 of file validation.cpp.

◆ nTimePostConnect

int64_t nTimePostConnect = 0
static

Definition at line 2647 of file validation.cpp.

◆ nTimeReadFromDiskTotal

int64_t nTimeReadFromDiskTotal = 0
static

Definition at line 2643 of file validation.cpp.

◆ nTimeTotal

int64_t nTimeTotal = 0
static

Definition at line 1975 of file validation.cpp.

◆ nTimeUndo

int64_t nTimeUndo = 0
static

Definition at line 1973 of file validation.cpp.

◆ nTimeVerify

int64_t nTimeVerify = 0
static

Definition at line 1972 of file validation.cpp.

◆ PRUNE_LOCK_BUFFER

constexpr int PRUNE_LOCK_BUFFER {10}
staticconstexpr

The number of blocks to keep below the deepest prune lock.

There is nothing special about this number. It is higher than what we expect to see in regular mainnet reorgs, but not so high that it would noticeably interfere with the pruning mechanism.

Definition at line 109 of file validation.cpp.

◆ scriptcheckqueue

CCheckQueue<CScriptCheck> scriptcheckqueue(128)
static
AssertLockHeld
AssertLockHeld(pool.cs)
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:121