pub struct CallFrame {Show 21 fields
pub gas_limit: u64,
pub gas_remaining: i64,
pub pc: usize,
pub msg_sender: Address,
pub to: Address,
pub code_address: Address,
pub bytecode: Code,
pub msg_value: U256,
pub stack: Stack,
pub memory: Memory,
pub calldata: Bytes,
pub output: Bytes,
pub sub_return_data: Bytes,
pub is_static: bool,
pub depth: usize,
pub is_create: bool,
pub call_frame_backup: CallFrameBackup,
pub ret_offset: usize,
pub ret_size: usize,
pub should_transfer_value: bool,
pub state_gas_used_at_entry: i64,
}Expand description
A call frame, or execution environment, is the context in which the EVM is currently executing. One context can trigger another with opcodes like CALL or CREATE. Call frames relationships can be thought of as a parent-child relation.
Fields§
§gas_limit: u64Max gas a callframe can use
gas_remaining: i64Keeps track of the remaining gas in the current context.
This is a i64 for performance reasons, to allow faster gas cost substraction and checks.
Additionally, gas limit won’t be a problem since https://eips.ethereum.org/EIPS/eip-7825 limits it to 2^24, which is lower than i64::MAX.
pc: usizeProgram Counter
msg_sender: AddressAddress of the account that sent the message
to: AddressAddress of the recipient of the message
code_address: AddressAddress of the code to execute. Usually the same as to, but can be different
bytecode: CodeBytecode to execute. Its hash field will be bogus for initcodes, as it is inaccessible to the VM unless associated to an account, which doesn’t happen for its initcode.
msg_value: U256Value sent along the transaction
stack: Stack§memory: Memory§calldata: BytesData sent along the transaction. Empty in CREATE transactions.
output: BytesReturn data of the CURRENT CONTEXT (see docs for more details)
sub_return_data: BytesReturn data of the SUB-CONTEXT (see docs for more details)
is_static: boolIndicates if current context is static (if it is, it can’t alter state)
depth: usizeCall stack current depth
is_create: boolThis is set to true if the function that created this callframe is CREATE or CREATE2
call_frame_backup: CallFrameBackupEverytime we want to write an account during execution of a callframe we store the pre-write state so that we can restore if it reverts
ret_offset: usizeReturn data offset
ret_size: usizeReturn data size
should_transfer_value: boolIf true then transfer value from caller to callee
state_gas_used_at_entry: i64EIP-8037: snapshot of VM.state_gas_used (signed) at child-frame entry. Used to restore parent’s state_gas_used on child revert.
Implementations§
Source§impl CallFrame
impl CallFrame
pub fn new( msg_sender: Address, to: Address, code_address: Address, bytecode: Code, msg_value: U256, calldata: Bytes, is_static: bool, gas_limit: u64, depth: usize, should_transfer_value: bool, is_create: bool, ret_offset: usize, ret_size: usize, stack: Stack, memory: Memory, ) -> Self
pub fn next_opcode(&self) -> u8
pub fn pc(&self) -> usize
Sourcepub fn increase_consumed_gas(&mut self, gas: u64) -> Result<(), ExceptionalHalt>
pub fn increase_consumed_gas(&mut self, gas: u64) -> Result<(), ExceptionalHalt>
Increases gas consumption of CallFrame and Environment, returning an error if the callframe gas limit is reached.
Sourcepub fn check_gas(&self, gas: u64) -> Result<(), ExceptionalHalt>
pub fn check_gas(&self, gas: u64) -> Result<(), ExceptionalHalt>
EELS’ check_gas: assert gas is available without consuming it.
pub fn set_code(&mut self, code: Code) -> Result<(), VMError>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CallFrame
impl !RefUnwindSafe for CallFrame
impl !Send for CallFrame
impl !Sync for CallFrame
impl !UnwindSafe for CallFrame
impl Unpin for CallFrame
impl UnsafeUnpin for CallFrame
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.