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>
impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecutor<'config, 'precompiles, S, P>
Sourcepub const fn precompiles(&self) -> &'precompiles P
pub const fn precompiles(&self) -> &'precompiles P
Return a reference to the precompile set.
Sourcepub const fn new_with_precompiles(
state: S,
config: &'config Config,
precompile_set: &'precompiles P,
) -> Self
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.
pub const fn state(&self) -> &S
pub const fn state_mut(&mut self) -> &mut S
pub fn into_state(self) -> S
Sourcepub fn enter_substate(&mut self, gas_limit: u64, is_static: bool)
pub fn enter_substate(&mut self, gas_limit: u64, is_static: bool)
Create a substate executor from the current executor.
Sourcepub fn exit_substate(&mut self, kind: &StackExitKind) -> Result<(), ExitError>
pub fn exit_substate(&mut self, kind: &StackExitKind) -> Result<(), ExitError>
Sourcepub fn execute(&mut self, runtime: &mut Runtime) -> ExitReason
pub fn execute(&mut self, runtime: &mut Runtime) -> ExitReason
Execute the runtime until it returns.
Sourcepub 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>)
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.
Sourcepub 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>)
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.
Sourcepub 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>)
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
access_listassociated to EIP-2930: Optional access listsauthorization_listassociated to EIP-7702: Authorized accounts
Sourcepub fn fee(&self, price: U256) -> U256
pub fn fee(&self, price: U256) -> U256
Get fee needed for the current executor, given the price.
Sourcepub fn nonce(&self, address: H160) -> U256
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
Sourcepub fn is_create_collision(&self, address: H160) -> bool
pub fn is_create_collision(&self, address: H160) -> bool
Check if the existing account is “create collision”. EIP-7610
Sourcepub fn create_address(&self, scheme: CreateScheme) -> H160
pub fn create_address(&self, scheme: CreateScheme) -> H160
Get the created address from given scheme.
Trait Implementations§
Source§impl<'config, S: StackState<'config>, P: PrecompileSet> Handler for StackExecutor<'config, '_, S, P>
impl<'config, S: StackState<'config>, P: PrecompileSet> Handler for StackExecutor<'config, '_, S, P>
Source§fn balance(&self, address: H160) -> U256
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
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
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 is_empty_storage(&self, address: H160) -> bool
fn is_empty_storage(&self, address: H160) -> bool
Check is account storage empty
Source§fn mark_delete(&mut self, address: H160, target: H160) -> Result<(), ExitError>
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>
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
Return the target address of the authority delegation designation (EIP-7702).
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 CreateInterrupt = StackExecutorCreateInterrupt<'static>
CREATE interrupt.Source§type CreateFeedback = Infallible
type CreateFeedback = Infallible
CREATE interrupt.Source§type CallInterrupt = StackExecutorCallInterrupt<'static>
type CallInterrupt = StackExecutorCallInterrupt<'static>
CALL interrupt.Source§type CallFeedback = Infallible
type CallFeedback = Infallible
CALL interrupt.Source§fn original_storage(&self, address: H160, index: H256) -> H256
fn original_storage(&self, address: H160, index: H256) -> H256
Source§fn is_cold(&mut self, address: H160, maybe_index: Option<H256>) -> bool
fn is_cold(&mut self, address: H160, maybe_index: Option<H256>) -> bool
accessed_addresses / accessed_storage_keys via an access list
transaction).
References: Read moreSource§fn block_hash(&self, number: U256) -> H256
fn block_hash(&self, number: U256) -> H256
Source§fn block_number(&self) -> U256
fn block_number(&self) -> U256
Source§fn block_coinbase(&self) -> H160
fn block_coinbase(&self) -> H160
Source§fn block_timestamp(&self) -> U256
fn block_timestamp(&self) -> U256
Source§fn block_difficulty(&self) -> U256
fn block_difficulty(&self) -> U256
Source§fn block_randomness(&self) -> Option<H256>
fn block_randomness(&self) -> Option<H256>
Source§fn block_gas_limit(&self) -> U256
fn block_gas_limit(&self) -> U256
Source§fn block_base_fee_per_gas(&self) -> U256
fn block_base_fee_per_gas(&self) -> U256
Source§fn set_storage(
&mut self,
address: H160,
index: H256,
value: H256,
) -> Result<(), ExitError>
fn set_storage( &mut self, address: H160, index: H256, value: H256, ) -> Result<(), ExitError>
Source§fn log(
&mut self,
address: H160,
topics: Vec<H256>,
data: Vec<u8>,
) -> Result<(), ExitError>
fn log( &mut self, address: H160, topics: Vec<H256>, data: Vec<u8>, ) -> Result<(), ExitError>
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>
fn create( &mut self, caller: H160, scheme: CreateScheme, value: U256, init_code: Vec<u8>, target_gas: Option<u64>, ) -> Capture<(ExitReason, Vec<u8>), Self::CreateInterrupt>
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>
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>
Source§fn record_external_operation(
&mut self,
op: ExternalOperation,
) -> Result<(), ExitError>
fn record_external_operation( &mut self, op: ExternalOperation, ) -> Result<(), ExitError>
ExternalOperation. Read moreSource§fn get_blob_hash(&self, index: usize) -> Option<U256>
fn get_blob_hash(&self, index: usize) -> Option<U256>
blob_hash from blob_versioned_hashes by index
[EIP-4844]: BLOBHASH - https://eips.ethereum.org/EIPS/eip-4844#opcode-to-get-versioned-hashes