StackExecutor

Struct StackExecutor 

Source
pub struct StackExecutor<'config, 'precompiles, S, P> { /* private fields */ }
Expand description

Stack-based executor.

Implementations§

Source§

impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecutor<'config, 'precompiles, S, P>

Source

pub const fn config(&self) -> &'config Config

Return a reference of the Config.

Source

pub const fn precompiles(&self) -> &'precompiles P

Return a reference to the precompile set.

Source

pub const fn new_with_precompiles( state: S, config: &'config Config, precompile_set: &'precompiles P, ) -> Self

Create a new stack-based executor with given precompiles.

Source

pub const fn state(&self) -> &S

Source

pub const fn state_mut(&mut self) -> &mut S

Source

pub fn into_state(self) -> S

Source

pub fn enter_substate(&mut self, gas_limit: u64, is_static: bool)

Create a substate executor from the current executor.

Source

pub fn exit_substate(&mut self, kind: &StackExitKind) -> Result<(), ExitError>

Exit a substate.

§Panics

Panic occurs if a result is an empty substate stack.

§Errors

Return ExitError

Source

pub fn execute(&mut self, runtime: &mut Runtime) -> ExitReason

Execute the runtime until it returns.

Source

pub fn gas(&self) -> u64

Get remaining gas.

Source

pub fn transact_create( &mut self, caller: H160, value: U256, init_code: Vec<u8>, gas_limit: u64, access_list: Vec<(H160, Vec<H256>)>, ) -> (ExitReason, Vec<u8>)

Execute a CREATE transaction.

Source

pub fn transact_create2( &mut self, caller: H160, value: U256, init_code: Vec<u8>, salt: H256, gas_limit: u64, access_list: Vec<(H160, Vec<H256>)>, ) -> (ExitReason, Vec<u8>)

Execute a CREATE2 transaction.

Source

pub fn transact_call( &mut self, caller: H160, address: H160, value: U256, data: Vec<u8>, gas_limit: u64, access_list: Vec<(H160, Vec<H256>)>, authorization_list: Vec<Authorization>, ) -> (ExitReason, Vec<u8>)

Execute a CALL transaction with a given parameters

§Notes
Source

pub fn used_gas(&self) -> u64

Get used gas for the current executor, given the price.

Source

pub fn fee(&self, price: U256) -> U256

Get fee needed for the current executor, given the price.

Source

pub fn nonce(&self, address: H160) -> U256

Get account nonce. NOTE: we don’t need to cache it as by default it’s MemoryStackState with cache flow

Source

pub fn is_create_collision(&self, address: H160) -> bool

Check if the existing account is “create collision”. EIP-7610

Source

pub fn create_address(&self, scheme: CreateScheme) -> H160

Get the created address from given scheme.

Source

pub fn warm_access_list(&mut self, access_list: Vec<(H160, Vec<H256>)>)

According to EIP-2930 - access_list should be warmed. This function warms addresses and storage keys.

EIP-2930: Optional access lists

Trait Implementations§

Source§

impl<'config, S: StackState<'config>, P: PrecompileSet> Handler for StackExecutor<'config, '_, S, P>

Source§

fn balance(&self, address: H160) -> U256

Get account balance NOTE: we don’t need to cache it as by default it’s MemoryStackState with cache flow

Source§

fn code_size(&mut self, address: H160) -> U256

Fetch the code size of an address. Provide a default implementation by fetching the code.

According to EIP-7702, the code size of an address is the size of the delegated address code size. https://eips.ethereum.org/EIPS/eip-7702#delegation-designation

Source§

fn code_hash(&mut self, address: H160) -> H256

Fetch the code hash of an address. Provide a default implementation by fetching the code.

According to EIP-7702, the code hash of an address is the hash of the delegated address code hash. https://eips.ethereum.org/EIPS/eip-7702#delegation-designation

Source§

fn code(&self, address: H160) -> Vec<u8>

Get account code

Source§

fn storage(&self, address: H160, index: H256) -> H256

Get account storage by index

Source§

fn is_empty_storage(&self, address: H160) -> bool

Check is account storage empty

Source§

fn exists(&self, address: H160) -> bool

Check is account exists on backend side

Source§

fn mark_delete(&mut self, address: H160, target: H160) -> Result<(), ExitError>

Mark account as deleted

  • SELFDESTRUCT - CANCUN hard fork: EIP-6780
Source§

fn blob_base_fee(&self) -> Option<u128>

Returns None if Cancun hard fork is not enabled via has_blob_base_fee config.

[EIP-4844]: Shard Blob Transactions [EIP-7516]: BLOBBASEFEE instruction

Source§

fn get_authority_target(&mut self, address: H160) -> Option<H160>

Return the target address of the authority delegation designation (EIP-7702).

Source§

fn authority_code(&mut self, authority: H160) -> Vec<u8>

Get delegation designator code for the authority code. If the code of address is delegation designator, then retrieve code from the designation address for the authority. Detect delegated designation loop and return basic byte code for loop.

It’s related to EIP-7702 Delegation Designation When authority code is found, it should set delegated address to authority_access array for calculating additional gas cost. Gas must be charged for the authority address and for delegated address, for detection is address warm or cold.

Source§

type CreateInterrupt = StackExecutorCreateInterrupt<'static>

Type of CREATE interrupt.
Source§

type CreateFeedback = Infallible

Feedback value for CREATE interrupt.
Source§

type CallInterrupt = StackExecutorCallInterrupt<'static>

Type of CALL interrupt.
Source§

type CallFeedback = Infallible

Feedback value of CALL interrupt.
Source§

fn original_storage(&self, address: H160, index: H256) -> H256

Get original storage value of address at index.
Source§

fn is_cold(&mut self, address: H160, maybe_index: Option<H256>) -> bool

Checks if the address or (address, index) pair has been previously accessed (or set in accessed_addresses / accessed_storage_keys via an access list transaction). References: Read more
Source§

fn gas_left(&self) -> U256

Get the gas left value.
Source§

fn gas_price(&self) -> U256

Get the gas price value.
Source§

fn origin(&self) -> H160

Get execution origin.
Source§

fn block_hash(&self, number: U256) -> H256

Get environmental block hash.
Source§

fn block_number(&self) -> U256

Get environmental block number.
Source§

fn block_coinbase(&self) -> H160

Get environmental coinbase.
Source§

fn block_timestamp(&self) -> U256

Get environmental block timestamp.
Source§

fn block_difficulty(&self) -> U256

Get environmental block difficulty.
Source§

fn block_randomness(&self) -> Option<H256>

Get environmental block randomness.
Source§

fn block_gas_limit(&self) -> U256

Get environmental gas limit.
Source§

fn block_base_fee_per_gas(&self) -> U256

Environmental block base fee.
Source§

fn chain_id(&self) -> U256

Get environmental chain ID.
Source§

fn deleted(&self, address: H160) -> bool

Check whether an address has already been deleted.
Source§

fn set_storage( &mut self, address: H160, index: H256, value: H256, ) -> Result<(), ExitError>

Set storage value of address at index. Read more
Source§

fn log( &mut self, address: H160, topics: Vec<H256>, data: Vec<u8>, ) -> Result<(), ExitError>

Create a log owned by address with given topics and data. Read more
Source§

fn create( &mut self, caller: H160, scheme: CreateScheme, value: U256, init_code: Vec<u8>, target_gas: Option<u64>, ) -> Capture<(ExitReason, Vec<u8>), Self::CreateInterrupt>

Invoke a create operation.
Source§

fn call( &mut self, code_address: H160, transfer: Option<Transfer>, input: Vec<u8>, target_gas: Option<u64>, is_static: bool, context: Context, ) -> Capture<(ExitReason, Vec<u8>), Self::CallInterrupt>

Invoke a call operation.
Source§

fn record_external_operation( &mut self, op: ExternalOperation, ) -> Result<(), ExitError>

Records some associated ExternalOperation. Read more
Source§

fn get_blob_hash(&self, index: usize) -> Option<U256>

Get blob_hash from blob_versioned_hashes by index [EIP-4844]: BLOBHASH - https://eips.ethereum.org/EIPS/eip-4844#opcode-to-get-versioned-hashes
Source§

fn tstore( &mut self, address: H160, index: H256, value: U256, ) -> Result<(), ExitError>

Set tstorage value of address at index. [EIP-1153]: Transient storage Read more
Source§

fn tload(&mut self, address: H160, index: H256) -> Result<U256, ExitError>

Get tstorage value of address at index. [EIP-1153]: Transient storage Read more
Source§

fn warm_target(&mut self, target: (H160, Option<H256>))

Warm target according to EIP-2929
Source§

fn create_feedback( &mut self, _feedback: Self::CreateFeedback, ) -> Result<(), ExitError>

Feed in create feedback. Read more
Source§

fn call_feedback( &mut self, _feedback: Self::CallFeedback, ) -> Result<(), ExitError>

Feed in call feedback. Read more
Source§

fn other( &mut self, opcode: Opcode, _stack: &mut Machine, ) -> Result<(), ExitError>

Handle other unknown external opcodes. Read more
Source§

impl<'config, S: StackState<'config>, P: PrecompileSet> InterpreterHandler for StackExecutor<'config, '_, S, P>

Source§

fn before_bytecode( &mut self, opcode: Opcode, _pc: usize, machine: &Machine, address: &H160, ) -> Result<(), ExitError>

Errors Read more

Auto Trait Implementations§

§

impl<'config, 'precompiles, S, P> Freeze for StackExecutor<'config, 'precompiles, S, P>
where S: Freeze,

§

impl<'config, 'precompiles, S, P> RefUnwindSafe for StackExecutor<'config, 'precompiles, S, P>

§

impl<'config, 'precompiles, S, P> Send for StackExecutor<'config, 'precompiles, S, P>
where S: Send, P: Sync,

§

impl<'config, 'precompiles, S, P> Sync for StackExecutor<'config, 'precompiles, S, P>
where S: Sync, P: Sync,

§

impl<'config, 'precompiles, S, P> Unpin for StackExecutor<'config, 'precompiles, S, P>
where S: Unpin,

§

impl<'config, 'precompiles, S, P> UnwindSafe for StackExecutor<'config, 'precompiles, S, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V