Trait zksync_vm2_interface::CallframeInterface

source ·
pub trait CallframeInterface {
Show 29 methods // Required methods fn address(&self) -> H160; fn set_address(&mut self, address: H160); fn code_address(&self) -> H160; fn set_code_address(&mut self, address: H160); fn caller(&self) -> H160; fn set_caller(&mut self, address: H160); fn program_counter(&self) -> Option<u16>; fn set_program_counter(&mut self, value: u16); fn exception_handler(&self) -> u16; fn set_exception_handler(&mut self, value: u16); fn is_static(&self) -> bool; fn is_kernel(&self) -> bool; fn gas(&self) -> u32; fn set_gas(&mut self, new_gas: u32); fn stipend(&self) -> u32; fn context_u128(&self) -> u128; fn set_context_u128(&mut self, value: u128); fn is_near_call(&self) -> bool; fn read_stack(&self, index: u16) -> (U256, bool); fn write_stack(&mut self, index: u16, value: U256, is_pointer: bool); fn stack_pointer(&self) -> u16; fn set_stack_pointer(&mut self, value: u16); fn heap(&self) -> HeapId; fn heap_bound(&self) -> u32; fn set_heap_bound(&mut self, value: u32); fn aux_heap(&self) -> HeapId; fn aux_heap_bound(&self) -> u32; fn set_aux_heap_bound(&mut self, value: u32); fn read_contract_code(&self, slot: u16) -> U256;
}
Expand description

Public interface of an EraVM call frame.

Required Methods§

source

fn address(&self) -> H160

Address of the storage context associated with this frame. For delegate calls, this address is inherited from the calling contract; otherwise, it’s the same as Self::code_address().

source

fn set_address(&mut self, address: H160)

Sets the address of the executing contract.

source

fn code_address(&self) -> H160

Address of the contract being executed.

source

fn set_code_address(&mut self, address: H160)

Sets the address of the contract being executed. Does not cause the contract at the specified address get loaded per se, just updates the value used internally by the VM (e.g., returned by the CodeAddress opcode).

source

fn caller(&self) -> H160

Address of the calling contract. Respects delegate and mimic calls.

source

fn set_caller(&mut self, address: H160)

Sets the address of the calling contract.

source

fn program_counter(&self) -> Option<u16>

Returns the current program counter (i.e., 0-based index of the instruction being executed). During panic this returns None.

source

fn set_program_counter(&mut self, value: u16)

Sets the program counter. The VM will execute an invalid instruction if you jump out of the program.

source

fn exception_handler(&self) -> u16

Returns the program counter that the parent frame should continue from if this frame fails.

source

fn set_exception_handler(&mut self, value: u16)

Sets the exception handler as specified above.

source

fn is_static(&self) -> bool

Checks whether the call is static.

source

fn is_kernel(&self) -> bool

Checks whether the call is executed in kernel mode.

source

fn gas(&self) -> u32

Returns the remaining amount of gas.

source

fn set_gas(&mut self, new_gas: u32)

Sets the remaining amount of gas.

source

fn stipend(&self) -> u32

Additional gas provided for the duration of this callframe.

source

fn context_u128(&self) -> u128

Returns the context value for this call. This context is accessible via ContextU128 opcode.

source

fn set_context_u128(&mut self, value: u128)

Sets the context value for this call.

source

fn is_near_call(&self) -> bool

Checks whether this frame corresponds to a near call.

source

fn read_stack(&self, index: u16) -> (U256, bool)

Reads the specified stack slot. Returns a value together with a pointer flag.

source

fn write_stack(&mut self, index: u16, value: U256, is_pointer: bool)

Sets the value and pointer flag for the specified stack slot.

source

fn stack_pointer(&self) -> u16

Returns the stack pointer.

source

fn set_stack_pointer(&mut self, value: u16)

Sets the stack pointer.

source

fn heap(&self) -> HeapId

Returns ID of the main heap used in this call.

source

fn heap_bound(&self) -> u32

Returns the main heap boundary (number of paid bytes).

source

fn set_heap_bound(&mut self, value: u32)

Sets the main heap boundary.

source

fn aux_heap(&self) -> HeapId

Returns ID of the auxiliary heap used in this call.

source

fn aux_heap_bound(&self) -> u32

Returns the auxiliary heap boundary (number of paid bytes).

source

fn set_aux_heap_bound(&mut self, value: u32)

Sets the auxiliary heap boundary.

source

fn read_contract_code(&self, slot: u16) -> U256

Reads a word from the bytecode of the executing contract.

Implementors§