HomePhabricator

[Iguana] Add `ScriptInterpreter` class, make `EvalScript` use it

Description

[Iguana] Add ScriptInterpreter class, make EvalScript use it

Summary:
In order to get a nice transaction debugger that allows users to step through individual opcodes, we need to split out the script execution code into a RunNextOp function, which then allows users to inspect the stack.

For that, introduce ScriptInterpreter, which simply contains all the state that would normally be in EvalScript, and add a few functions to interact with it, most importantly RunNextOp, which now contains one single execution of the next opcode.

EvalScript is then refactored to use ScriptInterpreter and calls RunNextOp in a loop.

There's no change in behavior.

NB: Curiously, removing two indents has the nice side effect that we also remove around 25 newlines when reformatting the interpreter code.

Depends on D16766.

Test Plan: ninja check && ninja check-functional

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D16733

Event Timeline