Trait Host
pub trait Host {
Show 27 methods
// Required methods
fn basefee(&self) -> Uint<256, 4>;
fn blob_gasprice(&self) -> Uint<256, 4>;
fn gas_limit(&self) -> Uint<256, 4>;
fn difficulty(&self) -> Uint<256, 4>;
fn prevrandao(&self) -> Option<Uint<256, 4>>;
fn block_number(&self) -> Uint<256, 4>;
fn timestamp(&self) -> Uint<256, 4>;
fn beneficiary(&self) -> Address;
fn chain_id(&self) -> Uint<256, 4>;
fn effective_gas_price(&self) -> Uint<256, 4>;
fn caller(&self) -> Address;
fn blob_hash(&self, number: usize) -> Option<Uint<256, 4>>;
fn max_initcode_size(&self) -> usize;
fn block_hash(&mut self, number: u64) -> Option<FixedBytes<32>>;
fn selfdestruct(
&mut self,
address: Address,
target: Address,
) -> Option<StateLoad<SelfDestructResult>>;
fn log(&mut self, log: Log);
fn sstore_skip_cold_load(
&mut self,
address: Address,
key: Uint<256, 4>,
value: Uint<256, 4>,
skip_cold_load: bool,
) -> Result<StateLoad<SStoreResult>, LoadError>;
fn sload_skip_cold_load(
&mut self,
address: Address,
key: Uint<256, 4>,
skip_cold_load: bool,
) -> Result<StateLoad<Uint<256, 4>>, LoadError>;
fn tstore(
&mut self,
address: Address,
key: Uint<256, 4>,
value: Uint<256, 4>,
);
fn tload(&mut self, address: Address, key: Uint<256, 4>) -> Uint<256, 4>;
fn load_account_info_skip_cold_load(
&mut self,
address: Address,
load_code: bool,
skip_cold_load: bool,
) -> Result<AccountInfoLoad<'_>, LoadError>;
// Provided methods
fn sstore(
&mut self,
address: Address,
key: Uint<256, 4>,
value: Uint<256, 4>,
) -> Option<StateLoad<SStoreResult>> { ... }
fn sload(
&mut self,
address: Address,
key: Uint<256, 4>,
) -> Option<StateLoad<Uint<256, 4>>> { ... }
fn balance(&mut self, address: Address) -> Option<StateLoad<Uint<256, 4>>> { ... }
fn load_account_delegated(
&mut self,
address: Address,
) -> Option<StateLoad<AccountLoad>> { ... }
fn load_account_code(
&mut self,
address: Address,
) -> Option<StateLoad<Bytes>> { ... }
fn load_account_code_hash(
&mut self,
address: Address,
) -> Option<StateLoad<FixedBytes<32>>> { ... }
}
Expand description
Host trait with all methods that are needed by the Interpreter.
This trait is implemented for all types that have ContextTr
trait.
There are few groups of functions which are Block, Transaction, Config, Database and Journal functions.
Required Methods§
fn basefee(&self) -> Uint<256, 4>
fn basefee(&self) -> Uint<256, 4>
Block basefee, calls ContextTr::block().basefee()
fn blob_gasprice(&self) -> Uint<256, 4>
fn blob_gasprice(&self) -> Uint<256, 4>
Block blob gasprice, calls ContextTr::block().blob_gasprice()
fn gas_limit(&self) -> Uint<256, 4>
fn gas_limit(&self) -> Uint<256, 4>
Block gas limit, calls ContextTr::block().gas_limit()
fn difficulty(&self) -> Uint<256, 4>
fn difficulty(&self) -> Uint<256, 4>
Block difficulty, calls ContextTr::block().difficulty()
fn prevrandao(&self) -> Option<Uint<256, 4>>
fn prevrandao(&self) -> Option<Uint<256, 4>>
Block prevrandao, calls ContextTr::block().prevrandao()
fn block_number(&self) -> Uint<256, 4>
fn block_number(&self) -> Uint<256, 4>
Block number, calls ContextTr::block().number()
fn timestamp(&self) -> Uint<256, 4>
fn timestamp(&self) -> Uint<256, 4>
Block timestamp, calls ContextTr::block().timestamp()
fn beneficiary(&self) -> Address
fn beneficiary(&self) -> Address
Block beneficiary, calls ContextTr::block().beneficiary()
fn chain_id(&self) -> Uint<256, 4>
fn chain_id(&self) -> Uint<256, 4>
Chain id, calls ContextTr::cfg().chain_id()
fn effective_gas_price(&self) -> Uint<256, 4>
fn effective_gas_price(&self) -> Uint<256, 4>
Transaction effective gas price, calls ContextTr::tx().effective_gas_price(basefee as u128)
fn caller(&self) -> Address
fn caller(&self) -> Address
Transaction caller, calls ContextTr::tx().caller()
fn blob_hash(&self, number: usize) -> Option<Uint<256, 4>>
fn blob_hash(&self, number: usize) -> Option<Uint<256, 4>>
Transaction blob hash, calls ContextTr::tx().blob_hash(number)
fn max_initcode_size(&self) -> usize
fn max_initcode_size(&self) -> usize
Max initcode size, calls ContextTr::cfg().max_code_size().saturating_mul(2)
fn block_hash(&mut self, number: u64) -> Option<FixedBytes<32>>
fn block_hash(&mut self, number: u64) -> Option<FixedBytes<32>>
Block hash, calls ContextTr::journal_mut().db().block_hash(number)
fn selfdestruct(
&mut self,
address: Address,
target: Address,
) -> Option<StateLoad<SelfDestructResult>>
fn selfdestruct( &mut self, address: Address, target: Address, ) -> Option<StateLoad<SelfDestructResult>>
Selfdestruct account, calls ContextTr::journal_mut().selfdestruct(address, target)
fn log(&mut self, log: Log)
fn log(&mut self, log: Log)
Log, calls ContextTr::journal_mut().log(log)
fn sstore_skip_cold_load(
&mut self,
address: Address,
key: Uint<256, 4>,
value: Uint<256, 4>,
skip_cold_load: bool,
) -> Result<StateLoad<SStoreResult>, LoadError>
fn sstore_skip_cold_load( &mut self, address: Address, key: Uint<256, 4>, value: Uint<256, 4>, skip_cold_load: bool, ) -> Result<StateLoad<SStoreResult>, LoadError>
Sstore with optional fetch from database. Return none if the value is cold or if there is db error.
fn sload_skip_cold_load(
&mut self,
address: Address,
key: Uint<256, 4>,
skip_cold_load: bool,
) -> Result<StateLoad<Uint<256, 4>>, LoadError>
fn sload_skip_cold_load( &mut self, address: Address, key: Uint<256, 4>, skip_cold_load: bool, ) -> Result<StateLoad<Uint<256, 4>>, LoadError>
Sload with optional fetch from database. Return none if the value is cold or if there is db error.
fn tstore(&mut self, address: Address, key: Uint<256, 4>, value: Uint<256, 4>)
fn tstore(&mut self, address: Address, key: Uint<256, 4>, value: Uint<256, 4>)
Tstore, calls ContextTr::journal_mut().tstore(address, key, value)
fn tload(&mut self, address: Address, key: Uint<256, 4>) -> Uint<256, 4>
fn tload(&mut self, address: Address, key: Uint<256, 4>) -> Uint<256, 4>
Tload, calls ContextTr::journal_mut().tload(address, key)
fn load_account_info_skip_cold_load(
&mut self,
address: Address,
load_code: bool,
skip_cold_load: bool,
) -> Result<AccountInfoLoad<'_>, LoadError>
fn load_account_info_skip_cold_load( &mut self, address: Address, load_code: bool, skip_cold_load: bool, ) -> Result<AccountInfoLoad<'_>, LoadError>
Main function to load account info.
If load_code is true, it will load the code fetching it from the database if not done before.
If skip_cold_load is true, it will not load the account if it is cold. This is needed to short circuit the load if there is not enough gas.
Returns AccountInfo, is_cold and is_empty.
Provided Methods§
fn sstore(
&mut self,
address: Address,
key: Uint<256, 4>,
value: Uint<256, 4>,
) -> Option<StateLoad<SStoreResult>>
fn sstore( &mut self, address: Address, key: Uint<256, 4>, value: Uint<256, 4>, ) -> Option<StateLoad<SStoreResult>>
Sstore, calls ContextTr::journal_mut().sstore(address, key, value)
fn sload(
&mut self,
address: Address,
key: Uint<256, 4>,
) -> Option<StateLoad<Uint<256, 4>>>
fn sload( &mut self, address: Address, key: Uint<256, 4>, ) -> Option<StateLoad<Uint<256, 4>>>
Sload, calls ContextTr::journal_mut().sload(address, key)
fn balance(&mut self, address: Address) -> Option<StateLoad<Uint<256, 4>>>
fn balance(&mut self, address: Address) -> Option<StateLoad<Uint<256, 4>>>
Balance, calls ContextTr::journal_mut().load_account(address)
fn load_account_delegated(
&mut self,
address: Address,
) -> Option<StateLoad<AccountLoad>>
fn load_account_delegated( &mut self, address: Address, ) -> Option<StateLoad<AccountLoad>>
Load account delegated, calls ContextTr::journal_mut().load_account_delegated(address)
fn load_account_code(&mut self, address: Address) -> Option<StateLoad<Bytes>>
fn load_account_code(&mut self, address: Address) -> Option<StateLoad<Bytes>>
Load account code, calls Host::load_account_info_skip_cold_load
with load_code
set to false.
fn load_account_code_hash(
&mut self,
address: Address,
) -> Option<StateLoad<FixedBytes<32>>>
fn load_account_code_hash( &mut self, address: Address, ) -> Option<StateLoad<FixedBytes<32>>>
Load account code hash, calls Host::load_account_info_skip_cold_load
with load_code
set to false.