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§
Sourcefn blob_gasprice(&self) -> Uint<256, 4>
fn blob_gasprice(&self) -> Uint<256, 4>
Block blob gasprice, calls ContextTr::block().blob_gasprice()
Sourcefn difficulty(&self) -> Uint<256, 4>
fn difficulty(&self) -> Uint<256, 4>
Block difficulty, calls ContextTr::block().difficulty()
Sourcefn prevrandao(&self) -> Option<Uint<256, 4>>
fn prevrandao(&self) -> Option<Uint<256, 4>>
Block prevrandao, calls ContextTr::block().prevrandao()
Sourcefn block_number(&self) -> Uint<256, 4>
fn block_number(&self) -> Uint<256, 4>
Block number, calls ContextTr::block().number()
Sourcefn beneficiary(&self) -> Address
fn beneficiary(&self) -> Address
Block beneficiary, calls ContextTr::block().beneficiary()
Sourcefn 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)
Sourcefn 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)
Sourcefn max_initcode_size(&self) -> usize
fn max_initcode_size(&self) -> usize
Max initcode size, calls ContextTr::cfg().max_code_size().saturating_mul(2)
Sourcefn 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)
Sourcefn 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)
Sourcefn 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.
Sourcefn 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.
Sourcefn 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)
Sourcefn 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)
Sourcefn 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§
Sourcefn 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)
Sourcefn 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)
Sourcefn 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)
Sourcefn 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)
Sourcefn 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.
Sourcefn 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.