pub trait Handler {
type CreateInterrupt;
type CreateFeedback;
type CallInterrupt;
type CallFeedback;
Show 31 methods
// Required methods
fn balance(&self, address: H160) -> U256;
fn code_size(&self, address: H160) -> U256;
fn code_hash(&self, address: H160) -> H256;
fn code(&self, address: H160) -> Vec<u8>;
fn storage(&self, address: H160, index: H256) -> H256;
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>
) -> Result<bool, ExitError>;
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, Option<H160>, 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 pre_validate(
&mut self,
context: &Context,
opcode: Opcode,
stack: &Stack
) -> Result<(), ExitError>;
fn record_external_operation(
&mut self,
op: ExternalOperation
) -> Result<(), ExitError>;
// 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§
sourcetype CreateInterrupt
type CreateInterrupt
Type of CREATE
interrupt.
sourcetype CreateFeedback
type CreateFeedback
Feedback value for CREATE
interrupt.
sourcetype CallInterrupt
type CallInterrupt
Type of CALL
interrupt.
sourcetype CallFeedback
type CallFeedback
Feedback value of CALL
interrupt.
Required Methods§
sourcefn original_storage(&self, address: H160, index: H256) -> H256
fn original_storage(&self, address: H160, index: H256) -> H256
Get original storage value of address at index.
sourcefn block_hash(&self, number: U256) -> H256
fn block_hash(&self, number: U256) -> H256
Get environmental block hash.
sourcefn block_number(&self) -> U256
fn block_number(&self) -> U256
Get environmental block number.
sourcefn block_coinbase(&self) -> H160
fn block_coinbase(&self) -> H160
Get environmental coinbase.
sourcefn block_timestamp(&self) -> U256
fn block_timestamp(&self) -> U256
Get environmental block timestamp.
sourcefn block_difficulty(&self) -> U256
fn block_difficulty(&self) -> U256
Get environmental block difficulty.
sourcefn block_randomness(&self) -> Option<H256>
fn block_randomness(&self) -> Option<H256>
Get environmental block randomness.
sourcefn block_gas_limit(&self) -> U256
fn block_gas_limit(&self) -> U256
Get environmental gas limit.
sourcefn block_base_fee_per_gas(&self) -> U256
fn block_base_fee_per_gas(&self) -> U256
Environmental block base fee.
sourcefn is_cold(
&mut self,
address: H160,
index: Option<H256>
) -> Result<bool, ExitError>
fn is_cold( &mut self, address: H160, 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:
sourcefn 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>
Set storage value of address at index.
sourcefn 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>
Create a log owned by address with given topics and data.
sourcefn mark_delete(&mut self, address: H160, target: H160) -> Result<(), ExitError>
fn mark_delete(&mut self, address: H160, target: H160) -> Result<(), ExitError>
Mark an address to be deleted, with funds transferred to target.
sourcefn 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>
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.
sourcefn 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>
Invoke a call operation.
sourcefn pre_validate(
&mut self,
context: &Context,
opcode: Opcode,
stack: &Stack
) -> Result<(), ExitError>
fn pre_validate( &mut self, context: &Context, opcode: Opcode, stack: &Stack ) -> Result<(), ExitError>
Pre-validation step for the runtime.
sourcefn record_external_operation(
&mut self,
op: ExternalOperation
) -> Result<(), ExitError>
fn record_external_operation( &mut self, op: ExternalOperation ) -> Result<(), ExitError>
Records some associated ExternalOperation
.
Provided Methods§
sourcefn create_feedback(
&mut self,
_feedback: Self::CreateFeedback
) -> Result<(), ExitError>
fn create_feedback( &mut self, _feedback: Self::CreateFeedback ) -> Result<(), ExitError>
Feed in create feedback.
sourcefn call_feedback(
&mut self,
_feedback: Self::CallFeedback
) -> Result<(), ExitError>
fn call_feedback( &mut self, _feedback: Self::CallFeedback ) -> Result<(), ExitError>
Feed in call feedback.