Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 713 Lines • ▼ Show 20 Lines | for (const CTxIn &txin : tx.vin) { | ||||
extraFlags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | extraFlags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | ||||
} | } | ||||
if (IsMagneticAnomalyEnabledForCurrentBlock(config)) { | if (IsMagneticAnomalyEnabledForCurrentBlock(config)) { | ||||
extraFlags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; | extraFlags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; | ||||
} | } | ||||
if (IsGreatWallEnabledForCurrentBlock(config)) { | if (IsGreatWallEnabledForCurrentBlock(config)) { | ||||
if (!fRequireStandard) { | if (fRequireStandard) { | ||||
extraFlags |= SCRIPT_ALLOW_SEGWIT_RECOVERY; | extraFlags |= SCRIPT_DISALLOW_SEGWIT_RECOVERY; | ||||
} | } | ||||
extraFlags |= SCRIPT_ENABLE_SCHNORR; | extraFlags |= SCRIPT_ENABLE_SCHNORR; | ||||
} else { | |||||
extraFlags |= SCRIPT_DISALLOW_SEGWIT_RECOVERY; | |||||
deadalnix: Make it a standard flag. | |||||
MengerianAuthorUnsubmitted Done Inline ActionsThe issue with this is that adding it to standard flags would change the behavior of the code. The goal of this Diff is to change the meaning of the flag without changing behavior. Mengerian: The issue with this is that adding it to standard flags would change the behavior of the code. | |||||
} | } | ||||
// 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; | ||||
// Check against previous transactions. This is done last to help | // Check against previous transactions. This is done last to help | ||||
// prevent CPU exhaustion denial-of-service attacks. | // prevent CPU exhaustion denial-of-service attacks. | ||||
▲ Show 20 Lines • Show All 499 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < tx.vin.size(); i++) { | ||||
txdata); | txdata); | ||||
if (pvChecks) { | if (pvChecks) { | ||||
pvChecks->push_back(std::move(check)); | pvChecks->push_back(std::move(check)); | ||||
} else if (!check()) { | } else if (!check()) { | ||||
// 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). | ||||
// Even though it is not a mandatory flag, | // Although it is not (currently) a standard flag, | ||||
// SCRIPT_ALLOW_SEGWIT_RECOVERY is strictly more permissive than the | // SCRIPT_ALLOW_SEGWIT_RECOVERY is treated similarly to the | ||||
// set of standard flags. It therefore needs to be added in order to | // set of standard-not-mandatory flags. It needs to be removed in | ||||
// check if we need to penalize the peer that sent us the | // order to check if we need to penalize, but not ban, the peer that | ||||
// transaction or not. | // sent us the transaction. | ||||
uint32_t mandatoryFlags = | uint32_t mandatoryFlags = flags & | ||||
(flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS) | | ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS & | ||||
SCRIPT_ALLOW_SEGWIT_RECOVERY; | ~SCRIPT_DISALLOW_SEGWIT_RECOVERY; | ||||
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, don't trigger DoS | ||||
// protection to avoid splitting the network on the basis of | // protection to avoid splitting the network on the basis of | ||||
// relay policy disagreements. | // relay policy disagreements. | ||||
CScriptCheck check2(scriptPubKey, amount, tx, i, mandatoryFlags, | CScriptCheck check2(scriptPubKey, amount, tx, i, mandatoryFlags, | ||||
sigCacheStore, txdata); | sigCacheStore, txdata); | ||||
if (check2()) { | if (check2()) { | ||||
▲ Show 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | static uint32_t GetBlockScriptFlags(const Config &config, | ||||
} | } | ||||
// If the Great Wall fork is enabled, we start accepting transactions | // If the Great Wall fork is enabled, we start accepting transactions | ||||
// recovering coins sent to segwit addresses. We also start accepting | // recovering coins sent to segwit addresses. We also start accepting | ||||
// 65/64-byte Schnorr signatures in CHECKSIG and CHECKDATASIG respectively, | // 65/64-byte Schnorr signatures in CHECKSIG and CHECKDATASIG respectively, | ||||
// and their verify variants. We also stop accepting 65 byte signatures in | // and their verify variants. We also stop accepting 65 byte signatures in | ||||
// CHECKMULTISIG and its verify variant. | // CHECKMULTISIG and its verify variant. | ||||
if (IsGreatWallEnabled(config, pChainTip)) { | if (IsGreatWallEnabled(config, pChainTip)) { | ||||
flags |= SCRIPT_ALLOW_SEGWIT_RECOVERY; | |||||
flags |= SCRIPT_ENABLE_SCHNORR; | flags |= SCRIPT_ENABLE_SCHNORR; | ||||
} else { | |||||
flags |= SCRIPT_DISALLOW_SEGWIT_RECOVERY; | |||||
deadalnixUnsubmitted Not Done Inline ActionsThe whole point is to simplify, not to add new codepath. And incidentally, if you add new codepath, there should be new tests. It's more robust to enable the flag no matter what, and then disable it when the fork is activated. deadalnix: The whole point is to simplify, not to add new codepath. And incidentally, if you add new… | |||||
} | } | ||||
// 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; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 4,013 Lines • Show Last 20 Lines |
Make it a standard flag.