anvil_zksync_core/node/inner/
storage.rs

1use async_trait::async_trait;
2use zksync_multivm::interface::storage::ReadStorage;
3use zksync_types::{StorageKey, StorageValue, H256};
4
5#[async_trait]
6pub trait ReadStorageDyn: ReadStorage + Send + Sync {
7    /// Alternative for [`Clone::clone`] that is object safe.
8    fn dyn_cloned(&self) -> Box<dyn ReadStorageDyn>;
9
10    /// Alternative version of [`ReadStorage::read_value`] that is fallible, async and does not
11    /// require `&mut self`.
12    async fn read_value_alt(&self, key: &StorageKey) -> anyhow::Result<StorageValue>;
13
14    /// Alternative version of [`ReadStorage::load_factory_dep`] that is fallible, async and does not
15    /// require `&mut self`.
16    async fn load_factory_dep_alt(&self, hash: H256) -> anyhow::Result<Option<Vec<u8>>>;
17}
18
19impl Clone for Box<dyn ReadStorageDyn> {
20    fn clone(&self) -> Self {
21        self.dyn_cloned()
22    }
23}