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§

source

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.

source

fn cost_of_writing_storage( &mut self, initial_slot: StorageSlot, new_value: U256, ) -> u32

Computes the cost of writing a storage slot.

source

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§

source

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().

Implementors§