pub trait Ext {
Show 33 methods
fn initial_storage_at(&self, key: &H256) -> Result<H256>;
fn storage_at(&self, key: &H256) -> Result<H256>;
fn set_storage(&mut self, key: H256, value: H256) -> Result<()>;
fn exists(&self, address: &Address) -> Result<bool>;
fn exists_and_not_null(&self, address: &Address) -> Result<bool>;
fn origin_balance(&self) -> Result<U256>;
fn balance(&self, address: &Address) -> Result<U256>;
fn blockhash(&mut self, number: &U256) -> H256;
fn create(
&mut self,
gas: &U256,
value: &U256,
code: &[u8],
address: CreateContractAddress,
trap: bool
) -> Result<ContractCreateResult, TrapKind>;
fn calc_address(
&self,
code: &[u8],
address: CreateContractAddress
) -> Option<Address>;
fn call(
&mut self,
gas: &U256,
sender_address: &Address,
receive_address: &Address,
value: Option<U256>,
data: &[u8],
code_address: &Address,
call_type: CallType,
trap: bool
) -> Result<MessageCallResult, TrapKind>;
fn extcode(&self, address: &Address) -> Result<Option<Arc<Bytes>>>;
fn extcodehash(&self, address: &Address) -> Result<Option<H256>>;
fn extcodesize(&self, address: &Address) -> Result<Option<usize>>;
fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> Result<()>;
fn ret(
self,
gas: &U256,
data: &ReturnData,
apply_state: bool
) -> Result<U256>;
fn suicide(&mut self, refund_address: &Address) -> Result<()>;
fn schedule(&self) -> &Schedule;
fn env_info(&self) -> &EnvInfo;
fn chain_id(&self) -> u64;
fn depth(&self) -> usize;
fn add_sstore_refund(&mut self, value: usize);
fn sub_sstore_refund(&mut self, value: usize);
fn is_static(&self) -> bool;
fn al_is_enabled(&self) -> bool;
fn al_contains_storage_key(&self, address: &Address, key: &H256) -> bool;
fn al_insert_storage_key(&mut self, address: Address, key: H256);
fn al_contains_address(&self, address: &Address) -> bool;
fn al_insert_address(&mut self, address: Address);
fn trace_next_instruction(
&mut self,
_pc: usize,
_instruction: u8,
_current_gas: U256
) -> bool { ... }
fn trace_prepare_execute(
&mut self,
_pc: usize,
_instruction: u8,
_gas_cost: U256,
_mem_written: Option<(usize, usize)>,
_store_written: Option<(U256, U256)>
) { ... }
fn trace_failed(&mut self) { ... }
fn trace_executed(
&mut self,
_gas_used: U256,
_stack_push: &[U256],
_mem: &[u8]
) { ... }
}
Expand description
Externalities interface for EVMs
Required methods
fn initial_storage_at(&self, key: &H256) -> Result<H256>
fn initial_storage_at(&self, key: &H256) -> Result<H256>
Returns the storage value for a given key if reversion happens on the current transaction.
fn storage_at(&self, key: &H256) -> Result<H256>
fn storage_at(&self, key: &H256) -> Result<H256>
Returns a value for given key.
fn exists_and_not_null(&self, address: &Address) -> Result<bool>
fn exists_and_not_null(&self, address: &Address) -> Result<bool>
Determine whether an account exists and is not null (zero balance/nonce, no code).
fn origin_balance(&self) -> Result<U256>
fn origin_balance(&self) -> Result<U256>
Balance of the origin account.
Returns the hash of one of the 256 most recent complete blocks.
Creates new contract.
Returns gas_left and contract address if contract creation was successful.
fn calc_address(
&self,
code: &[u8],
address: CreateContractAddress
) -> Option<Address>
fn calc_address(
&self,
code: &[u8],
address: CreateContractAddress
) -> Option<Address>
Returns the address that will be created in the create call
Message call.
Returns Err, if we run out of gas. Otherwise returns call_result which contains gas left and true if subcall was successfull.
Returns code at given address
Returns code hash at given address
Returns code size at given address
Creates log entry with given topics and data
Should be called when transaction calls RETURN
opcode.
Returns gas_left if cost of returning the data is not too high.
Should be called when contract commits suicide. Address to which funds should be refunded.
Returns current depth of execution.
If contract A calls contract B, and contract B calls C, then A depth is 0, B is 1, C is 2 and so on.
fn add_sstore_refund(&mut self, value: usize)
fn add_sstore_refund(&mut self, value: usize)
Increments sstore refunds counter.
fn sub_sstore_refund(&mut self, value: usize)
fn sub_sstore_refund(&mut self, value: usize)
Decrements sstore refunds counter.
fn al_is_enabled(&self) -> bool
fn al_is_enabled(&self) -> bool
Returns if the list is enabled
fn al_contains_storage_key(&self, address: &Address, key: &H256) -> bool
fn al_contains_storage_key(&self, address: &Address, key: &H256) -> bool
Checks if contains an storage key
fn al_insert_storage_key(&mut self, address: Address, key: H256)
fn al_insert_storage_key(&mut self, address: Address, key: H256)
Inserts an storage key into the list
fn al_contains_address(&self, address: &Address) -> bool
fn al_contains_address(&self, address: &Address) -> bool
Checks if contains an address
fn al_insert_address(&mut self, address: Address)
fn al_insert_address(&mut self, address: Address)
Inserts an address into the list
Provided methods
Decide if any more operations should be traced. Passthrough for the VM trace.
Prepare to trace an operation. Passthrough for the VM trace.
For each call of trace_prepare_execute
either trace_failed
or trace_executed
MUST be called.
fn trace_failed(&mut self)
fn trace_failed(&mut self)
Trace the execution failure of a single instruction.