pub trait PrecompileStorageProvider {
Show 22 methods
// Required methods
fn chain_id(&self) -> u64;
fn timestamp(&self) -> U256;
fn beneficiary(&self) -> Address;
fn block_number(&self) -> u64;
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;
fn is_static(&self) -> bool;
fn checkpoint(&mut self) -> JournalCheckpoint;
fn checkpoint_commit(&mut self, checkpoint: JournalCheckpoint);
fn checkpoint_revert(&mut self, checkpoint: JournalCheckpoint);
// Provided methods
fn keccak256(&mut self, data: &[u8]) -> Result<B256> { ... }
fn recover_signer(
&mut self,
digest: B256,
v: u8,
r: B256,
s: B256,
) -> Result<Option<Address>> { ... }
}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 block_number(&self) -> u64
fn block_number(&self) -> u64
Returns the current block number.
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.
Sourcefn checkpoint(&mut self) -> JournalCheckpoint
fn checkpoint(&mut self) -> JournalCheckpoint
Creates a new journal checkpoint so that all subsequent state-changing
operations can be atomically committed (checkpoint_commit)
or reverted (checkpoint_revert).
Prefer StorageCtx::checkpoint which returns a CheckpointGuard that
auto-reverts on drop and is hardfork-aware (no-op pre-T1C).
Sourcefn checkpoint_commit(&mut self, checkpoint: JournalCheckpoint)
fn checkpoint_commit(&mut self, checkpoint: JournalCheckpoint)
Commits all state changes since the given checkpoint.
Prefer CheckpointGuard::commit.
Sourcefn checkpoint_revert(&mut self, checkpoint: JournalCheckpoint)
fn checkpoint_revert(&mut self, checkpoint: JournalCheckpoint)
Reverts all state changes back to the given checkpoint.
Prefer CheckpointGuard (auto-reverts on drop).
Provided Methods§
Sourcefn keccak256(&mut self, data: &[u8]) -> Result<B256>
fn keccak256(&mut self, data: &[u8]) -> Result<B256>
Computes keccak256 and charges the appropriate gas.
Implementations should use this over naked keccak256 call to ensure gas is accounted for.
Sourcefn recover_signer(
&mut self,
digest: B256,
v: u8,
r: B256,
s: B256,
) -> Result<Option<Address>>
fn recover_signer( &mut self, digest: B256, v: u8, r: B256, s: B256, ) -> Result<Option<Address>>
Recovers the signer address from an ECDSA signature and charges ecrecover gas.
As per TIP-1004, it only accepts v values of 27 or 28 (no 0/1 normalization).
Returns Ok(None) on invalid signatures; callers map to domain-specific errors.