pub struct VMState {
pub program: Program,
pub public_input: VecDeque<BFieldElement>,
pub public_output: Vec<BFieldElement>,
pub secret_individual_tokens: VecDeque<BFieldElement>,
pub secret_digests: VecDeque<Digest>,
pub ram: HashMap<BFieldElement, BFieldElement>,
pub op_stack: OpStack,
pub jump_stack: Vec<(BFieldElement, BFieldElement)>,
pub cycle_count: u32,
pub instruction_pointer: usize,
pub sponge: Option<Tip5>,
pub halting: bool,
/* private fields */
}Fields§
§program: ProgramThe program memory stores the instructions (and their arguments) of the program currently being executed by Triton VM. It is read-only.
public_input: VecDeque<BFieldElement>A list of BFieldElements the program can read from using instruction
read_io.
public_output: Vec<BFieldElement>A list of BFieldElements the program can write to using instruction
write_io.
secret_individual_tokens: VecDeque<BFieldElement>A list of BFieldElements the program can read from using instruction
divine.
secret_digests: VecDeque<Digest>A list of Digests the program can use for instruction merkle_step.
ram: HashMap<BFieldElement, BFieldElement>The read-write random-access memory allows Triton VM to store arbitrary data.
op_stack: OpStackThe Op-stack memory stores Triton VM’s entire operational stack.
jump_stack: Vec<(BFieldElement, BFieldElement)>The Jump-stack memory stores the entire jump stack.
cycle_count: u32Number of cycles the program has been running for
instruction_pointer: usizeCurrent instruction’s address in program memory
sponge: Option<Tip5>The current state of the one, global Sponge that can be manipulated
using instructions SpongeInit, SpongeAbsorb,
SpongeAbsorbMem, and SpongeSqueeze.
Instruction SpongeInit resets the Sponge.
Note that this is the full state, including capacity. The capacity should never be exposed outside the VM.
halting: boolIndicates whether the terminating instruction halt has been executed.
Implementations§
Source§impl VMState
impl VMState
Sourcepub fn new(
program: Program,
public_input: PublicInput,
non_determinism: NonDeterminism,
) -> Self
pub fn new( program: Program, public_input: PublicInput, non_determinism: NonDeterminism, ) -> Self
Create initial VMState for a given program.
pub fn derive_helper_variables(&self) -> [BFieldElement; 6]
Sourcepub fn step(&mut self) -> Result<Vec<CoProcessorCall>, InstructionError>
pub fn step(&mut self) -> Result<Vec<CoProcessorCall>, InstructionError>
Perform the state transition as a mutable operation on self.
pub fn to_processor_row(&self) -> Array1<BFieldElement>
pub fn current_instruction(&self) -> Result<Instruction, InstructionError>
Sourcepub fn next_instruction(&self) -> Result<Instruction, InstructionError>
pub fn next_instruction(&self) -> Result<Instruction, InstructionError>
Return the next instruction on the tape, skipping arguments.
Note that this is not necessarily the next instruction to execute, since
the current instruction could be a jump, but it is either
program.instructions[ip + 1] or program.instructions[ip + 2],
depending on whether the current instruction takes an argument.
Sourcepub fn run(&mut self) -> Result<(), InstructionError>
pub fn run(&mut self) -> Result<(), InstructionError>
Run Triton VM on this state to completion, or until an error occurs.
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for VMState
impl<'arbitrary> Arbitrary<'arbitrary> for VMState
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for VMState
impl<'de> Deserialize<'de> for VMState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for VMState
impl StructuralPartialEq for VMState
Auto Trait Implementations§
impl Freeze for VMState
impl RefUnwindSafe for VMState
impl Send for VMState
impl Sync for VMState
impl Unpin for VMState
impl UnwindSafe for VMState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more