Trait zksync_vm2::StorageInterface
source · pub trait StorageInterface {
// Required methods
fn read_storage(&mut self, contract: H160, key: U256) -> StorageSlot;
fn cost_of_writing_storage(
&mut self,
initial_slot: StorageSlot,
new_value: U256,
) -> u32;
fn is_free_storage_slot(&self, contract: &H160, key: &U256) -> bool;
// Provided method
fn read_storage_value(&mut self, contract: H160, key: U256) -> U256 { ... }
}
Expand description
VM storage access operations.
Required Methods§
sourcefn read_storage(&mut self, contract: H160, key: U256) -> StorageSlot
fn read_storage(&mut self, contract: H160, key: U256) -> StorageSlot
Reads the specified slot from the storage.
There is no write counterpart; WorldDiff::get_storage_changes()
gives a list of all storage changes.
sourcefn cost_of_writing_storage(
&mut self,
initial_slot: StorageSlot,
new_value: U256,
) -> u32
fn cost_of_writing_storage( &mut self, initial_slot: StorageSlot, new_value: U256, ) -> u32
Computes the cost of writing a storage slot.
sourcefn is_free_storage_slot(&self, contract: &H160, key: &U256) -> bool
fn is_free_storage_slot(&self, contract: &H160, key: &U256) -> bool
Returns if the storage slot is free both in terms of gas and pubdata.
Provided Methods§
sourcefn read_storage_value(&mut self, contract: H160, key: U256) -> U256
fn read_storage_value(&mut self, contract: H160, key: U256) -> U256
Same as Self::read_storage()
, but doesn’t request the initialness flag for the read slot.
The default implementation uses read_storage()
.