Handler

Trait Handler 

Source
pub trait Handler {
    type CreateInterrupt;
    type CreateFeedback;
    type CallInterrupt;
    type CallFeedback;

Show 38 methods // Required methods fn balance(&self, address: H160) -> U256; fn code_size(&mut self, address: H160) -> U256; fn code_hash(&mut self, address: H160) -> H256; fn code(&self, address: H160) -> Vec<u8> ; fn storage(&self, address: H160, index: H256) -> H256; fn is_empty_storage(&self, address: H160) -> bool; fn original_storage(&self, address: H160, index: H256) -> H256; fn gas_left(&self) -> U256; fn gas_price(&self) -> U256; fn origin(&self) -> H160; fn block_hash(&self, number: U256) -> H256; fn block_number(&self) -> U256; fn block_coinbase(&self) -> H160; fn block_timestamp(&self) -> U256; fn block_difficulty(&self) -> U256; fn block_randomness(&self) -> Option<H256>; fn block_gas_limit(&self) -> U256; fn block_base_fee_per_gas(&self) -> U256; fn chain_id(&self) -> U256; fn exists(&self, address: H160) -> bool; fn deleted(&self, address: H160) -> bool; fn is_cold(&mut self, address: H160, index: Option<H256>) -> bool; fn set_storage( &mut self, address: H160, index: H256, value: H256, ) -> Result<(), ExitError>; fn log( &mut self, address: H160, topics: Vec<H256>, data: Vec<u8>, ) -> Result<(), ExitError>; fn mark_delete( &mut self, address: H160, target: H160, ) -> Result<(), ExitError>; 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 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 record_external_operation( &mut self, op: ExternalOperation, ) -> Result<(), ExitError>; fn blob_base_fee(&self) -> Option<u128>; fn get_blob_hash(&self, index: usize) -> Option<U256>; fn tstore( &mut self, address: H160, index: H256, value: U256, ) -> Result<(), ExitError>; fn tload(&mut self, address: H160, index: H256) -> Result<U256, ExitError>; fn get_authority_target(&mut self, address: H160) -> Option<H160>; fn authority_code(&mut self, authority: H160) -> Vec<u8> ; fn warm_target(&mut self, target: (H160, Option<H256>)); // Provided methods fn create_feedback( &mut self, _feedback: Self::CreateFeedback, ) -> Result<(), ExitError> { ... } fn call_feedback( &mut self, _feedback: Self::CallFeedback, ) -> Result<(), ExitError> { ... } fn other( &mut self, opcode: Opcode, _stack: &mut Machine, ) -> Result<(), ExitError> { ... }
}
Expand description

EVM context handler.

Required Associated Types§

Source

type CreateInterrupt

Type of CREATE interrupt.

Source

type CreateFeedback

Feedback value for CREATE interrupt.

Source

type CallInterrupt

Type of CALL interrupt.

Source

type CallFeedback

Feedback value of CALL interrupt.

Required Methods§

Source

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

Get balance of address.

Source

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

Get code size of address.

Source

fn code_hash(&mut 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 is_empty_storage(&self, address: H160) -> bool

Check if the storage of the address is empty.

Source

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

Get original storage value of address at index.

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

Check whether an address exists.

Source

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

Check whether an address has already been deleted.

Source

fn is_cold(&mut self, address: H160, 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:

§Errors

Return ExitError

Source

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

Set storage value of address at index.

§Errors

Return ExitError

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.

§Errors

Return ExitError

Source

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

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

§Errors

Return 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>

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.

§Errors

Return ExitError

Source

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

Returns None if Cancun is not enabled. CANCUN hard fork. [EIP-4844]: Shard Blob Transactions [EIP-7516]: BLOBBASEFEE instruction

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

§Errors

Return ExitError

Source

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

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

§Errors

Return ExitError

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. EIP-7702

Source

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

Warm target according to EIP-2929

Provided Methods§

Source

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

Feed in create feedback.

§Errors

Return ExitError

Source

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

Feed in call feedback.

§Errors

Return ExitError

Source

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

Handle other unknown external opcodes.

§Errors

Return ExitError

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + Handler + ?Sized> Handler for &'a mut T

Source§

type CreateInterrupt = <T as Handler>::CreateInterrupt

Source§

type CreateFeedback = <T as Handler>::CreateFeedback

Source§

type CallInterrupt = <T as Handler>::CallInterrupt

Source§

type CallFeedback = <T as Handler>::CallFeedback

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn gas_left(&self) -> U256

Source§

fn gas_price(&self) -> U256

Source§

fn origin(&self) -> H160

Source§

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

Source§

fn block_number(&self) -> U256

Source§

fn block_coinbase(&self) -> H160

Source§

fn block_timestamp(&self) -> U256

Source§

fn block_difficulty(&self) -> U256

Source§

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

Source§

fn block_gas_limit(&self) -> U256

Source§

fn block_base_fee_per_gas(&self) -> U256

Source§

fn chain_id(&self) -> U256

Source§

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

Source§

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

Source§

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

Source§

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>

Source§

fn mark_delete(&mut self, address: H160, target: H160) -> 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>

Source§

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

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>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T: Handler + ?Sized> Handler for Box<T>

Source§

type CreateInterrupt = <T as Handler>::CreateInterrupt

Source§

type CreateFeedback = <T as Handler>::CreateFeedback

Source§

type CallInterrupt = <T as Handler>::CallInterrupt

Source§

type CallFeedback = <T as Handler>::CallFeedback

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn gas_left(&self) -> U256

Source§

fn gas_price(&self) -> U256

Source§

fn origin(&self) -> H160

Source§

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

Source§

fn block_number(&self) -> U256

Source§

fn block_coinbase(&self) -> H160

Source§

fn block_timestamp(&self) -> U256

Source§

fn block_difficulty(&self) -> U256

Source§

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

Source§

fn block_gas_limit(&self) -> U256

Source§

fn block_base_fee_per_gas(&self) -> U256

Source§

fn chain_id(&self) -> U256

Source§

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

Source§

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

Source§

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

Source§

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>

Source§

fn mark_delete(&mut self, address: H160, target: H160) -> 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>

Source§

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

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>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§

Source§

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

Source§

type CreateInterrupt = StackExecutorCreateInterrupt<'static>

Source§

type CreateFeedback = Infallible

Source§

type CallInterrupt = StackExecutorCallInterrupt<'static>

Source§

type CallFeedback = Infallible