PrecompileStorageProvider

Trait PrecompileStorageProvider 

Source
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 storage
  • HashMapStorageProvider - 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§

Source

fn chain_id(&self) -> u64

Returns the chain ID.

Source

fn timestamp(&self) -> U256

Returns the current block timestamp.

Source

fn beneficiary(&self) -> Address

Returns the current block beneficiary (coinbase).

Source

fn set_code(&mut self, address: Address, code: Bytecode) -> Result<()>

Sets the bytecode at the given address.

Source

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.

Source

fn sload(&mut self, address: Address, key: U256) -> Result<U256>

Performs an SLOAD operation (persistent storage read).

Source

fn tload(&mut self, address: Address, key: U256) -> Result<U256>

Performs a TLOAD operation (transient storage read).

Source

fn sstore(&mut self, address: Address, key: U256, value: U256) -> Result<()>

Performs an SSTORE operation (persistent storage write).

Source

fn tstore(&mut self, address: Address, key: U256, value: U256) -> Result<()>

Performs a TSTORE operation (transient storage write).

Source

fn emit_event(&mut self, address: Address, event: LogData) -> Result<()>

Emits an event from the given contract address.

Source

fn deduct_gas(&mut self, gas: u64) -> Result<()>

Deducts gas from the remaining gas and returns an error if insufficient.

Source

fn refund_gas(&mut self, gas: i64)

Add refund to the refund gas counter.

Source

fn gas_used(&self) -> u64

Returns the gas used so far.

Source

fn gas_refunded(&self) -> i64

Returns the gas refunded so far.

Source

fn spec(&self) -> TempoHardfork

Returns the currently active hardfork.

Implementors§