Bitcoin ABC  0.26.3
P2P Digital Currency
Classes | Macros | Functions | Variables
validation.cpp File Reference
#include <validation.h>
#include <arith_uint256.h>
#include <avalanche/avalanche.h>
#include <avalanche/processor.h>
#include <blockvalidity.h>
#include <chainparams.h>
#include <checkpoints.h>
#include <checkqueue.h>
#include <config.h>
#include <consensus/activation.h>
#include <consensus/amount.h>
#include <consensus/merkle.h>
#include <consensus/tx_check.h>
#include <consensus/tx_verify.h>
#include <consensus/validation.h>
#include <deploymentstatus.h>
#include <hash.h>
#include <index/blockfilterindex.h>
#include <logging.h>
#include <logging/timer.h>
#include <minerfund.h>
#include <node/blockstorage.h>
#include <node/coinstats.h>
#include <node/ui_interface.h>
#include <node/utxo_snapshot.h>
#include <policy/block/minerfund.h>
#include <policy/mempool.h>
#include <policy/policy.h>
#include <policy/settings.h>
#include <pow/pow.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <random.h>
#include <reverse_iterator.h>
#include <script/script.h>
#include <script/scriptcache.h>
#include <script/sigcache.h>
#include <shutdown.h>
#include <timedata.h>
#include <tinyformat.h>
#include <txdb.h>
#include <txmempool.h>
#include <undo.h>
#include <util/check.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/system.h>
#include <util/trace.h>
#include <util/translation.h>
#include <validationinterface.h>
#include <warnings.h>
#include <algorithm>
#include <atomic>
#include <deque>
#include <numeric>
#include <optional>
#include <string>
#include <thread>

Go to the source code of this file.

Classes

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

static uint32_t GetNextBlockScriptFlags (const Consensus::Params &params, const CBlockIndex *pindex)
 
bool CheckSequenceLocksAtTip (CBlockIndex *tip, const CCoinsView &coins_view, const CTransaction &tx, LockPoints *lp, bool useExistingLockPoints)
 Check if transaction will be BIP68 final in the next block to be created on top of tip. More...
 
static bool IsReplayProtectionEnabled (const Consensus::Params &params, int64_t nMedianTimePast)
 
static bool IsReplayProtectionEnabled (const Consensus::Params &params, const CBlockIndex *pindexPrev)
 
static bool CheckInputsFromMempoolAndCache (const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &view, const CTxMemPool &pool, const uint32_t flags, PrecomputedTransactionData &txdata, int &nSigChecksOut, 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, nSigChecksOut)
 
MempoolAcceptResult AcceptToMemoryPool (const Config &config, Chainstate &active_chainstate, const CTransactionRef &tx, int64_t accept_time, bool bypass_limits, bool test_accept, unsigned int heightOverride)
 Try to add a transaction to the mempool. More...
 
PackageMempoolAcceptResult ProcessNewPackage (const Config &config, Chainstate &active_chainstate, CTxMemPool &pool, const Package &package, bool test_accept)
 Validate (and maybe submit) a package to the mempool. More...
 
Amount GetBlockSubsidy (int nHeight, const Consensus::Params &consensusParams)
 
static void AlertNotify (const std::string &strMessage)
 
void SpendCoins (CCoinsViewCache &view, const CTransaction &tx, CTxUndo &txundo, int nHeight)
 Mark all the coins corresponding to a given transaction inputs as spent. More...
 
void UpdateCoins (CCoinsViewCache &view, const CTransaction &tx, CTxUndo &txundo, int nHeight)
 Apply the effects of this transaction on the UTXO set represented by view. More...
 
bool CheckInputScripts (const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &inputs, const uint32_t flags, bool sigCacheStore, bool scriptCacheStore, const PrecomputedTransactionData &txdata, int &nSigChecksOut, TxSigCheckLimiter &txLimitSigChecks, CheckInputsLimiter *pBlockLimitSigChecks, std::vector< CScriptCheck > *pvChecks)
 Check whether all of this transaction's input scripts succeed. More...
 
bool AbortNode (BlockValidationState &state, const std::string &strMessage, const bilingual_str &userMessage)
 
DisconnectResult UndoCoinSpend (const Coin &undo, CCoinsViewCache &view, const COutPoint &out)
 Restore the UTXO in a Coin at a given COutPoint. More...
 
DisconnectResult ApplyBlockUndo (const CBlockUndo &blockUndo, const CBlock &block, const CBlockIndex *pindex, CCoinsViewCache &view)
 Undo a block from the block and the undoblock data. 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 void UpdateTipLog (const CCoinsViewCache &coins_tip, const CBlockIndex *tip, const CChainParams &params, const std::string &func_name, const std::string &prefix) EXCLUSIVE_LOCKS_REQUIRED(
 
static SynchronizationState GetSynchronizationState (bool init)
 
static bool NotifyHeaderTip (Chainstate &chainstate) LOCKS_EXCLUDED(cs_main)
 
static void LimitValidationInterfaceQueue () LOCKS_EXCLUDED(cs_main)
 
static bool CheckBlockHeader (const CBlockHeader &block, BlockValidationState &state, const Consensus::Params &params, BlockValidationOptions validationOptions)
 Return true if the provided block header is valid. More...
 
bool CheckBlock (const CBlock &block, BlockValidationState &state, const Consensus::Params &params, BlockValidationOptions validationOptions)
 Functions for validating blocks and updating the block tree. More...
 
static bool ContextualCheckBlockHeader (const CChainParams &params, const CBlockHeader &block, BlockValidationState &state, BlockManager &blockman, const CBlockIndex *pindexPrev, int64_t nAdjustedTime) EXCLUSIVE_LOCKS_REQUIRED(
 Context-dependent validity checks. More...
 
bool ContextualCheckTransactionForCurrentBlock (const CBlockIndex *active_chain_tip, const Consensus::Params &params, const CTransaction &tx, TxValidationState &state)
 
static bool ContextualCheckBlock (const CBlock &block, BlockValidationState &state, const Consensus::Params &params, 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 &params, Chainstate &chainstate, const CBlock &block, CBlockIndex *pindexPrev, BlockValidationOptions validationOptions)
 
void PruneBlockFilesManual (Chainstate &active_chainstate, int nManualPruneHeight)
 Prune block files up to a given height. More...
 
bool LoadMempool (const Config &config, CTxMemPool &pool, Chainstate &active_chainstate)
 Load the mempool from disk. More...
 
bool DumpMempool (const CTxMemPool &pool)
 Dump the mempool to disk. 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 the chain's transaction count might be unset) This conditional lock requirement might be confusing, see: https://github.com/bitcoin/bitcoin/issues/15994. 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 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...
 
const std::vector< std::string > CHECKLEVEL_DOC
 Documentation for argument 'checklevel'. More...
 
RecursiveMutex cs_main
 Global state. More...
 
Mutex 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 fRequireStandard = true
 
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...
 
BlockHash 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...
 
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE_PER_KB)
 A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) More...
 
static bool pool cs
 
static CCheckQueue< CScriptCheckscriptcheckqueue (128)
 
static int64_t nTimeCheck = 0
 
static int64_t nTimeForks = 0
 
static int64_t nTimeVerify = 0
 
static int64_t nTimeConnect = 0
 
static int64_t nTimeIndex = 0
 
static int64_t nTimeTotal = 0
 
static int64_t nBlocksTotal = 0
 
static int64_t nTimeReadFromDisk = 0
 
static int64_t nTimeConnectTotal = 0
 
static int64_t nTimeFlush = 0
 
static int64_t nTimeChainState = 0
 
static int64_t nTimePostConnect = 0
 
static const uint64_t MEMPOOL_DUMP_VERSION = 1
 

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 1607 of file validation.cpp.

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

◆ AcceptToMemoryPool()

MempoolAcceptResult AcceptToMemoryPool ( const Config config,
Chainstate active_chainstate,
const CTransactionRef tx,
int64_t  accept_time,
bool  bypass_limits,
bool  test_accept = false,
unsigned int  heightOverride = 0 
)

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]configThe global configuration.
[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.
[in]heightOverrideOverride the block height of the transaction. Used only upon reorg.
Returns
a MempoolAcceptResult indicating whether the transaction was accepted/rejected with reason.

Definition at line 1163 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 1314 of file validation.cpp.

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

◆ ApplyBlockUndo()

DisconnectResult ApplyBlockUndo ( const CBlockUndo blockUndo,
const CBlock block,
const CBlockIndex pindex,
CCoinsViewCache coins 
)

Undo a block from the block and the undoblock data.

See DisconnectBlock for more details.

Definition at line 1668 of file validation.cpp.

Here is the call graph for this function:

◆ assert()

assert ( !tx.  IsCoinBase())

◆ AssertLockHeld()

AssertLockHeld ( pool.  cs)

◆ CheckBlock()

bool CheckBlock ( const CBlock block,
BlockValidationState state,
const Consensus::Params params,
BlockValidationOptions  validationOptions 
)

Functions for validating blocks and updating the block tree.

Context-independent validity checks.

Returns true if the provided block is valid (has valid header, transactions are valid, block is a valid size, etc.)

Definition at line 3835 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 params,
BlockValidationOptions  validationOptions 
)
static

Return true if the provided block header is valid.

Only verify PoW if blockValidationOptions is configured to do so. This allows validation of headers on which the PoW hasn't been done. For example: to validate template handed to mining software. Do not call this for any check that depends on the context. For context-dependent calls, see ContextualCheckBlockHeader.

Definition at line 3821 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 view,
const uint32_t  flags,
bool  sigCacheStore,
bool  scriptCacheStore,
const PrecomputedTransactionData txdata,
int &  nSigChecksOut,
TxSigCheckLimiter txLimitSigChecks,
CheckInputsLimiter pBlockLimitSigChecks,
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.

Upon success nSigChecksOut will be filled in with either:

  • correct total for all inputs, or,
  • 0, in the case when checks were pushed onto pvChecks (i.e., a cache miss with pvChecks non-null), in which case the total can be found by executing pvChecks and adding the results.

Setting sigCacheStore/scriptCacheStore 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.

pLimitSigChecks can be passed to limit the sigchecks count either in parallel or serial validation. With pvChecks null (serial validation), breaking the pLimitSigChecks limit will abort evaluation early and return false. With pvChecks not-null (parallel validation): the cached nSigChecks may itself break the limit in which case false is returned, OR, each entry in the returned pvChecks must be executed exactly once in order to probe the limit accurately.

Definition at line 1502 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  ,
nSigChecksOut   
)

◆ CheckInputsFromMempoolAndCache()

static bool CheckInputsFromMempoolAndCache ( const CTransaction tx,
TxValidationState state,
const CCoinsViewCache view,
const CTxMemPool pool,
const uint32_t  flags,
PrecomputedTransactionData txdata,
int &  nSigChecksOut,
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 = nullptr,
bool  useExistingLockPoints = false 
)

Check if transaction will be BIP68 final in the next block to be created on top of tip.

Parameters
[in]tipChain tip to check tx sequence locks against. For example, the tip of the current active chain.
[in]coins_viewAny CCoinsView that provides access to the relevant coins for checking sequence locks. For example, it can be a CCoinsViewCache that isn't connected to anything but contains all the relevant coins, or a CCoinsViewMemPool that is connected to the mempool and chainstate UTXO set. In the latter case, the caller is responsible for holding the appropriate locks to ensure that calls to GetCoin() return correct coins. Simulates calling SequenceLocks() with data from the tip passed in. Optionally stores in LockPoints the resulting height and time calculated and the hash of the block needed for calculation or skips the calculation and uses the LockPoints passed in for evaluation. The LockPoints should not be considered valid if CheckSequenceLocksAtTip returns false.

Definition at line 155 of file validation.cpp.

Here is the call graph for this function:

◆ ContextualCheckBlock()

static bool ContextualCheckBlock ( const CBlock block,
BlockValidationState state,
const Consensus::Params params,
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 4048 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 CChainParams params,
const CBlockHeader block,
BlockValidationState state,
BlockManager blockman,
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 3934 of file validation.cpp.

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

◆ ContextualCheckTransactionForCurrentBlock()

bool ContextualCheckTransactionForCurrentBlock ( const CBlockIndex active_chain_tip,
const Consensus::Params params,
const CTransaction tx,
TxValidationState state 
)

Definition at line 4013 of file validation.cpp.

Here is the call graph for this function:

◆ DumpMempool()

bool DumpMempool ( const CTxMemPool pool)

Dump the mempool to disk.

Definition at line 5731 of file validation.cpp.

Here is the call graph for this function:
Here is the caller 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 5868 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 5969 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 261 of file validation.cpp.

Here is the call graph for this function:

◆ GetBlockSubsidy()

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

Definition at line 1235 of file validation.cpp.

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

◆ GetNextBlockScriptFlags()

static uint32_t GetNextBlockScriptFlags ( const Consensus::Params params,
const CBlockIndex pindex 
)
static

Definition at line 1741 of file validation.cpp.

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

◆ GetSynchronizationState()

static SynchronizationState GetSynchronizationState ( bool  init)
static

Definition at line 3133 of file validation.cpp.

Here is the caller graph for this function:

◆ 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 the chain's transaction count might be unset) This conditional lock requirement might be confusing, see: https://github.com/bitcoin/bitcoin/issues/15994.

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

Definition at line 5801 of file validation.cpp.

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

◆ IsReplayProtectionEnabled() [1/2]

static bool IsReplayProtectionEnabled ( const Consensus::Params params,
const CBlockIndex pindexPrev 
)
static

Definition at line 238 of file validation.cpp.

Here is the call graph for this function:

◆ IsReplayProtectionEnabled() [2/2]

static bool IsReplayProtectionEnabled ( const Consensus::Params params,
int64_t  nMedianTimePast 
)
static

Definition at line 231 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 3167 of file validation.cpp.

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

◆ LoadMempool()

bool LoadMempool ( const Config config,
CTxMemPool pool,
Chainstate active_chainstate 
)

Load the mempool from disk.

Definition at line 5630 of file validation.cpp.

Here is the call graph for this function:

◆ NotifyHeaderTip()

static bool NotifyHeaderTip ( Chainstate chainstate)
static

Definition at line 3143 of file validation.cpp.

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

◆ ProcessNewPackage()

PackageMempoolAcceptResult ProcessNewPackage ( const Config config,
Chainstate 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 detailson 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 1199 of file validation.cpp.

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

◆ PruneBlockFilesManual()

void PruneBlockFilesManual ( Chainstate active_chainstate,
int  nManualPruneHeight 
)

Prune block files up to a given height.

Definition at line 4574 of file validation.cpp.

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

◆ SpendCoins()

void SpendCoins ( CCoinsViewCache view,
const CTransaction tx,
CTxUndo txundo,
int  nHeight 
)

Mark all the coins corresponding to a given transaction inputs as spent.

Definition at line 1460 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 1731 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 1735 of file validation.cpp.

Here is the caller graph for this function:

◆ TestBlockValidity()

bool TestBlockValidity ( BlockValidationState state,
const CChainParams params,
Chainstate chainstate,
const CBlock block,
CBlockIndex pindexPrev,
BlockValidationOptions  validationOptions 
)

Definition at line 4533 of file validation.cpp.

Here is the call graph for this function:

◆ UndoCoinSpend()

DisconnectResult UndoCoinSpend ( const 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

Definition at line 1614 of file validation.cpp.

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

◆ UpdateCoins()

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

Apply the effects of this transaction on the UTXO set represented by view.

Definition at line 1475 of file validation.cpp.

Here is the call 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 
)
static

Definition at line 2472 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 92 of file validation.cpp.

◆ cs

bool pool cs
Initial value:
{
RecursiveMutex cs_main
Global state.
Definition: validation.cpp:113
AssertLockHeld(pool.cs)

Definition at line 256 of file validation.cpp.

◆ cs_main

RecursiveMutex cs_main

Global state.

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 113 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 91 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 89 of file validation.cpp.

◆ fCheckBlockIndex

bool fCheckBlockIndex = false

Definition at line 119 of file validation.cpp.

◆ fCheckpointsEnabled

bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED

Definition at line 120 of file validation.cpp.

◆ fRequireStandard

bool fRequireStandard = true

Definition at line 118 of file validation.cpp.

◆ g_best_block

uint256 g_best_block

Used to notify getblocktemplate RPC of new tips.

Definition at line 117 of file validation.cpp.

◆ g_best_block_cv

std::condition_variable g_best_block_cv

Definition at line 116 of file validation.cpp.

◆ g_best_block_mutex

Mutex g_best_block_mutex

Definition at line 115 of file validation.cpp.

◆ hashAssumeValid

BlockHash hashAssumeValid

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

Definition at line 123 of file validation.cpp.

◆ MEMPOOL_DUMP_VERSION

const uint64_t MEMPOOL_DUMP_VERSION = 1
static

Definition at line 5628 of file validation.cpp.

◆ minRelayTxFee

A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)

Definition at line 126 of file validation.cpp.

◆ nBlocksTotal

int64_t nBlocksTotal = 0
static

Definition at line 1813 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 121 of file validation.cpp.

◆ nMinimumChainWork

arith_uint256 nMinimumChainWork

Minimum work we will assume exists on some valid chain.

Definition at line 124 of file validation.cpp.

◆ nTimeChainState

int64_t nTimeChainState = 0
static

Definition at line 2605 of file validation.cpp.

◆ nTimeCheck

int64_t nTimeCheck = 0
static

Definition at line 1807 of file validation.cpp.

◆ nTimeConnect

int64_t nTimeConnect = 0
static

Definition at line 1810 of file validation.cpp.

◆ nTimeConnectTotal

int64_t nTimeConnectTotal = 0
static

Definition at line 2603 of file validation.cpp.

◆ nTimeFlush

int64_t nTimeFlush = 0
static

Definition at line 2604 of file validation.cpp.

◆ nTimeForks

int64_t nTimeForks = 0
static

Definition at line 1808 of file validation.cpp.

◆ nTimeIndex

int64_t nTimeIndex = 0
static

Definition at line 1811 of file validation.cpp.

◆ nTimePostConnect

int64_t nTimePostConnect = 0
static

Definition at line 2606 of file validation.cpp.

◆ nTimeReadFromDisk

int64_t nTimeReadFromDisk = 0
static

Definition at line 2602 of file validation.cpp.

◆ nTimeTotal

int64_t nTimeTotal = 0
static

Definition at line 1812 of file validation.cpp.

◆ nTimeVerify

int64_t nTimeVerify = 0
static

Definition at line 1809 of file validation.cpp.

◆ scriptcheckqueue

CCheckQueue<CScriptCheck> scriptcheckqueue(128) ( 128  )
static