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§
sourcefn storage_at(&self, key: &Vec<u8>) -> Result<U256>
fn storage_at(&self, key: &Vec<u8>) -> Result<U256>
Returns a value for given key.
sourcefn set_storage(&mut self, key: Vec<u8>, value: U256) -> Result<()>
fn set_storage(&mut self, key: Vec<u8>, value: U256) -> Result<()>
Stores a value for given key.
sourcefn transient_storage_at(&self, key: &Vec<u8>) -> Result<U256>
fn transient_storage_at(&self, key: &Vec<u8>) -> Result<U256>
Returns a value for given key.
sourcefn transient_set_storage(&mut self, key: Vec<u8>, value: U256) -> Result<()>
fn transient_set_storage(&mut self, key: Vec<u8>, value: U256) -> Result<()>
Stores a value for given key.
sourcefn 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).
sourcefn origin_balance(&self) -> Result<U256>
fn origin_balance(&self) -> Result<U256>
Balance of the origin account.
sourcefn blockhash(&mut self, number: &U256) -> Result<H256>
fn blockhash(&mut self, number: &U256) -> Result<H256>
Returns the hash of one of the 256 most recent complete blocks.
sourcefn create(
&mut self,
gas: &U256,
value: &U256,
code: &[u8],
address: CreateContractAddress
) -> DbResult<Result<ContractCreateResult, TrapKind>>
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.
sourcefn 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 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.
sourcefn extcode(&self, address: &Address) -> Result<Option<Arc<Bytes>>>
fn extcode(&self, address: &Address) -> Result<Option<Arc<Bytes>>>
Returns code at given address
sourcefn extcodehash(&self, address: &Address) -> Result<H256>
fn extcodehash(&self, address: &Address) -> Result<H256>
Returns code hash at given address
sourcefn extcodesize(&self, address: &Address) -> Result<usize>
fn extcodesize(&self, address: &Address) -> Result<usize>
Returns code size at given address
sourcefn log(&mut self, topics: Vec<H256>, data: &[u8]) -> Result<()>
fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> Result<()>
Creates log entry with given topics and data
sourcefn ret(self, gas: &U256, data: &ReturnData, apply_state: bool) -> Result<U256>
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.
sourcefn suicide(&mut self, refund_address: &Address) -> Result<()>
fn suicide(&mut self, refund_address: &Address) -> Result<()>
Should be called when contract commits suicide. Address to which funds should be refunded.
sourcefn depth(&self) -> usize
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.
sourcefn is_static_or_reentrancy(&self) -> bool
fn is_static_or_reentrancy(&self) -> bool
Check if running in static context or reentrancy context