Trait cfx_vm_types::Context

source ·
pub trait Context {
Show 28 methods // Required methods fn storage_at(&self, key: &Vec<u8>) -> Result<U256>; fn set_storage(&mut self, key: Vec<u8>, value: U256) -> Result<()>; fn transient_storage_at(&self, key: &Vec<u8>) -> Result<U256>; fn transient_set_storage(&mut self, key: Vec<u8>, value: U256) -> 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) -> Result<H256>; fn create( &mut self, gas: &U256, value: &U256, code: &[u8], address: CreateContractAddress ) -> DbResult<Result<ContractCreateResult, TrapKind>>; fn call( &mut self, gas: &U256, sender_address: &Address, receive_address: &Address, value: Option<U256>, data: &[u8], code_address: &Address, call_type: CallType ) -> DbResult<Result<MessageCallResult, TrapKind>>; fn extcode(&self, address: &Address) -> Result<Option<Arc<Bytes>>>; fn extcodehash(&self, address: &Address) -> Result<H256>; fn extcodesize(&self, address: &Address) -> Result<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 spec(&self) -> &Spec; fn env(&self) -> &Env; fn chain_id(&self) -> u64; fn space(&self) -> Space; fn depth(&self) -> usize; fn is_static(&self) -> bool; fn is_static_or_reentrancy(&self) -> bool; fn blockhash_source(&self) -> BlockHashSource; // Provided methods fn trace_step(&mut self, interpreter: &dyn InterpreterInfo) { ... } fn trace_step_end(&mut self, interpreter: &dyn InterpreterInfo) { ... } fn opcode_trace_enabled(&self) -> bool { ... }
}
Expand description

Context for VMs

Required Methods§

source

fn storage_at(&self, key: &Vec<u8>) -> Result<U256>

Returns a value for given key.

source

fn set_storage(&mut self, key: Vec<u8>, value: U256) -> Result<()>

Stores a value for given key.

source

fn transient_storage_at(&self, key: &Vec<u8>) -> Result<U256>

Returns a value for given key.

source

fn transient_set_storage(&mut self, key: Vec<u8>, value: U256) -> Result<()>

Stores a value for given key.

source

fn exists(&self, address: &Address) -> Result<bool>

Determine whether an account exists.

source

fn exists_and_not_null(&self, address: &Address) -> Result<bool>

Determine whether an account exists and is not null (zero balance/nonce, no code).

source

fn origin_balance(&self) -> Result<U256>

Balance of the origin account.

source

fn balance(&self, address: &Address) -> Result<U256>

Returns address balance.

source

fn blockhash(&mut self, number: &U256) -> Result<H256>

Returns the hash of one of the 256 most recent complete blocks.

source

fn create( &mut self, gas: &U256, value: &U256, code: &[u8], address: CreateContractAddress ) -> DbResult<Result<ContractCreateResult, TrapKind>>

Creates new contract.

Returns gas_left and contract address if contract creation was succesfull.

source

fn call( &mut self, gas: &U256, sender_address: &Address, receive_address: &Address, value: Option<U256>, data: &[u8], code_address: &Address, call_type: CallType ) -> DbResult<Result<MessageCallResult, TrapKind>>

Message call.

Returns Err, if we run out of gas. Otherwise returns call_result which contains gas left and true if subcall was successful.

source

fn extcode(&self, address: &Address) -> Result<Option<Arc<Bytes>>>

Returns code at given address

source

fn extcodehash(&self, address: &Address) -> Result<H256>

Returns code hash at given address

source

fn extcodesize(&self, address: &Address) -> Result<usize>

Returns code size at given address

source

fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> Result<()>

Creates log entry with given topics and data

source

fn ret(self, gas: &U256, data: &ReturnData, apply_state: bool) -> Result<U256>

Should be called when transaction calls RETURN opcode. Returns gas_left if cost of returning the data is not too high.

source

fn suicide(&mut self, refund_address: &Address) -> Result<()>

Should be called when contract commits suicide. Address to which funds should be refunded.

source

fn spec(&self) -> &Spec

Returns specification.

source

fn env(&self) -> &Env

Returns environment.

source

fn chain_id(&self) -> u64

Returns the chain ID of the blockchain

source

fn space(&self) -> Space

Returns the space of the blockchain

source

fn depth(&self) -> usize

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.

source

fn is_static(&self) -> bool

Check if running in static context.

source

fn is_static_or_reentrancy(&self) -> bool

Check if running in static context or reentrancy context

source

fn blockhash_source(&self) -> BlockHashSource

Provided Methods§

source

fn trace_step(&mut self, interpreter: &dyn InterpreterInfo)

source

fn trace_step_end(&mut self, interpreter: &dyn InterpreterInfo)

source

fn opcode_trace_enabled(&self) -> bool

Implementors§