Changeset View
Standalone View
src/script/interpreter.h
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | public: | ||||
bool CheckSequence(const CScriptNum &nSequence) const final override; | bool CheckSequence(const CScriptNum &nSequence) const final override; | ||||
}; | }; | ||||
using TransactionSignatureChecker = | using TransactionSignatureChecker = | ||||
GenericTransactionSignatureChecker<CTransaction>; | GenericTransactionSignatureChecker<CTransaction>; | ||||
using MutableTransactionSignatureChecker = | using MutableTransactionSignatureChecker = | ||||
GenericTransactionSignatureChecker<CMutableTransaction>; | GenericTransactionSignatureChecker<CMutableTransaction>; | ||||
/** Struct for holding cumulative results from executing a script or a sequence | |||||
* of scripts. | |||||
*/ | |||||
deadalnix: Fix comment formatting. | |||||
deadalnixUnsubmitted Done Inline Actions^ deadalnix: ^ | |||||
struct ScriptExecutionMetrics { | |||||
int nSigChecks = 0; | |||||
deadalnixUnsubmitted Done Inline ActionsDo you really expect negative number of sigops? The way I envision this is that you have 2 structs, one that collects the metric, with data private and that friend EvalScript. Then you get another struct, that has the same metrics, that has getter for them, and a public function to absorb the first struct. You'll have to get something like this at some point to aggregate a bunch of metrics from a bunch of scripts that run in parallel at some point. Maybe not strictly necessary for this patch, but think about it. Maybe ScriptMetricCollector and ScriptMetricAggregator or something like that. deadalnix: Do you really expect negative number of sigops?
The way I envision this is that you have 2… | |||||
markblundebergAuthorUnsubmitted Done Inline ActionsNo, but I do plan to do integer arithmetic (and not modulo arithmetic/bitwise manips) with the sigchecks count, and the common wisdom is that you don't use modulo ints ("unsigned") just because an arithmetical quantity is nonnegative. markblundeberg: No, but I do plan to do integer arithmetic (and not modulo arithmetic/bitwise manips) with the… | |||||
markblundebergAuthorUnsubmitted Done Inline ActionsFor aggregation, my plan is like so: A fresh ScriptExecutionMetrics is generated for every call to VerifyScript (i.e., a new one for every input and for every distinct set of flags). So, at first aggregation only happens across the sequential EvalScript calls that happen on the same stack. Each ScriptExecutionMetrics needs to be unshared and starts fresh for that input, so that any per-input limitations know what happened for that input specifically and separately. In CScriptChecks::operator(), once the VerifyScript is done it can then merge the per-input metrics into a coarser aggregator, which can be one of two types:
markblundeberg: For aggregation, my plan is like so:
A fresh `ScriptExecutionMetrics` is generated for every… | |||||
}; | |||||
bool EvalScript(std::vector<std::vector<uint8_t>> &stack, const CScript &script, | bool EvalScript(std::vector<std::vector<uint8_t>> &stack, const CScript &script, | ||||
uint32_t flags, const BaseSignatureChecker &checker, | uint32_t flags, const BaseSignatureChecker &checker, | ||||
ScriptError *error = nullptr); | ScriptError *error, ScriptExecutionMetrics &metrics); | ||||
deadalnixUnsubmitted Done Inline ActionsPlease reorder arguments such as the default value for serror can stay. Before or after checker seems like an appropriate place. deadalnix: Please reorder arguments such as the default value for serror can stay. Before or after checker… | |||||
static inline bool EvalScript(std::vector<std::vector<uint8_t>> &stack, | |||||
deadalnixUnsubmitted Done Inline ActionsYou don't need inline for static functions. deadalnix: You don't need inline for static functions. | |||||
markblundebergAuthorUnsubmitted Done Inline ActionsThat's true, it will compile, but I'd like to avoid gcc throwing up a bunch of warnings about unused function coming from this header when it's only static. markblundeberg: That's true, it will compile, but I'd like to avoid gcc throwing up a bunch of warnings about… | |||||
deadalnixUnsubmitted Done Inline ActionsFair enough :) deadalnix: Fair enough :) | |||||
const CScript &script, uint32_t flags, | |||||
const BaseSignatureChecker &checker, | |||||
ScriptError *error = nullptr) { | |||||
ScriptExecutionMetrics dummymetrics; | |||||
return EvalScript(stack, script, flags, checker, error, dummymetrics); | |||||
} | |||||
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, | bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, | ||||
uint32_t flags, const BaseSignatureChecker &checker, | uint32_t flags, const BaseSignatureChecker &checker, | ||||
ScriptError *serror = nullptr); | ScriptError *serror = nullptr); | ||||
int FindAndDelete(CScript &script, const CScript &b); | int FindAndDelete(CScript &script, const CScript &b); | ||||
#endif // BITCOIN_SCRIPT_INTERPRETER_H | #endif // BITCOIN_SCRIPT_INTERPRETER_H |
Fix comment formatting.