pub trait VmDatabase:
Send
+ Sync
+ DynClone {
// Required methods
fn get_account_state(
&self,
address: Address,
) -> Result<Option<AccountState>, EvmError>;
fn get_storage_slot(
&self,
address: Address,
key: H256,
) -> Result<Option<U256>, EvmError>;
fn get_block_hash(&self, block_number: u64) -> Result<H256, EvmError>;
fn get_chain_config(&self) -> Result<ChainConfig, EvmError>;
fn get_account_code(&self, code_hash: H256) -> Result<Code, EvmError>;
fn get_code_metadata(
&self,
code_hash: H256,
) -> Result<CodeMetadata, EvmError>;
// Provided methods
fn code_cache_budget_bytes(&self) -> u64 { ... }
fn get_account_states_batch(
&self,
addresses: &[Address],
) -> Result<Vec<Option<AccountState>>, EvmError> { ... }
fn get_account_codes_batch(
&self,
code_hashes: &[H256],
) -> Result<Vec<Option<Code>>, EvmError> { ... }
fn get_storage_slots_batch(
&self,
keys: &[(Address, H256)],
) -> Result<Vec<Option<U256>>, EvmError> { ... }
}Required Methods§
fn get_account_state( &self, address: Address, ) -> Result<Option<AccountState>, EvmError>
fn get_storage_slot( &self, address: Address, key: H256, ) -> Result<Option<U256>, EvmError>
fn get_block_hash(&self, block_number: u64) -> Result<H256, EvmError>
fn get_chain_config(&self) -> Result<ChainConfig, EvmError>
fn get_account_code(&self, code_hash: H256) -> Result<Code, EvmError>
fn get_code_metadata(&self, code_hash: H256) -> Result<CodeMetadata, EvmError>
Provided Methods§
Sourcefn code_cache_budget_bytes(&self) -> u64
fn code_cache_budget_bytes(&self) -> u64
Capacity of this backend’s bytecode cache, in Code::size bytes, which bounds
how much bytecode a block warm reads speculatively. Default is the floor for a
backend holding no such cache.
Sourcefn get_account_states_batch(
&self,
addresses: &[Address],
) -> Result<Vec<Option<AccountState>>, EvmError>
fn get_account_states_batch( &self, addresses: &[Address], ) -> Result<Vec<Option<AccountState>>, EvmError>
Batch account-state lookup. Default impl loops get_account_state.
Backends that can amortize per-key cost (e.g. rocksdb multi_get_cf on
the flat key-value table) should override this.
Sourcefn get_account_codes_batch(
&self,
code_hashes: &[H256],
) -> Result<Vec<Option<Code>>, EvmError>
fn get_account_codes_batch( &self, code_hashes: &[H256], ) -> Result<Vec<Option<Code>>, EvmError>
Batch bytecode lookup, aligned to code_hashes. None means the hash is absent
from the database, which callers warming a cache treat as nothing to warm rather
than as failure. Default impl loops get_account_code; backends that can amortize
per-key cost (e.g. rocksdb multi_get_cf on the account-codes table) override it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".