Skip to content

Commit

Permalink
refactor: allow tracing program execution from a given starting state
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Dec 15, 2023
1 parent 4b31b2f commit 5f702d4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion triton-vm/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,19 @@ impl Program {
&self,
public_input: PublicInput,
non_determinism: NonDeterminism<BFieldElement>,
) -> Result<(AlgebraicExecutionTrace, Vec<BFieldElement>)> {
let state = VMState::new(self, public_input, non_determinism);
self.trace_execution_of_state(state)
}

/// Trace the execution of a [`Program`] from a given [`VMState`]. Consider using
/// [`trace_execution`][Self::trace_execution], unless you know this is what you want.
pub fn trace_execution_of_state(
&self,
mut state: VMState,
) -> Result<(AlgebraicExecutionTrace, Vec<BFieldElement>)> {
let mut aet = AlgebraicExecutionTrace::new(self.clone());
let mut state = VMState::new(self, public_input, non_determinism);
assert_eq!(self.instructions, state.program);
assert_eq!(self.len_bwords(), aet.instruction_multiplicities.len());

while !state.halting {
Expand Down

0 comments on commit 5f702d4

Please sign in to comment.