Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 997 Lines • ▼ Show 20 Lines | // Check for conflicts with in-memory transactions | ||||
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 (IsMonolithEnabled(config, chainActive.Tip())) { | |||||
extraFlags |= SCRIPT_ENABLE_MONOLITH_OPCODES; | |||||
} | |||||
if (IsReplayProtectionEnabledForCurrentBlock(config)) { | if (IsReplayProtectionEnabledForCurrentBlock(config)) { | ||||
extraFlags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | extraFlags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | ||||
} | } | ||||
// Check inputs based on the set of flags we activate. | // Check inputs based on the set of flags we activate. | ||||
uint32_t scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS; | uint32_t scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS; | ||||
if (!config.GetChainParams().RequireStandard()) { | if (!config.GetChainParams().RequireStandard()) { | ||||
scriptVerifyFlags = | scriptVerifyFlags = | ||||
▲ Show 20 Lines • Show All 583 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < tx.vin.size(); i++) { | ||||
// Verify signature | // Verify signature | ||||
CScriptCheck check(scriptPubKey, amount, tx, i, flags, sigCacheStore, | CScriptCheck check(scriptPubKey, amount, tx, i, flags, sigCacheStore, | ||||
txdata); | txdata); | ||||
if (pvChecks) { | if (pvChecks) { | ||||
pvChecks->push_back(std::move(check)); | pvChecks->push_back(std::move(check)); | ||||
} else if (!check()) { | } else if (!check()) { | ||||
const bool hasNonMandatoryFlags = | const bool hasNonMandatoryFlags = | ||||
(flags & STANDARD_NOT_MANDATORY_VERIFY_FLAGS) != 0; | (flags & STANDARD_NOT_MANDATORY_VERIFY_FLAGS) != 0; | ||||
const bool doesNotHaveMonolith = | if (hasNonMandatoryFlags) { | ||||
(flags & SCRIPT_ENABLE_MONOLITH_OPCODES) == 0; | |||||
if (hasNonMandatoryFlags || doesNotHaveMonolith) { | |||||
// Check whether the failure was caused by a non-mandatory | // Check whether the failure was caused by a non-mandatory | ||||
// script verification check, such as non-standard DER encodings | // script verification check, such as non-standard DER encodings | ||||
// or non-null dummy arguments; if so, don't trigger DoS | // or non-null dummy arguments; if so, don't trigger DoS | ||||
// protection to avoid splitting the network between upgraded | // protection to avoid splitting the network between upgraded | ||||
// and non-upgraded nodes. | // and non-upgraded nodes. | ||||
// | // | ||||
// We also check activating the monolith opcodes as it is a | // We also check activating the monolith opcodes as it is a | ||||
// strictly additive change and we would not like to ban some of | // strictly additive change and we would not like to ban some of | ||||
// our peer that are ahead of us and are considering the fork | // our peer that are ahead of us and are considering the fork | ||||
// as activated. | // as activated. | ||||
CScriptCheck check2( | CScriptCheck check2(scriptPubKey, amount, tx, i, | ||||
scriptPubKey, amount, tx, i, | flags & | ||||
(flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS) | | ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS, | ||||
SCRIPT_ENABLE_MONOLITH_OPCODES, | |||||
sigCacheStore, txdata); | sigCacheStore, txdata); | ||||
if (check2()) { | if (check2()) { | ||||
return state.Invalid( | return state.Invalid( | ||||
false, REJECT_NONSTANDARD, | false, REJECT_NONSTANDARD, | ||||
strprintf("non-mandatory-script-verify-flag (%s)", | strprintf("non-mandatory-script-verify-flag (%s)", | ||||
ScriptErrorString(check.GetScriptError()))); | ScriptErrorString(check.GetScriptError()))); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 350 Lines • ▼ Show 20 Lines | static uint32_t GetBlockScriptFlags(const Config &config, | ||||
// 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, pChainTip)) { | if (IsDAAEnabled(config, pChainTip)) { | ||||
flags |= SCRIPT_VERIFY_LOW_S; | flags |= SCRIPT_VERIFY_LOW_S; | ||||
flags |= SCRIPT_VERIFY_NULLFAIL; | flags |= SCRIPT_VERIFY_NULLFAIL; | ||||
} | } | ||||
// The monolith HF enable a set of opcodes. | |||||
if (IsMonolithEnabled(config, pChainTip)) { | |||||
flags |= SCRIPT_ENABLE_MONOLITH_OPCODES; | |||||
} | |||||
// 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, pChainTip)) { | if (IsReplayProtectionEnabled(config, pChainTip)) { | ||||
flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | ||||
} | } | ||||
return flags; | return flags; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 3,527 Lines • Show Last 20 Lines |