pub struct VMState {
pub program: Vec<Instruction>,
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: Vec<Instruction>The 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 read from using instruction divine_sibling.
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, 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
Since program is read-only across individual states, and multiple
inner helper functions refer to it, a read-only reference is kept in
the struct.
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[ip + 1] or program[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§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>,
source§impl PartialEq for VMState
impl PartialEq for VMState
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> 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