Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | static bool FlushStateToDisk(CValidationState &state, FlushStateMode mode, | ||||
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 bool CheckInputs(const CTransaction &tx, CValidationState &state, | static bool CheckInputs(const CTransaction &tx, CValidationState &state, | ||||
const CCoinsViewCache &view, bool fScriptChecks, | const CCoinsViewCache &view, bool fScriptChecks, | ||||
uint32_t flags, bool cacheStore, | uint32_t flags, bool cacheStore, | ||||
const PrecomputedTransactionData &txdata, | const PrecomputedTransactionData &txdata, | ||||
std::vector<CScriptCheck> *pvChecks = nullptr); | std::vector<CScriptCheck> *pvChecks = nullptr); | ||||
static uint32_t GetBlockScriptFlags(const CBlockIndex *pindex, | |||||
const Config &config); | |||||
static bool IsFinalTx(const CTransaction &tx, int nBlockHeight, | static bool IsFinalTx(const CTransaction &tx, int nBlockHeight, | ||||
int64_t nBlockTime) { | int64_t nBlockTime) { | ||||
if (tx.nLockTime == 0) { | if (tx.nLockTime == 0) { | ||||
return true; | return true; | ||||
} | } | ||||
int64_t lockTime = tx.nLockTime; | int64_t lockTime = tx.nLockTime; | ||||
▲ Show 20 Lines • Show All 637 Lines • ▼ Show 20 Lines | // Check for conflicts with in-memory transactions | ||||
// prevent CPU exhaustion denial-of-service attacks. | // prevent CPU exhaustion denial-of-service attacks. | ||||
PrecomputedTransactionData txdata(tx); | PrecomputedTransactionData txdata(tx); | ||||
if (!CheckInputs(tx, state, view, true, scriptVerifyFlags, true, | if (!CheckInputs(tx, state, view, true, scriptVerifyFlags, true, | ||||
txdata)) { | txdata)) { | ||||
// State filled in by CheckInputs. | // State filled in by CheckInputs. | ||||
return false; | return false; | ||||
} | } | ||||
// Check again against just the consensus-critical mandatory script | // Check again against the current block tip's script verification flags | ||||
// verification flags, in case of bugs in the standard flags that cause | // to cache our script execution flags. This is, of course, useless if | ||||
// the next block has different script flags from the previous one, but | |||||
// because the cache tracks script flags for us it will auto-invalidate | |||||
// and we'll just have a few blocks of extra misses on soft-fork | |||||
// activation. | |||||
// | |||||
// This is also useful in case of bugs in the standard flags that cause | |||||
// 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 | // instance the STRICTENC flag was incorrectly allowing certain CHECKSIG | ||||
// 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, however allowing such transactions into the mempool | // invalid blocks (using TestBlockValidity), however allowing such | ||||
// can be exploited as a DoS attack. | // transactions into the mempool can be exploited as a DoS attack. | ||||
{ | uint32_t currentBlockScriptVerifyFlags = | ||||
GetBlockScriptFlags(chainActive.Tip(), config); | |||||
if (!CheckInputs(tx, state, view, true, currentBlockScriptVerifyFlags, | |||||
true, txdata)) { | |||||
// If we're using promiscuousmempoolflags, we may hit this normally. | |||||
// Check if current block has some flags that scriptVerifyFlags does | |||||
// not before printing an ominous warning. | |||||
if (!(~scriptVerifyFlags & currentBlockScriptVerifyFlags)) { | |||||
return error( | |||||
"%s: BUG! PLEASE REPORT THIS! ConnectInputs failed against " | |||||
"MANDATORY but not STANDARD flags %s, %s", | |||||
__func__, txid.ToString(), FormatStateMessage(state)); | |||||
} | |||||
if (!CheckInputs(tx, state, view, true, | if (!CheckInputs(tx, state, view, true, | ||||
MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata)) { | MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata)) { | ||||
return error( | return error( | ||||
"%s: BUG! PLEASE REPORT THIS! ConnectInputs failed " | "%s: ConnectInputs failed against MANDATORY but not " | ||||
"against MANDATORY but not STANDARD flags %s, %s", | "STANDARD flags due to promiscuous mempool %s, %s", | ||||
__func__, txid.ToString(), FormatStateMessage(state)); | __func__, txid.ToString(), FormatStateMessage(state)); | ||||
} | } | ||||
LogPrintf("Warning: -promiscuousmempool flags set to not include " | |||||
"currently enforced soft forks, this may break mining or " | |||||
"otherwise cause instability!\n"); | |||||
} | } | ||||
// This transaction should only count for fee estimation if | // This transaction should only count for fee estimation if | ||||
// the node is not behind and it is not dependent on any other | // the node is not behind and it is not dependent on any other | ||||
// transactions in the mempool. | // transactions in the mempool. | ||||
bool validForFeeEstimation = | bool validForFeeEstimation = | ||||
IsCurrentForFeeEstimation() && pool.HasNoInputsOf(tx); | IsCurrentForFeeEstimation() && pool.HasNoInputsOf(tx); | ||||
▲ Show 20 Lines • Show All 4,059 Lines • Show Last 20 Lines |