Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 1,080 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < tx.vin.size(); i++) { | ||||
// Compute flags without the optional standardness flags. | // Compute flags without the optional standardness flags. | ||||
// This differs from MANDATORY_SCRIPT_VERIFY_FLAGS as it contains | // This differs from MANDATORY_SCRIPT_VERIFY_FLAGS as it contains | ||||
// additional upgrade flags (see AcceptToMemoryPoolWorker variable | // additional upgrade flags (see AcceptToMemoryPoolWorker variable | ||||
// extraFlags). | // extraFlags). | ||||
uint32_t mandatoryFlags = | uint32_t mandatoryFlags = | ||||
flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS; | flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS; | ||||
if (flags != mandatoryFlags) { | if (flags != mandatoryFlags) { | ||||
// Check whether the failure was caused by a non-mandatory | // Check whether the failure was caused by a non-mandatory | ||||
// script verification check. If so, don't trigger DoS | // script verification check. If so, ensure we return | ||||
// protection to avoid splitting the network on the basis of | // NOT_STANDARD instead of CONSENSUS to avoid downstream users | ||||
// relay policy disagreements. | // splitting the network between upgraded and non-upgraded nodes | ||||
// by banning CONSENSUS-failing data providers. | |||||
CScriptCheck check2(scriptPubKey, amount, tx, i, mandatoryFlags, | CScriptCheck check2(scriptPubKey, amount, tx, i, mandatoryFlags, | ||||
sigCacheStore, txdata); | sigCacheStore, txdata); | ||||
if (check2()) { | if (check2()) { | ||||
return state.Invalid( | return state.Invalid( | ||||
ValidationInvalidReason::TX_NOT_STANDARD, false, | ValidationInvalidReason::TX_NOT_STANDARD, false, | ||||
REJECT_NONSTANDARD, | REJECT_NONSTANDARD, | ||||
strprintf("non-mandatory-script-verify-flag (%s)", | strprintf("non-mandatory-script-verify-flag (%s)", | ||||
ScriptErrorString(scriptError))); | ScriptErrorString(scriptError))); | ||||
} | } | ||||
// update the error message to reflect the mandatory violation. | // update the error message to reflect the mandatory violation. | ||||
scriptError = check2.GetScriptError(); | scriptError = check2.GetScriptError(); | ||||
} | } | ||||
// Failures of other flags indicate a transaction that is invalid in | // MANDATORY flag failures correspond to | ||||
// new blocks, e.g. a invalid P2SH. We DoS ban such nodes as they | // ValidationInvalidReason::CONSENSUS. Because CONSENSUS failures | ||||
// are not following the protocol. That said during an upgrade | // are the most serious case of validation failures, we may need to | ||||
// careful thought should be taken as to the correct behavior - we | // consider using RECENT_CONSENSUS_CHANGE for any script failure | ||||
// may want to continue peering with non-upgraded nodes even after | // that could be due to non-upgraded nodes which we may want to | ||||
// soft-fork super-majority signaling has occurred. | // support, to avoid splitting the network (but this depends on the | ||||
// details of how net_processing handles such errors). | |||||
return state.Invalid( | return state.Invalid( | ||||
ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, | ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, | ||||
strprintf("mandatory-script-verify-flag-failed (%s)", | strprintf("mandatory-script-verify-flag-failed (%s)", | ||||
ScriptErrorString(scriptError))); | ScriptErrorString(scriptError))); | ||||
} | } | ||||
nSigChecksTotal += check.GetScriptExecutionMetrics().nSigChecks; | nSigChecksTotal += check.GetScriptExecutionMetrics().nSigChecks; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 4,533 Lines • Show Last 20 Lines |