Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 308 Lines • ▼ Show 20 Lines | static bool FlushStateToDisk(const CChainParams &chainParams, | ||||
int nManualPruneHeight = 0); | int nManualPruneHeight = 0); | ||||
static void FindFilesToPruneManual(std::set<int> &setFilesToPrune, | static void FindFilesToPruneManual(std::set<int> &setFilesToPrune, | ||||
int nManualPruneHeight); | int nManualPruneHeight); | ||||
static void FindFilesToPrune(std::set<int> &setFilesToPrune, | static void FindFilesToPrune(std::set<int> &setFilesToPrune, | ||||
uint64_t nPruneAfterHeight); | uint64_t nPruneAfterHeight); | ||||
static FILE *OpenUndoFile(const FlatFilePos &pos, bool fReadOnly = false); | static FILE *OpenUndoFile(const FlatFilePos &pos, bool fReadOnly = false); | ||||
static FlatFileSeq BlockFileSeq(); | static FlatFileSeq BlockFileSeq(); | ||||
static FlatFileSeq UndoFileSeq(); | static FlatFileSeq UndoFileSeq(); | ||||
static uint32_t GetNextBlockScriptFlags(const Config &config, | static uint32_t GetNextBlockScriptFlags(const Consensus::Params ¶ms, | ||||
const CBlockIndex *pindex); | const CBlockIndex *pindex); | ||||
bool TestLockPointValidity(const LockPoints *lp) { | bool TestLockPointValidity(const LockPoints *lp) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
assert(lp); | assert(lp); | ||||
// If there are relative lock times then the maxInputBlock will be set | // If there are relative lock times then the maxInputBlock will be set | ||||
// If there are no relative lock times, the LockPoints don't depend on the | // If there are no relative lock times, the LockPoints don't depend on the | ||||
// chain | // chain | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
/** Convert CValidationState to a human-readable message for logging */ | /** Convert CValidationState to a human-readable message for logging */ | ||||
std::string FormatStateMessage(const CValidationState &state) { | std::string FormatStateMessage(const CValidationState &state) { | ||||
return strprintf( | return strprintf( | ||||
"%s%s (code %i)", state.GetRejectReason(), | "%s%s (code %i)", state.GetRejectReason(), | ||||
state.GetDebugMessage().empty() ? "" : ", " + state.GetDebugMessage(), | state.GetDebugMessage().empty() ? "" : ", " + state.GetDebugMessage(), | ||||
state.GetRejectCode()); | state.GetRejectCode()); | ||||
} | } | ||||
static bool IsMagneticAnomalyEnabledForCurrentBlock(const Config &config) { | static bool | ||||
IsMagneticAnomalyEnabledForCurrentBlock(const Consensus::Params ¶ms) { | |||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
return IsMagneticAnomalyEnabled(config, chainActive.Tip()); | return IsMagneticAnomalyEnabled(params, chainActive.Tip()); | ||||
} | } | ||||
static bool IsGravitonEnabledForCurrentBlock(const Config &config) { | static bool IsGravitonEnabledForCurrentBlock(const Consensus::Params ¶ms) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
return IsGravitonEnabled(config, chainActive.Tip()); | return IsGravitonEnabled(params, chainActive.Tip()); | ||||
} | } | ||||
// Command-line argument "-replayprotectionactivationtime=<timestamp>" will | // Command-line argument "-replayprotectionactivationtime=<timestamp>" will | ||||
// cause the node to switch to replay protected SigHash ForkID value when the | // cause the node to switch to replay protected SigHash ForkID value when the | ||||
// median timestamp of the previous 11 blocks is greater than or equal to | // median timestamp of the previous 11 blocks is greater than or equal to | ||||
// <timestamp>. Defaults to the pre-defined timestamp when not set. | // <timestamp>. Defaults to the pre-defined timestamp when not set. | ||||
static bool IsReplayProtectionEnabled(const Config &config, | static bool IsReplayProtectionEnabled(const Consensus::Params ¶ms, | ||||
int64_t nMedianTimePast) { | int64_t nMedianTimePast) { | ||||
return nMedianTimePast >= | return nMedianTimePast >= gArgs.GetArg("-replayprotectionactivationtime", | ||||
gArgs.GetArg( | params.phononActivationTime); | ||||
"-replayprotectionactivationtime", | |||||
config.GetChainParams().GetConsensus().phononActivationTime); | |||||
} | } | ||||
static bool IsReplayProtectionEnabled(const Config &config, | static bool IsReplayProtectionEnabled(const Consensus::Params ¶ms, | ||||
const CBlockIndex *pindexPrev) { | const CBlockIndex *pindexPrev) { | ||||
if (pindexPrev == nullptr) { | if (pindexPrev == nullptr) { | ||||
return false; | return false; | ||||
} | } | ||||
return IsReplayProtectionEnabled(config, pindexPrev->GetMedianTimePast()); | return IsReplayProtectionEnabled(params, pindexPrev->GetMedianTimePast()); | ||||
} | } | ||||
static bool IsReplayProtectionEnabledForCurrentBlock(const Config &config) { | static bool | ||||
IsReplayProtectionEnabledForCurrentBlock(const Consensus::Params ¶ms) { | |||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
return IsReplayProtectionEnabled(config, chainActive.Tip()); | return IsReplayProtectionEnabled(params, chainActive.Tip()); | ||||
} | } | ||||
// Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool | // Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool | ||||
// were somehow broken and returning the wrong scriptPubKeys | // were somehow broken and returning the wrong scriptPubKeys | ||||
static bool CheckInputsFromMempoolAndCache( | static bool CheckInputsFromMempoolAndCache( | ||||
const CTransaction &tx, CValidationState &state, | const CTransaction &tx, CValidationState &state, | ||||
const CCoinsViewCache &view, const CTxMemPool &pool, const uint32_t flags, | const CCoinsViewCache &view, const CTxMemPool &pool, const uint32_t flags, | ||||
bool cacheSigStore, PrecomputedTransactionData &txdata) { | bool cacheSigStore, PrecomputedTransactionData &txdata) { | ||||
Show All 34 Lines | |||||
static bool AcceptToMemoryPoolWorker( | static bool AcceptToMemoryPoolWorker( | ||||
const Config &config, CTxMemPool &pool, CValidationState &state, | const Config &config, CTxMemPool &pool, CValidationState &state, | ||||
const CTransactionRef &ptx, bool fLimitFree, bool *pfMissingInputs, | const CTransactionRef &ptx, bool fLimitFree, bool *pfMissingInputs, | ||||
int64_t nAcceptTime, bool fOverrideMempoolLimit, const Amount nAbsurdFee, | int64_t nAcceptTime, bool fOverrideMempoolLimit, const Amount nAbsurdFee, | ||||
std::vector<COutPoint> &coins_to_uncache, bool test_accept) { | std::vector<COutPoint> &coins_to_uncache, bool test_accept) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
const Consensus::Params &consensusParams = | |||||
config.GetChainParams().GetConsensus(); | |||||
const CTransaction &tx = *ptx; | const CTransaction &tx = *ptx; | ||||
const TxId txid = tx.GetId(); | const TxId txid = tx.GetId(); | ||||
// mempool "read lock" (held through | // mempool "read lock" (held through | ||||
// GetMainSignals().TransactionAddedToMempool()) | // GetMainSignals().TransactionAddedToMempool()) | ||||
LOCK(pool.cs); | LOCK(pool.cs); | ||||
if (pfMissingInputs) { | if (pfMissingInputs) { | ||||
*pfMissingInputs = false; | *pfMissingInputs = false; | ||||
▲ Show 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | for (const CTxIn &txin : tx.vin) { | ||||
entry, setAncestors, nLimitAncestors, nLimitAncestorSize, | entry, setAncestors, nLimitAncestors, nLimitAncestorSize, | ||||
nLimitDescendants, nLimitDescendantSize, errString)) { | nLimitDescendants, nLimitDescendantSize, errString)) { | ||||
return state.DoS(0, false, REJECT_NONSTANDARD, | return state.DoS(0, false, REJECT_NONSTANDARD, | ||||
"too-long-mempool-chain", false, errString); | "too-long-mempool-chain", false, errString); | ||||
} | } | ||||
// Set extraFlags as a set of flags that needs to be activated. | // Set extraFlags as a set of flags that needs to be activated. | ||||
uint32_t extraFlags = SCRIPT_VERIFY_NONE; | uint32_t extraFlags = SCRIPT_VERIFY_NONE; | ||||
if (IsReplayProtectionEnabledForCurrentBlock(config)) { | if (IsReplayProtectionEnabledForCurrentBlock(consensusParams)) { | ||||
extraFlags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | extraFlags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | ||||
} | } | ||||
if (IsMagneticAnomalyEnabledForCurrentBlock(config)) { | if (IsMagneticAnomalyEnabledForCurrentBlock(consensusParams)) { | ||||
extraFlags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; | extraFlags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; | ||||
} | } | ||||
if (IsGravitonEnabledForCurrentBlock(config)) { | if (IsGravitonEnabledForCurrentBlock(consensusParams)) { | ||||
extraFlags |= SCRIPT_ENABLE_SCHNORR_MULTISIG; | extraFlags |= SCRIPT_ENABLE_SCHNORR_MULTISIG; | ||||
extraFlags |= SCRIPT_VERIFY_MINIMALDATA; | extraFlags |= SCRIPT_VERIFY_MINIMALDATA; | ||||
} | } | ||||
// Make sure whatever we need to activate is actually activated. | // Make sure whatever we need to activate is actually activated. | ||||
const uint32_t scriptVerifyFlags = | const uint32_t scriptVerifyFlags = | ||||
STANDARD_SCRIPT_VERIFY_FLAGS | extraFlags; | STANDARD_SCRIPT_VERIFY_FLAGS | extraFlags; | ||||
Show All 13 Lines | for (const CTxIn &txin : tx.vin) { | ||||
// transactions to pass as valid when they're actually invalid. For | // transactions to pass as valid when they're actually invalid. For | ||||
// instance the STRICTENC flag was incorrectly allowing certain CHECKSIG | // instance the STRICTENC flag was incorrectly allowing certain CHECKSIG | ||||
// NOT scripts to pass, even though they were invalid. | // NOT scripts to pass, even though they were invalid. | ||||
// | // | ||||
// There is a similar check in CreateNewBlock() to prevent creating | // There is a similar check in CreateNewBlock() to prevent creating | ||||
// invalid blocks (using TestBlockValidity), however allowing such | // invalid blocks (using TestBlockValidity), however allowing such | ||||
// transactions into the mempool can be exploited as a DoS attack. | // transactions into the mempool can be exploited as a DoS attack. | ||||
uint32_t nextBlockScriptVerifyFlags = | uint32_t nextBlockScriptVerifyFlags = | ||||
GetNextBlockScriptFlags(config, chainActive.Tip()); | GetNextBlockScriptFlags(consensusParams, chainActive.Tip()); | ||||
if (!CheckInputsFromMempoolAndCache(tx, state, view, pool, | if (!CheckInputsFromMempoolAndCache(tx, state, view, pool, | ||||
nextBlockScriptVerifyFlags, true, | nextBlockScriptVerifyFlags, true, | ||||
txdata)) { | txdata)) { | ||||
return error("%s: BUG! PLEASE REPORT THIS! CheckInputs failed " | return error("%s: BUG! PLEASE REPORT THIS! CheckInputs failed " | ||||
"against next-block but not STANDARD flags %s, %s", | "against next-block but not STANDARD flags %s, %s", | ||||
__func__, txid.ToString(), FormatStateMessage(state)); | __func__, txid.ToString(), FormatStateMessage(state)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 776 Lines • ▼ Show 20 Lines | |||||
int32_t ComputeBlockVersion(const CBlockIndex *pindexPrev, | int32_t ComputeBlockVersion(const CBlockIndex *pindexPrev, | ||||
const Consensus::Params ¶ms) { | const Consensus::Params ¶ms) { | ||||
int32_t nVersion = VERSIONBITS_TOP_BITS; | int32_t nVersion = VERSIONBITS_TOP_BITS; | ||||
return nVersion; | return nVersion; | ||||
} | } | ||||
// Returns the script flags which should be checked for the block after | // Returns the script flags which should be checked for the block after | ||||
// the given block. | // the given block. | ||||
static uint32_t GetNextBlockScriptFlags(const Config &config, | static uint32_t GetNextBlockScriptFlags(const Consensus::Params ¶ms, | ||||
const CBlockIndex *pindex) { | const CBlockIndex *pindex) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
const Consensus::Params &consensusParams = | |||||
config.GetChainParams().GetConsensus(); | |||||
uint32_t flags = SCRIPT_VERIFY_NONE; | uint32_t flags = SCRIPT_VERIFY_NONE; | ||||
// Start enforcing P2SH (BIP16) | // Start enforcing P2SH (BIP16) | ||||
if ((pindex->nHeight + 1) >= consensusParams.BIP16Height) { | if ((pindex->nHeight + 1) >= params.BIP16Height) { | ||||
flags |= SCRIPT_VERIFY_P2SH; | flags |= SCRIPT_VERIFY_P2SH; | ||||
} | } | ||||
// Start enforcing the DERSIG (BIP66) rule. | // Start enforcing the DERSIG (BIP66) rule. | ||||
if ((pindex->nHeight + 1) >= consensusParams.BIP66Height) { | if ((pindex->nHeight + 1) >= params.BIP66Height) { | ||||
flags |= SCRIPT_VERIFY_DERSIG; | flags |= SCRIPT_VERIFY_DERSIG; | ||||
} | } | ||||
// Start enforcing CHECKLOCKTIMEVERIFY (BIP65) rule. | // Start enforcing CHECKLOCKTIMEVERIFY (BIP65) rule. | ||||
if ((pindex->nHeight + 1) >= consensusParams.BIP65Height) { | if ((pindex->nHeight + 1) >= params.BIP65Height) { | ||||
flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY; | flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY; | ||||
} | } | ||||
// Start enforcing CSV (BIP68, BIP112 and BIP113) rule. | // Start enforcing CSV (BIP68, BIP112 and BIP113) rule. | ||||
if ((pindex->nHeight + 1) >= consensusParams.CSVHeight) { | if ((pindex->nHeight + 1) >= params.CSVHeight) { | ||||
flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY; | flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY; | ||||
} | } | ||||
// If the UAHF is enabled, we start accepting replay protected txns | // If the UAHF is enabled, we start accepting replay protected txns | ||||
if (IsUAHFenabled(config, pindex)) { | if (IsUAHFenabled(params, pindex)) { | ||||
flags |= SCRIPT_VERIFY_STRICTENC; | flags |= SCRIPT_VERIFY_STRICTENC; | ||||
flags |= SCRIPT_ENABLE_SIGHASH_FORKID; | flags |= SCRIPT_ENABLE_SIGHASH_FORKID; | ||||
} | } | ||||
// If the DAA HF is enabled, we start rejecting transaction that use a high | // If the DAA HF is enabled, we start rejecting transaction that use a high | ||||
// s in their signature. We also make sure that signature that are supposed | // s in their signature. We also make sure that signature that are supposed | ||||
// to fail (for instance in multisig or other forms of smart contracts) are | // to fail (for instance in multisig or other forms of smart contracts) are | ||||
// null. | // null. | ||||
if (IsDAAEnabled(config, pindex)) { | if (IsDAAEnabled(params, pindex)) { | ||||
flags |= SCRIPT_VERIFY_LOW_S; | flags |= SCRIPT_VERIFY_LOW_S; | ||||
flags |= SCRIPT_VERIFY_NULLFAIL; | flags |= SCRIPT_VERIFY_NULLFAIL; | ||||
} | } | ||||
// When the magnetic anomaly fork is enabled, we start accepting | // When the magnetic anomaly fork is enabled, we start accepting | ||||
// transactions using the OP_CHECKDATASIG opcode and it's verify | // transactions using the OP_CHECKDATASIG opcode and it's verify | ||||
// alternative. We also start enforcing push only signatures and | // alternative. We also start enforcing push only signatures and | ||||
// clean stack. | // clean stack. | ||||
if (IsMagneticAnomalyEnabled(config, pindex)) { | if (IsMagneticAnomalyEnabled(params, pindex)) { | ||||
flags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; | flags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; | ||||
flags |= SCRIPT_VERIFY_SIGPUSHONLY; | flags |= SCRIPT_VERIFY_SIGPUSHONLY; | ||||
flags |= SCRIPT_VERIFY_CLEANSTACK; | flags |= SCRIPT_VERIFY_CLEANSTACK; | ||||
} | } | ||||
if (IsGravitonEnabled(config, pindex)) { | if (IsGravitonEnabled(params, pindex)) { | ||||
flags |= SCRIPT_ENABLE_SCHNORR_MULTISIG; | flags |= SCRIPT_ENABLE_SCHNORR_MULTISIG; | ||||
flags |= SCRIPT_VERIFY_MINIMALDATA; | flags |= SCRIPT_VERIFY_MINIMALDATA; | ||||
} | } | ||||
// We make sure this node will have replay protection during the next hard | // We make sure this node will have replay protection during the next hard | ||||
// fork. | // fork. | ||||
if (IsReplayProtectionEnabled(config, pindex)) { | if (IsReplayProtectionEnabled(params, pindex)) { | ||||
flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | ||||
} | } | ||||
return flags; | return flags; | ||||
} | } | ||||
static int64_t nTimeCheck = 0; | static int64_t nTimeCheck = 0; | ||||
static int64_t nTimeForks = 0; | static int64_t nTimeForks = 0; | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | bool CChainState::ConnectBlock(const Config &config, const CBlock &block, | ||||
} | } | ||||
// Start enforcing BIP68 (sequence locks). | // Start enforcing BIP68 (sequence locks). | ||||
int nLockTimeFlags = 0; | int nLockTimeFlags = 0; | ||||
if (pindex->nHeight >= consensusParams.CSVHeight) { | if (pindex->nHeight >= consensusParams.CSVHeight) { | ||||
nLockTimeFlags |= LOCKTIME_VERIFY_SEQUENCE; | nLockTimeFlags |= LOCKTIME_VERIFY_SEQUENCE; | ||||
} | } | ||||
const uint32_t flags = GetNextBlockScriptFlags(config, pindex->pprev); | const uint32_t flags = | ||||
GetNextBlockScriptFlags(consensusParams, pindex->pprev); | |||||
int64_t nTime2 = GetTimeMicros(); | int64_t nTime2 = GetTimeMicros(); | ||||
nTimeForks += nTime2 - nTime1; | nTimeForks += nTime2 - nTime1; | ||||
LogPrint(BCLog::BENCH, " - Fork checks: %.2fms [%.2fs (%.2fms/blk)]\n", | LogPrint(BCLog::BENCH, " - Fork checks: %.2fms [%.2fs (%.2fms/blk)]\n", | ||||
MILLI * (nTime2 - nTime1), nTimeForks * MICRO, | MILLI * (nTime2 - nTime1), nTimeForks * MICRO, | ||||
nTimeForks * MILLI / nBlocksTotal); | nTimeForks * MILLI / nBlocksTotal); | ||||
CBlockUndo blockundo; | CBlockUndo blockundo; | ||||
▲ Show 20 Lines • Show All 403 Lines • ▼ Show 20 Lines | LogPrint(BCLog::BENCH, "- Disconnect block: %.2fms\n", | ||||
(GetTimeMicros() - nStart) * MILLI); | (GetTimeMicros() - nStart) * MILLI); | ||||
// Write the chain state to disk, if necessary. | // Write the chain state to disk, if necessary. | ||||
if (!FlushStateToDisk(config.GetChainParams(), state, | if (!FlushStateToDisk(config.GetChainParams(), state, | ||||
FlushStateMode::IF_NEEDED)) { | FlushStateMode::IF_NEEDED)) { | ||||
return false; | return false; | ||||
} | } | ||||
const Consensus::Params &consensusParams = | |||||
config.GetChainParams().GetConsensus(); | |||||
// If this block is deactivating a fork, we move all mempool transactions | // If this block is deactivating a fork, we move all mempool transactions | ||||
// in front of disconnectpool for reprocessing in a future | // in front of disconnectpool for reprocessing in a future | ||||
// updateMempoolForReorg call | // updateMempoolForReorg call | ||||
if (pindexDelete->pprev != nullptr && | if (pindexDelete->pprev != nullptr && | ||||
GetNextBlockScriptFlags(config, pindexDelete) != | GetNextBlockScriptFlags(consensusParams, pindexDelete) != | ||||
GetNextBlockScriptFlags(config, pindexDelete->pprev)) { | GetNextBlockScriptFlags(consensusParams, pindexDelete->pprev)) { | ||||
LogPrint(BCLog::MEMPOOL, | LogPrint(BCLog::MEMPOOL, | ||||
"Disconnecting mempool due to rewind of upgrade block\n"); | "Disconnecting mempool due to rewind of upgrade block\n"); | ||||
if (disconnectpool) { | if (disconnectpool) { | ||||
disconnectpool->importMempool(g_mempool); | disconnectpool->importMempool(g_mempool); | ||||
} | } | ||||
g_mempool.clear(); | g_mempool.clear(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Lines | LogPrint(BCLog::BENCH, | ||||
" - Writing chainstate: %.2fms [%.2fs (%.2fms/blk)]\n", | " - Writing chainstate: %.2fms [%.2fs (%.2fms/blk)]\n", | ||||
(nTime5 - nTime4) * MILLI, nTimeChainState * MICRO, | (nTime5 - nTime4) * MILLI, nTimeChainState * MICRO, | ||||
nTimeChainState * MILLI / nBlocksTotal); | nTimeChainState * MILLI / nBlocksTotal); | ||||
// Remove conflicting transactions from the mempool.; | // Remove conflicting transactions from the mempool.; | ||||
g_mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight); | g_mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight); | ||||
disconnectpool.removeForBlock(blockConnecting.vtx); | disconnectpool.removeForBlock(blockConnecting.vtx); | ||||
const Consensus::Params &consensusParams = | |||||
config.GetChainParams().GetConsensus(); | |||||
// If this block is activating a fork, we move all mempool transactions | // If this block is activating a fork, we move all mempool transactions | ||||
// in front of disconnectpool for reprocessing in a future | // in front of disconnectpool for reprocessing in a future | ||||
// updateMempoolForReorg call | // updateMempoolForReorg call | ||||
if (pindexNew->pprev != nullptr && | if (pindexNew->pprev != nullptr && | ||||
GetNextBlockScriptFlags(config, pindexNew) != | GetNextBlockScriptFlags(consensusParams, pindexNew) != | ||||
GetNextBlockScriptFlags(config, pindexNew->pprev)) { | GetNextBlockScriptFlags(consensusParams, pindexNew->pprev)) { | ||||
LogPrint(BCLog::MEMPOOL, | LogPrint(BCLog::MEMPOOL, | ||||
"Disconnecting mempool due to acceptance of upgrade block\n"); | "Disconnecting mempool due to acceptance of upgrade block\n"); | ||||
disconnectpool.importMempool(g_mempool); | disconnectpool.importMempool(g_mempool); | ||||
} | } | ||||
// Update chainActive & related variables. | // Update chainActive & related variables. | ||||
chainActive.SetTip(pindexNew); | chainActive.SetTip(pindexNew); | ||||
UpdateTip(config, pindexNew); | UpdateTip(config, pindexNew); | ||||
▲ Show 20 Lines • Show All 1,168 Lines • ▼ Show 20 Lines | static bool ContextualCheckBlock(const Config &config, const CBlock &block, | ||||
const int64_t nMedianTimePast = | const int64_t nMedianTimePast = | ||||
pindexPrev == nullptr ? 0 : pindexPrev->GetMedianTimePast(); | pindexPrev == nullptr ? 0 : pindexPrev->GetMedianTimePast(); | ||||
const int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) | const int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) | ||||
? nMedianTimePast | ? nMedianTimePast | ||||
: block.GetBlockTime(); | : block.GetBlockTime(); | ||||
const bool fIsMagneticAnomalyEnabled = | const bool fIsMagneticAnomalyEnabled = | ||||
IsMagneticAnomalyEnabled(config, pindexPrev); | IsMagneticAnomalyEnabled(consensusParams, pindexPrev); | ||||
// Check that all transactions are finalized | // Check that all transactions are finalized | ||||
const CTransaction *prevTx = nullptr; | const CTransaction *prevTx = nullptr; | ||||
for (const auto &ptx : block.vtx) { | for (const auto &ptx : block.vtx) { | ||||
const CTransaction &tx = *ptx; | const CTransaction &tx = *ptx; | ||||
if (fIsMagneticAnomalyEnabled) { | if (fIsMagneticAnomalyEnabled) { | ||||
if (prevTx && (tx.GetId() <= prevTx->GetId())) { | if (prevTx && (tx.GetId() <= prevTx->GetId())) { | ||||
if (tx.GetId() == prevTx->GetId()) { | if (tx.GetId() == prevTx->GetId()) { | ||||
▲ Show 20 Lines • Show All 1,982 Lines • Show Last 20 Lines |