Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | bool EvalScript(std::vector<valtype> &stack, const CScript &script, | ||||
valtype vchPushValue; | valtype vchPushValue; | ||||
std::vector<bool> vfExec; | std::vector<bool> vfExec; | ||||
std::vector<valtype> altstack; | std::vector<valtype> altstack; | ||||
set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); | set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); | ||||
if (script.size() > MAX_SCRIPT_SIZE) { | if (script.size() > MAX_SCRIPT_SIZE) { | ||||
return set_error(serror, SCRIPT_ERR_SCRIPT_SIZE); | return set_error(serror, SCRIPT_ERR_SCRIPT_SIZE); | ||||
} | } | ||||
int nOpCount = 0; | int nOpCount = 0; | ||||
bool fRequireMinimal = (flags & SCRIPT_VERIFY_MINIMALDATA) != 0; | bool fRequireMinimal = (flags & SCRIPT_VERIFY_MINIMALDATA) != 0; | ||||
deadalnix: What is the problem with using minimaldata, that already do what we are looking for ? | |||||
markblundebergAuthorUnsubmitted Done Inline ActionsMINIMALDATA is a different and much larger ruleset. It also has quite low test coverage (since it is only a standardness rule), so from what I can tell, many more tests would have to be added to make it consensus ready. MINIMALDATA does the following, very little of which is tested:
The proposed rule does the following:
See T667 markblundeberg: MINIMALDATA is a different and much larger ruleset. It also has quite low test coverage (since… | |||||
try { | try { | ||||
while (pc < pend) { | while (pc < pend) { | ||||
bool fExec = !count(vfExec.begin(), vfExec.end(), false); | bool fExec = !count(vfExec.begin(), vfExec.end(), false); | ||||
// | // | ||||
// Read instruction | // Read instruction | ||||
// | // | ||||
▲ Show 20 Lines • Show All 1,460 Lines • ▼ Show 20 Lines | bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, | ||||
// If FORKID is enabled, we also ensure strict encoding. | // If FORKID is enabled, we also ensure strict encoding. | ||||
if (flags & SCRIPT_ENABLE_SIGHASH_FORKID) { | if (flags & SCRIPT_ENABLE_SIGHASH_FORKID) { | ||||
flags |= SCRIPT_VERIFY_STRICTENC; | flags |= SCRIPT_VERIFY_STRICTENC; | ||||
} | } | ||||
if ((flags & SCRIPT_VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly()) { | if ((flags & SCRIPT_VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly()) { | ||||
return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); | return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); | ||||
} | } | ||||
if ((flags & SCRIPT_VERIFY_SCRIPTSIGMINPUSHONLY) != 0 && | |||||
!scriptSig.IsMinimalPushOnly()) { | |||||
return set_error(serror, SCRIPT_ERR_SCRIPTSIGMINPUSHONLY); | |||||
} | |||||
std::vector<valtype> stack, stackCopy; | std::vector<valtype> stack, stackCopy; | ||||
if (!EvalScript(stack, scriptSig, flags, checker, serror)) { | if (!EvalScript(stack, scriptSig, flags, checker, serror)) { | ||||
// serror is set | // serror is set | ||||
return false; | return false; | ||||
} | } | ||||
if (flags & SCRIPT_VERIFY_P2SH) { | if (flags & SCRIPT_VERIFY_P2SH) { | ||||
stackCopy = stack; | stackCopy = stack; | ||||
} | } | ||||
if (!EvalScript(stack, scriptPubKey, flags, checker, serror)) { | if (!EvalScript(stack, scriptPubKey, flags, checker, serror)) { | ||||
// serror is set | // serror is set | ||||
return false; | return false; | ||||
} | } | ||||
if (stack.empty()) { | if (stack.empty()) { | ||||
return set_error(serror, SCRIPT_ERR_EVAL_FALSE); | return set_error(serror, SCRIPT_ERR_EVAL_FALSE); | ||||
} | } | ||||
if (CastToBool(stack.back()) == false) { | if (CastToBool(stack.back()) == false) { | ||||
return set_error(serror, SCRIPT_ERR_EVAL_FALSE); | return set_error(serror, SCRIPT_ERR_EVAL_FALSE); | ||||
} | } | ||||
// Additional validation for spend-to-script-hash transactions: | // Additional validation for spend-to-script-hash transactions: | ||||
if ((flags & SCRIPT_VERIFY_P2SH) && scriptPubKey.IsPayToScriptHash()) { | if ((flags & SCRIPT_VERIFY_P2SH) && scriptPubKey.IsPayToScriptHash()) { | ||||
// scriptSig must be literals-only or validation fails | // scriptSig must be literals-only or validation fails | ||||
if (!scriptSig.IsPushOnly()) { | if (!scriptSig.IsPushOnly()) { | ||||
markblundebergAuthorUnsubmitted Done Inline ActionsSomething interesting: this has been redundant since November and we could remove it (or better -- comment out for posterity). markblundeberg: Something interesting: this has been redundant since November and we could remove it (or better… | |||||
deadalnixUnsubmitted Not Done Inline ActionsWe don't comment out for posterity. We have source control for posterity. deadalnix: We don't comment out for posterity. We have source control for posterity. | |||||
return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); | return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); | ||||
} | } | ||||
// Restore stack. | // Restore stack. | ||||
swap(stack, stackCopy); | swap(stack, stackCopy); | ||||
// stack cannot be empty here, because if it was the P2SH HASH <> EQUAL | // stack cannot be empty here, because if it was the P2SH HASH <> EQUAL | ||||
// scriptPubKey would be evaluated with an empty stack and the | // scriptPubKey would be evaluated with an empty stack and the | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |
What is the problem with using minimaldata, that already do what we are looking for ?