Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Wrap EvalScript in a ScriptExecution class #10729

Open
wants to merge 2 commits into
from

Conversation

Projects
None yet
4 participants
Member

luke-jr commented Jul 3, 2017

When we last discussed making scripts debuggable (sometime after #3901), the plan was to instead trace execution rather than single-step through it.

This is the first step toward that goal. The full implementation can be found on my script_debugger branch.

@fanquake fanquake added the Validation label Jul 3, 2017

src/script/interpreter.h
@@ -174,7 +174,34 @@ class MutableTransactionSignatureChecker : public TransactionSignatureChecker
MutableTransactionSignatureChecker(const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn) : TransactionSignatureChecker(&txTo, nInIn, amountIn), txTo(*txToIn) {}
};
-bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, SigVersion sigversion, ScriptError* error = NULL);
+class ScriptExecution {
@promag

promag Jul 4, 2017

Contributor

Nit,rename to ScriptExecuter?

@luke-jr

luke-jr Jul 4, 2017

Member

It can only execute a single script.

+ typedef std::vector<unsigned char> StackElementType;
+ typedef std::vector<StackElementType> StackType;
+
+ const CScript& script;
@promag

promag Jul 4, 2017

Contributor

Make these private?

@luke-jr

luke-jr Jul 4, 2017

Member

They are meant for external inspection.

@promag

promag Jul 4, 2017

Contributor

When that happens either make it public, create a getter or an Inspect method?

src/script/interpreter.h
+
+ ScriptExecution(StackType& stack, const CScript&, unsigned int flags, const BaseSignatureChecker&, SigVersion);
+
+ bool Eval(ScriptError* error = NULL);
@promag

promag Jul 4, 2017

Contributor

Rename to Execute?

src/script/interpreter.h
+
+inline bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, SigVersion sigversion, ScriptError* error = NULL)
+{
+ return ScriptExecution(stack, script, flags, checker, sigversion).Eval(error);
@promag

promag Jul 4, 2017

Contributor

Move stack to ::Eval() for the time being as this is an output (also remove stack member from class)?

@luke-jr

luke-jr Jul 4, 2017

Member

It's not only an output.

Member

luke-jr commented Sep 2, 2017

Rebased

Member

jtimon commented Sep 6, 2017

Concept ACK, will review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment