pub trait PrecompileStorageProvider {
Show 15 methods
// Required methods
fn chain_id(&self) -> u64;
fn timestamp(&self) -> U256;
fn beneficiary(&self) -> Address;
fn set_code(&mut self, address: Address, code: Bytecode) -> Result<()>;
fn with_account_info(
&mut self,
address: Address,
f: &mut dyn FnMut(&AccountInfo),
) -> Result<()>;
fn sload(&mut self, address: Address, key: U256) -> Result<U256>;
fn tload(&mut self, address: Address, key: U256) -> Result<U256>;
fn sstore(&mut self, address: Address, key: U256, value: U256) -> Result<()>;
fn tstore(&mut self, address: Address, key: U256, value: U256) -> Result<()>;
fn emit_event(&mut self, address: Address, event: LogData) -> Result<()>;
fn deduct_gas(&mut self, gas: u64) -> Result<()>;
fn refund_gas(&mut self, gas: i64);
fn gas_used(&self) -> u64;
fn gas_refunded(&self) -> i64;
fn spec(&self) -> TempoHardfork;
}Expand description
Low-level storage provider for interacting with the EVM.
§Implementations
EvmPrecompileStorageProvider- Production EVM storageHashMapStorageProvider- Test storage
§Sync with [StorageCtx]
StorageCtx mirrors these methods with split mutability for read (staticcall) vs write (call).
When adding new methods here, remember to add corresponding methods to StorageCtx.
Required Methods§
Sourcefn beneficiary(&self) -> Address
fn beneficiary(&self) -> Address
Returns the current block beneficiary (coinbase).
Sourcefn set_code(&mut self, address: Address, code: Bytecode) -> Result<()>
fn set_code(&mut self, address: Address, code: Bytecode) -> Result<()>
Sets the bytecode at the given address.
Sourcefn with_account_info(
&mut self,
address: Address,
f: &mut dyn FnMut(&AccountInfo),
) -> Result<()>
fn with_account_info( &mut self, address: Address, f: &mut dyn FnMut(&AccountInfo), ) -> Result<()>
Executes a closure with access to the account info for the given address.
Sourcefn sload(&mut self, address: Address, key: U256) -> Result<U256>
fn sload(&mut self, address: Address, key: U256) -> Result<U256>
Performs an SLOAD operation (persistent storage read).
Sourcefn tload(&mut self, address: Address, key: U256) -> Result<U256>
fn tload(&mut self, address: Address, key: U256) -> Result<U256>
Performs a TLOAD operation (transient storage read).
Sourcefn sstore(&mut self, address: Address, key: U256, value: U256) -> Result<()>
fn sstore(&mut self, address: Address, key: U256, value: U256) -> Result<()>
Performs an SSTORE operation (persistent storage write).
Sourcefn tstore(&mut self, address: Address, key: U256, value: U256) -> Result<()>
fn tstore(&mut self, address: Address, key: U256, value: U256) -> Result<()>
Performs a TSTORE operation (transient storage write).
Sourcefn emit_event(&mut self, address: Address, event: LogData) -> Result<()>
fn emit_event(&mut self, address: Address, event: LogData) -> Result<()>
Emits an event from the given contract address.
Sourcefn deduct_gas(&mut self, gas: u64) -> Result<()>
fn deduct_gas(&mut self, gas: u64) -> Result<()>
Deducts gas from the remaining gas and returns an error if insufficient.
Sourcefn refund_gas(&mut self, gas: i64)
fn refund_gas(&mut self, gas: i64)
Add refund to the refund gas counter.
Sourcefn gas_refunded(&self) -> i64
fn gas_refunded(&self) -> i64
Returns the gas refunded so far.
Sourcefn spec(&self) -> TempoHardfork
fn spec(&self) -> TempoHardfork
Returns the currently active hardfork.