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 fn config(&self) -> &'config Config

Return a reference of the Config.

Source

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

Return a reference to the precompile set.

Source

pub 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 fn state(&self) -> &S

Source

pub 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. Panic if it results an empty substate stack.

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>)>, ) -> (ExitReason, Vec<u8>)

Execute a CALL transaction with a given caller, address, value and gas limit and data.

Takes in an additional access_list parameter for EIP-2930 which was introduced in the Ethereum Berlin hard fork. If you do not wish to use this functionality, just pass in an empty vector.

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.

Source

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

Get the create address from given scheme.

Source

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

Trait Implementations§

Source§

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

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 balance(&self, address: H160) -> U256

Get balance of address.
Source§

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

Get code size of address.
Source§

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

Get code hash of address.
Source§

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

Get code of address.
Source§

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

Get storage value of address at index.
Source§

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

Get transient storage value of address at index.
Source§

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

Get original storage value of address at index.
Source§

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

Check whether an address exists.
Source§

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

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.
Source§

fn set_transient_storage(&mut self, address: H160, index: H256, value: H256)

Set transient storage value of address at index, transient storage gets discarded after every transaction. (see EIP-1153)
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.
Source§

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

Mark an address to be deleted, with funds transferred to target.
Source§

fn create( &mut self, caller: H160, scheme: CreateScheme, value: U256, init_code: Vec<u8>, target_gas: Option<u64>, ) -> Capture<(ExitReason, Option<H160>, 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 pre_validate( &mut self, context: &Context, opcode: Opcode, stack: &Stack, ) -> Result<(), ExitError>

Pre-validation step for the runtime.
Source§

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

Records some associated ExternalOperation.
Source§

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

Feed in create feedback.
Source§

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

Feed in call feedback.
Source§

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

Handle other unknown external opcodes.

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

Source§

impl<T> JsonSchemaMaybe for T