zcash_script/src
Greg Pfeil cc157ffdce
Add various stepwise functionality (#204)
* Move some constants in preparation

This makes some minor changes to constants to facilitate splitting out a
stepwise interpreter.

* Extract a step function from the interpreter

This is generally useful for testing, but specifically, we want to be
able to run this side-by-side with the C++ interpreter, and check that
every bit of our state matches along the way.

This change is as minimal as possible, to avoid divergence until after
it can be compared against C++. E.g., the massive `match opcode {…}`
block that has been moved should only change the dereferencing of
`op_count`.

* Add a `State` struct to make stepping easier

* Expose step interpreter

* Add a stepwise comparison interpreter

The C++ changes aren’t in place yet, so this is currently just an A/A test.

This changes our closures into structs containing a function, because
that’s how we can pass around functions with universally-quantified
lifetimes.

* Make interpreters more flexible

Previously the `ZcashScript` impls didn’t use `self`, so the types were
just tags. However, with the new `StepwiseInterpreter`, they need
`self`.

This also removes `RustInterpreter` in favor of a `rust_interpreter`
function that instantiates an appropriate `StepwiseInterpreter`.

* Add a function for C++/Rust comparison interpreter

* Fix fuzzer

* Clean up `use` in lib.rs

* Fix weird indentation

* Make various fields non-`pub`

* Add a `new` constructor for `Stack`

* Remove incorrect comment

* Appease Clippy

Adds `Default` impls for `Stack` and `State`.

* Rename `State::manual` to `State::from_parts`
2025-04-10 18:03:29 -03:00
..
external Initial Rust implementation (#174) 2025-01-29 19:31:52 -03:00
cxx.rs Expose `ScriptError` on C++ side (#195) 2025-02-11 11:22:52 -03:00
interpreter.rs Add various stepwise functionality (#204) 2025-04-10 18:03:29 -03:00
lib.rs Add various stepwise functionality (#204) 2025-04-10 18:03:29 -03:00
script.rs Add various stepwise functionality (#204) 2025-04-10 18:03:29 -03:00
script_error.rs Addressing post-hoc PR feedback on #174 (#197) 2025-02-25 13:49:54 -03:00
zcash_script.rs Add various stepwise functionality (#204) 2025-04-10 18:03:29 -03:00