pub struct VirtualMachine<T, W> { /* private fields */ }Expand description
High-performance out-of-circuit EraVM implementation.
Implementations§
Source§impl<T: Tracer, W: World<T>> VirtualMachine<T, W>
impl<T: Tracer, W: World<T>> VirtualMachine<T, W>
Sourcepub fn new(
address: H160,
program: Program<T, W>,
caller: H160,
calldata: &[u8],
gas: u32,
settings: Settings,
) -> Self
pub fn new( address: H160, program: Program<T, W>, caller: H160, calldata: &[u8], gas: u32, settings: Settings, ) -> Self
Creates a new VM instance.
Sourcepub fn reserve_dynamic_heap_capacity(&mut self, n: usize)
pub fn reserve_dynamic_heap_capacity(&mut self, n: usize)
Pre-reserve dynamic heap-group capacity to suppress mid-execution
Vec doublings inside Heaps. Hint with the worst-case far-call
count estimable from the witness.
Sourcepub fn world_diff(&self) -> &WorldDiff
pub fn world_diff(&self) -> &WorldDiff
Provides a reference to the World diff accumulated by VM execution so far.
Sourcepub fn run(&mut self, world: &mut W, tracer: &mut T) -> ExecutionEnd
pub fn run(&mut self, world: &mut W, tracer: &mut T) -> ExecutionEnd
Sourcepub fn resume_with_additional_gas_limit(
&mut self,
world: &mut W,
tracer: &mut T,
gas_limit: u32,
) -> Option<(u32, ExecutionEnd)>
pub fn resume_with_additional_gas_limit( &mut self, world: &mut W, tracer: &mut T, gas_limit: u32, ) -> Option<(u32, ExecutionEnd)>
Returns how much of the extra gas limit is left and the stop reason, unless the extra gas limit was exceeded.
Needed to support account validation gas limit. We cannot simply reduce the available gas, as contracts might behave differently depending on remaining gas.
Sourcepub fn make_snapshot(&mut self)
pub fn make_snapshot(&mut self)
Creates a VM snapshot. The snapshot can then be rolled back to, or discarded.
§Panics
- Panics if called outside the initial (bootloader) callframe.
- Panics if this VM already has a snapshot.
Sourcepub fn rollback(&mut self)
pub fn rollback(&mut self)
Returns the VM to the state it was in when Self::make_snapshot() was called.
§Panics
- Panics if this VM doesn’t hold a snapshot.
- Panics if called outside the initial (bootloader) callframe.
Sourcepub fn pop_snapshot(&mut self)
pub fn pop_snapshot(&mut self)
Pops a previously made snapshot without rolling back to it. This effectively commits all changes made up to this point, so that they cannot be rolled back.
§Panics
- Panics if called outside the initial (bootloader) callframe.
Trait Implementations§
Source§impl<T: Tracer, W: World<T>> StateInterface for VirtualMachine<T, W>
impl<T: Tracer, W: World<T>> StateInterface for VirtualMachine<T, W>
Source§fn read_register(&self, register: u8) -> (U256, bool)
fn read_register(&self, register: u8) -> (U256, bool)
Source§fn set_register(&mut self, register: u8, value: U256, is_pointer: bool)
fn set_register(&mut self, register: u8, value: U256, is_pointer: bool)
Source§fn number_of_callframes(&self) -> usize
fn number_of_callframes(&self) -> usize
Source§fn current_frame(&mut self) -> impl CallframeInterface + '_
fn current_frame(&mut self) -> impl CallframeInterface + '_
Source§fn callframe(&mut self, n: usize) -> impl CallframeInterface + '_
fn callframe(&mut self, n: usize) -> impl CallframeInterface + '_
Source§fn read_heap_byte(&self, heap: HeapId, index: u32) -> u8
fn read_heap_byte(&self, heap: HeapId, index: u32) -> u8
Source§fn read_heap_u256(&self, heap: HeapId, index: u32) -> U256
fn read_heap_u256(&self, heap: HeapId, index: u32) -> U256
U256 word in the big-endian order from the specified heap / offset
(which is the index of the most significant byte of the read value).Source§fn write_heap_u256(&mut self, heap: HeapId, index: u32, value: U256)
fn write_heap_u256(&mut self, heap: HeapId, index: u32, value: U256)
U256 word in the big-endian order to the specified heap at the specified offset
(which is the index of the most significant byte of the written value).