diff --git a/crates/cache/src/error.rs b/crates/cache/src/inmemory/error.rs similarity index 100% rename from crates/cache/src/error.rs rename to crates/cache/src/inmemory/error.rs diff --git a/crates/cache/src/inmemory/mod.rs b/crates/cache/src/inmemory/mod.rs new file mode 100644 index 00000000..5f4560b3 --- /dev/null +++ b/crates/cache/src/inmemory/mod.rs @@ -0,0 +1,356 @@ +use std::collections::{HashMap, HashSet}; +use std::sync::Arc; + +use async_trait::async_trait; +use dashmap::DashMap; +use dojo_types::naming; +use starknet::core::types::contract::AbiEntry; +use starknet::core::types::{ + BlockId, BlockTag, ContractClass, EntryPointsByType, LegacyContractAbiEntry, StarknetError, +}; +use starknet::core::types::{Felt, U256}; +use starknet::core::utils::get_selector_from_name; +use starknet::providers::{Provider, ProviderError}; +use tokio::sync::{Mutex, RwLock}; +use torii_math::I256; +use torii_proto::Model; +use torii_storage::ReadOnlyStorage; + +use crate::inmemory::error::Error; +use crate::{Cache, CacheError, ReadOnlyCache}; + +pub mod error; + +#[derive(Debug)] +pub struct InMemoryCache { + pub model_cache: ModelCache, + pub erc_cache: ErcCache, +} + +impl InMemoryCache { + pub async fn new(storage: Arc) -> Result { + Ok(Self { + model_cache: ModelCache::new(storage.clone()).await?, + erc_cache: ErcCache::new(storage).await?, + }) + } +} + +#[async_trait] +impl ReadOnlyCache for InMemoryCache { + async fn models(&self, selectors: &[Felt]) -> Result, CacheError> { + self.model_cache + .models(selectors) + .await + .map_err(|e| CacheError(Box::new(e))) + } + + async fn model(&self, selector: Felt) -> Result { + self.model_cache + .model(selector) + .await + .map_err(|e| CacheError(Box::new(e))) + } + + async fn is_token_registered(&self, token_id: &str) -> bool { + self.erc_cache.is_token_registered(token_id).await + } + + async fn get_token_registration_lock(&self, token_id: &str) -> Option>> { + self.erc_cache.get_token_registration_lock(token_id).await + } + + async fn balances_diff(&self) -> HashMap { + self.erc_cache + .balances_diff + .iter() + .map(|t| (t.key().clone(), *t.value())) + .collect() + } +} + +#[async_trait] +impl Cache for InMemoryCache { + async fn register_model(&self, selector: Felt, model: Model) { + self.model_cache.set(selector, model).await + } + + async fn clear_models(&self) { + self.model_cache.clear().await + } + + async fn mark_token_registered(&self, token_id: &str) { + self.erc_cache.mark_token_registered(token_id).await + } + + async fn clear_balances_diff(&self) { + self.erc_cache.balances_diff.clear(); + self.erc_cache.balances_diff.shrink_to_fit(); + } + + async fn update_balance_diff(&self, token_id: &str, from: Felt, to: Felt, value: U256) { + if from != Felt::ZERO { + // from/token_id + let from_balance_id = format!("{:#x}/{}", from, token_id); + let mut from_balance = self + .erc_cache + .balances_diff + .entry(from_balance_id) + .or_default(); + *from_balance -= I256::from(value); + } + + if to != Felt::ZERO { + // to/token_id + let to_balance_id = format!("{:#x}/{}", to, token_id); + let mut to_balance = self + .erc_cache + .balances_diff + .entry(to_balance_id) + .or_default(); + *to_balance += I256::from(value); + } + } +} + +#[derive(Debug)] +pub struct ModelCache { + storage: Arc, + model_cache: RwLock>, +} + +impl ModelCache { + pub async fn new(storage: Arc) -> Result { + let models = storage.models().await?; + + let mut model_cache = HashMap::new(); + for model in models { + let selector = naming::compute_selector_from_names(&model.namespace, &model.name); + model_cache.insert(selector, model); + } + + Ok(Self { + storage, + model_cache: RwLock::new(model_cache), + }) + } + + pub async fn models(&self, selectors: &[Felt]) -> Result, Error> { + if selectors.is_empty() { + return Ok(self.model_cache.read().await.values().cloned().collect()); + } + + let mut schemas = Vec::with_capacity(selectors.len()); + for selector in selectors { + schemas.push(self.model(*selector).await?); + } + + Ok(schemas) + } + + pub async fn model(&self, selector: Felt) -> Result { + { + let cache = self.model_cache.read().await; + if let Some(model) = cache.get(&selector).cloned() { + return Ok(model); + } + } + + self.update_model(selector).await + } + + async fn update_model(&self, selector: Felt) -> Result { + let model = self.storage.model(selector).await?; + + let mut cache = self.model_cache.write().await; + let s = naming::compute_selector_from_names(&model.namespace, &model.name); + cache.insert(s, model.clone()); + + Ok(model) + } + + pub async fn set(&self, selector: Felt, model: Model) { + let mut cache = self.model_cache.write().await; + cache.insert(selector, model); + } + + pub async fn clear(&self) { + self.model_cache.write().await.clear(); + } +} + +#[derive(Debug)] +pub enum TokenState { + Registered, + Registering(Arc>), + NotRegistered, +} + +#[derive(Debug)] +pub struct ErcCache { + pub balances_diff: DashMap, + // the registry is a map of token_id to a mutex that is used to track if the token is registered + // we need a mutex for the token state to prevent race conditions in case of multiple token regs + pub token_id_registry: DashMap, +} + +impl ErcCache { + pub async fn new(storage: Arc) -> Result { + // read existing token_id's from balances table and cache them + let token_id_registry: HashSet = storage.token_ids().await?; + + Ok(Self { + balances_diff: DashMap::new(), + token_id_registry: token_id_registry + .iter() + .map(|token_id| (token_id.clone(), TokenState::Registered)) + .collect(), + }) + } + + pub async fn get_token_registration_lock(&self, token_id: &str) -> Option>> { + let entry = self.token_id_registry.entry(token_id.to_string()); + match entry { + dashmap::Entry::Occupied(mut occupied) => match occupied.get() { + TokenState::Registering(mutex) => Some(mutex.clone()), + TokenState::Registered => None, + TokenState::NotRegistered => { + let mutex = Arc::new(Mutex::new(())); + occupied.insert(TokenState::Registering(mutex.clone())); + Some(mutex) + } + }, + dashmap::Entry::Vacant(vacant) => { + let mutex = Arc::new(Mutex::new(())); + vacant.insert(TokenState::Registering(mutex.clone())); + Some(mutex) + } + } + } + + pub async fn mark_token_registered(&self, token_id: &str) { + self.token_id_registry + .insert(token_id.to_string(), TokenState::Registered); + } + + pub async fn is_token_registered(&self, token_id: &str) -> bool { + self.token_id_registry + .get(token_id) + .map(|t| matches!(t.value(), TokenState::Registered)) + .unwrap_or(false) + } +} + +#[derive(Debug, Clone)] +pub enum ClassAbi { + Sierra((EntryPointsByType, Vec)), + Legacy(Vec), +} + +#[derive(Debug)] +pub struct ContractClassCache { + pub classes: RwLock>, + pub provider: Arc

, +} + +impl ContractClassCache

{ + pub fn new(provider: Arc

) -> Self { + Self { + classes: RwLock::new(HashMap::new()), + provider, + } + } + + pub async fn get( + &self, + contract_address: Felt, + mut block_id: BlockId, + ) -> Result { + { + let classes = self.classes.read().await; + if let Some(class) = classes.get(&contract_address) { + return Ok(class.1.clone()); + } + } + + let class_hash = match self + .provider + .get_class_hash_at(block_id, contract_address) + .await + { + Ok(class_hash) => class_hash, + Err(e) => match e { + // if we got a block not found error, we probably are in a pending block. + ProviderError::StarknetError(StarknetError::BlockNotFound) => { + block_id = BlockId::Tag(BlockTag::Pending); + self.provider + .get_class_hash_at(block_id, contract_address) + .await? + } + _ => return Err(Error::Provider(e)), + }, + }; + let class = match self + .provider + .get_class_at(block_id, contract_address) + .await? + { + ContractClass::Sierra(sierra) => { + let abi: Vec = serde_json::from_str(&sierra.abi).unwrap(); + let functions: Vec = flatten_abi_funcs_recursive(&abi); + ClassAbi::Sierra((sierra.entry_points_by_type, functions)) + } + ContractClass::Legacy(legacy) => ClassAbi::Legacy(legacy.abi.unwrap_or_default()), + }; + self.classes + .write() + .await + .insert(contract_address, (class_hash, class.clone())); + Ok(class) + } +} + +fn flatten_abi_funcs_recursive(abi: &[AbiEntry]) -> Vec { + abi.iter() + .flat_map(|entry| match entry { + AbiEntry::Function(_) | AbiEntry::L1Handler(_) | AbiEntry::Constructor(_) => { + vec![entry.clone()] + } + AbiEntry::Interface(interface) => flatten_abi_funcs_recursive(&interface.items), + _ => vec![], + }) + .collect() +} + +pub fn get_entrypoint_name_from_class(class: &ClassAbi, selector: Felt) -> Option { + match class { + ClassAbi::Sierra((entrypoints, abi)) => { + let entrypoint_idx = match entrypoints + .external + .iter() + .chain(entrypoints.l1_handler.iter()) + .chain(entrypoints.constructor.iter()) + .find(|entrypoint| entrypoint.selector == selector) + { + Some(entrypoint) => entrypoint.function_idx, + None => return None, + }; + + abi.get(entrypoint_idx as usize) + .and_then(|function| match function { + AbiEntry::Function(function) => Some(function.name.clone()), + AbiEntry::L1Handler(l1_handler) => Some(l1_handler.name.clone()), + AbiEntry::Constructor(constructor) => Some(constructor.name.clone()), + _ => None, + }) + } + ClassAbi::Legacy(abi) => abi.iter().find_map(|entry| match entry { + LegacyContractAbiEntry::Function(function) + if get_selector_from_name(&function.name).unwrap() == selector => + { + Some(function.name.clone()) + } + _ => None, + }), + } +} diff --git a/crates/cache/src/lib.rs b/crates/cache/src/lib.rs index bff366dc..a51be997 100644 --- a/crates/cache/src/lib.rs +++ b/crates/cache/src/lib.rs @@ -1,26 +1,15 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::sync::Arc; use async_trait::async_trait; -use dashmap::DashMap; -use dojo_types::naming; -use starknet::core::types::contract::AbiEntry; -use starknet::core::types::{ - BlockId, BlockTag, ContractClass, EntryPointsByType, LegacyContractAbiEntry, StarknetError, -}; use starknet::core::types::{Felt, U256}; -use starknet::core::utils::get_selector_from_name; -use starknet::providers::{Provider, ProviderError}; -use tokio::sync::{Mutex, RwLock}; +use tokio::sync::Mutex; use torii_math::I256; use torii_proto::Model; -use torii_storage::ReadOnlyStorage; -use crate::error::Error; +pub mod inmemory; -pub mod error; - -pub type CacheError = Box; +pub struct CacheError(Box); #[async_trait] pub trait ReadOnlyCache: Send + Sync + std::fmt::Debug { @@ -56,338 +45,4 @@ pub trait Cache: ReadOnlyCache + Send + Sync + std::fmt::Debug { /// Update the balances diff. async fn update_balance_diff(&self, token_id: &str, from: Felt, to: Felt, value: U256); -} - -#[derive(Debug)] -pub struct InMemoryCache { - pub model_cache: ModelCache, - pub erc_cache: ErcCache, -} - -impl InMemoryCache { - pub async fn new(storage: Arc) -> Result { - Ok(Self { - model_cache: ModelCache::new(storage.clone()).await?, - erc_cache: ErcCache::new(storage).await?, - }) - } -} - -#[async_trait] -impl ReadOnlyCache for InMemoryCache { - async fn models(&self, selectors: &[Felt]) -> Result, CacheError> { - self.model_cache - .models(selectors) - .await - .map_err(|e| Box::new(e) as CacheError) - } - - async fn model(&self, selector: Felt) -> Result { - self.model_cache - .model(selector) - .await - .map_err(|e| Box::new(e) as CacheError) - } - - async fn is_token_registered(&self, token_id: &str) -> bool { - self.erc_cache.is_token_registered(token_id).await - } - - async fn get_token_registration_lock(&self, token_id: &str) -> Option>> { - self.erc_cache.get_token_registration_lock(token_id).await - } - - async fn balances_diff(&self) -> HashMap { - self.erc_cache - .balances_diff - .iter() - .map(|t| (t.key().clone(), *t.value())) - .collect() - } -} - -#[async_trait] -impl Cache for InMemoryCache { - async fn register_model(&self, selector: Felt, model: Model) { - self.model_cache.set(selector, model).await - } - - async fn clear_models(&self) { - self.model_cache.clear().await - } - - async fn mark_token_registered(&self, token_id: &str) { - self.erc_cache.mark_token_registered(token_id).await - } - - async fn clear_balances_diff(&self) { - self.erc_cache.balances_diff.clear(); - self.erc_cache.balances_diff.shrink_to_fit(); - } - - async fn update_balance_diff(&self, token_id: &str, from: Felt, to: Felt, value: U256) { - if from != Felt::ZERO { - // from/token_id - let from_balance_id = format!("{:#x}/{}", from, token_id); - let mut from_balance = self - .erc_cache - .balances_diff - .entry(from_balance_id) - .or_default(); - *from_balance -= I256::from(value); - } - - if to != Felt::ZERO { - // to/token_id - let to_balance_id = format!("{:#x}/{}", to, token_id); - let mut to_balance = self - .erc_cache - .balances_diff - .entry(to_balance_id) - .or_default(); - *to_balance += I256::from(value); - } - } -} - -#[derive(Debug)] -pub struct ModelCache { - storage: Arc, - model_cache: RwLock>, -} - -impl ModelCache { - pub async fn new(storage: Arc) -> Result { - let models = storage.models().await?; - - let mut model_cache = HashMap::new(); - for model in models { - let selector = naming::compute_selector_from_names(&model.namespace, &model.name); - model_cache.insert(selector, model); - } - - Ok(Self { - storage, - model_cache: RwLock::new(model_cache), - }) - } - - pub async fn models(&self, selectors: &[Felt]) -> Result, Error> { - if selectors.is_empty() { - return Ok(self.model_cache.read().await.values().cloned().collect()); - } - - let mut schemas = Vec::with_capacity(selectors.len()); - for selector in selectors { - schemas.push(self.model(*selector).await?); - } - - Ok(schemas) - } - - pub async fn model(&self, selector: Felt) -> Result { - { - let cache = self.model_cache.read().await; - if let Some(model) = cache.get(&selector).cloned() { - return Ok(model); - } - } - - self.update_model(selector).await - } - - async fn update_model(&self, selector: Felt) -> Result { - let model = self.storage.model(selector).await?; - - let mut cache = self.model_cache.write().await; - let s = naming::compute_selector_from_names(&model.namespace, &model.name); - cache.insert(s, model.clone()); - - Ok(model) - } - - pub async fn set(&self, selector: Felt, model: Model) { - let mut cache = self.model_cache.write().await; - cache.insert(selector, model); - } - - pub async fn clear(&self) { - self.model_cache.write().await.clear(); - } -} - -#[derive(Debug)] -pub enum TokenState { - Registered, - Registering(Arc>), - NotRegistered, -} - -#[derive(Debug)] -pub struct ErcCache { - pub balances_diff: DashMap, - // the registry is a map of token_id to a mutex that is used to track if the token is registered - // we need a mutex for the token state to prevent race conditions in case of multiple token regs - pub token_id_registry: DashMap, -} - -impl ErcCache { - pub async fn new(storage: Arc) -> Result { - // read existing token_id's from balances table and cache them - let token_id_registry: HashSet = storage.token_ids().await?; - - Ok(Self { - balances_diff: DashMap::new(), - token_id_registry: token_id_registry - .iter() - .map(|token_id| (token_id.clone(), TokenState::Registered)) - .collect(), - }) - } - - pub async fn get_token_registration_lock(&self, token_id: &str) -> Option>> { - let entry = self.token_id_registry.entry(token_id.to_string()); - match entry { - dashmap::Entry::Occupied(mut occupied) => match occupied.get() { - TokenState::Registering(mutex) => Some(mutex.clone()), - TokenState::Registered => None, - TokenState::NotRegistered => { - let mutex = Arc::new(Mutex::new(())); - occupied.insert(TokenState::Registering(mutex.clone())); - Some(mutex) - } - }, - dashmap::Entry::Vacant(vacant) => { - let mutex = Arc::new(Mutex::new(())); - vacant.insert(TokenState::Registering(mutex.clone())); - Some(mutex) - } - } - } - - pub async fn mark_token_registered(&self, token_id: &str) { - self.token_id_registry - .insert(token_id.to_string(), TokenState::Registered); - } - - pub async fn is_token_registered(&self, token_id: &str) -> bool { - self.token_id_registry - .get(token_id) - .map(|t| matches!(t.value(), TokenState::Registered)) - .unwrap_or(false) - } -} - -#[derive(Debug, Clone)] -pub enum ClassAbi { - Sierra((EntryPointsByType, Vec)), - Legacy(Vec), -} - -#[derive(Debug)] -pub struct ContractClassCache { - pub classes: RwLock>, - pub provider: Arc

, -} - -impl ContractClassCache

{ - pub fn new(provider: Arc

) -> Self { - Self { - classes: RwLock::new(HashMap::new()), - provider, - } - } - - pub async fn get( - &self, - contract_address: Felt, - mut block_id: BlockId, - ) -> Result { - { - let classes = self.classes.read().await; - if let Some(class) = classes.get(&contract_address) { - return Ok(class.1.clone()); - } - } - - let class_hash = match self - .provider - .get_class_hash_at(block_id, contract_address) - .await - { - Ok(class_hash) => class_hash, - Err(e) => match e { - // if we got a block not found error, we probably are in a pending block. - ProviderError::StarknetError(StarknetError::BlockNotFound) => { - block_id = BlockId::Tag(BlockTag::Pending); - self.provider - .get_class_hash_at(block_id, contract_address) - .await? - } - _ => return Err(Error::Provider(e)), - }, - }; - let class = match self - .provider - .get_class_at(block_id, contract_address) - .await? - { - ContractClass::Sierra(sierra) => { - let abi: Vec = serde_json::from_str(&sierra.abi).unwrap(); - let functions: Vec = flatten_abi_funcs_recursive(&abi); - ClassAbi::Sierra((sierra.entry_points_by_type, functions)) - } - ContractClass::Legacy(legacy) => ClassAbi::Legacy(legacy.abi.unwrap_or_default()), - }; - self.classes - .write() - .await - .insert(contract_address, (class_hash, class.clone())); - Ok(class) - } -} - -fn flatten_abi_funcs_recursive(abi: &[AbiEntry]) -> Vec { - abi.iter() - .flat_map(|entry| match entry { - AbiEntry::Function(_) | AbiEntry::L1Handler(_) | AbiEntry::Constructor(_) => { - vec![entry.clone()] - } - AbiEntry::Interface(interface) => flatten_abi_funcs_recursive(&interface.items), - _ => vec![], - }) - .collect() -} - -pub fn get_entrypoint_name_from_class(class: &ClassAbi, selector: Felt) -> Option { - match class { - ClassAbi::Sierra((entrypoints, abi)) => { - let entrypoint_idx = match entrypoints - .external - .iter() - .chain(entrypoints.l1_handler.iter()) - .chain(entrypoints.constructor.iter()) - .find(|entrypoint| entrypoint.selector == selector) - { - Some(entrypoint) => entrypoint.function_idx, - None => return None, - }; - - abi.get(entrypoint_idx as usize) - .and_then(|function| match function { - AbiEntry::Function(function) => Some(function.name.clone()), - AbiEntry::L1Handler(l1_handler) => Some(l1_handler.name.clone()), - AbiEntry::Constructor(constructor) => Some(constructor.name.clone()), - _ => None, - }) - } - ClassAbi::Legacy(abi) => abi.iter().find_map(|entry| match entry { - LegacyContractAbiEntry::Function(function) - if get_selector_from_name(&function.name).unwrap() == selector => - { - Some(function.name.clone()) - } - _ => None, - }), - } -} +} \ No newline at end of file diff --git a/crates/indexer/engine/src/engine.rs b/crates/indexer/engine/src/engine.rs index 7ff70d14..e11a9514 100644 --- a/crates/indexer/engine/src/engine.rs +++ b/crates/indexer/engine/src/engine.rs @@ -13,7 +13,7 @@ use starknet_crypto::Felt; use tokio::sync::broadcast::Sender; use tokio::sync::Semaphore; use tokio::time::{sleep, Instant}; -use torii_cache::{Cache, ContractClassCache}; +use torii_cache::{Cache, inmemory::ContractClassCache}; use torii_controllers::sync::ControllersSync; use torii_processors::{ BlockProcessorContext, EventProcessorConfig, EventProcessorContext, Processors, @@ -192,7 +192,7 @@ impl Engine

{ if let Some(last_fetch_result) = cached_data.as_ref() { Result::<_, Error>::Ok(last_fetch_result.clone()) } else { - let cursors = self.storage.cursors().await?; + let cursors = self.storage.cursors().await.map_err(Error::Storage)?; let fetch_result = self.fetcher.fetch(&cursors).await?; Ok(Arc::new(fetch_result)) } diff --git a/crates/indexer/engine/src/error.rs b/crates/indexer/engine/src/error.rs index 408de267..1822c811 100644 --- a/crates/indexer/engine/src/error.rs +++ b/crates/indexer/engine/src/error.rs @@ -7,9 +7,9 @@ pub enum Error { #[error(transparent)] ProcessError(#[from] ProcessError), #[error(transparent)] - Cache(#[from] torii_cache::error::Error), + Cache(torii_cache::CacheError), #[error(transparent)] - Storage(#[from] torii_storage::StorageError), + Storage(torii_storage::StorageError), #[error(transparent)] ProviderError(#[from] starknet::providers::ProviderError), #[error(transparent)] @@ -25,7 +25,7 @@ pub enum ProcessError { #[error(transparent)] Processors(#[from] torii_processors::error::Error), #[error(transparent)] - Cache(#[from] torii_cache::error::Error), + Cache(torii_cache::CacheError), #[error(transparent)] - Storage(#[from] torii_storage::StorageError), + Storage(torii_storage::StorageError), } diff --git a/crates/indexer/engine/src/test.rs b/crates/indexer/engine/src/test.rs index 1cec33bf..fc319257 100644 --- a/crates/indexer/engine/src/test.rs +++ b/crates/indexer/engine/src/test.rs @@ -20,7 +20,7 @@ use starknet::providers::{JsonRpcClient, Provider}; use starknet_crypto::poseidon_hash_many; use tempfile::NamedTempFile; use tokio::sync::broadcast; -use torii_cache::{Cache, InMemoryCache}; +use torii_cache::{Cache, inmemory::InMemoryCache}; use torii_sqlite::executor::Executor; use torii_sqlite::types::Token; use torii_sqlite::utils::u256_to_sql_string; diff --git a/crates/processors/src/error.rs b/crates/processors/src/error.rs index 308a733a..de28cc6f 100644 --- a/crates/processors/src/error.rs +++ b/crates/processors/src/error.rs @@ -30,7 +30,7 @@ pub enum Error { #[error(transparent)] TokenMetadataError(#[from] TokenMetadataError), #[error(transparent)] - CacheError(#[from] torii_cache::error::Error), + InMemoryCacheError(#[from] torii_cache::inmemory::error::Error), } #[derive(Error, Debug)] diff --git a/crates/processors/src/lib.rs b/crates/processors/src/lib.rs index bbdbe5b3..ce4d9836 100644 --- a/crates/processors/src/lib.rs +++ b/crates/processors/src/lib.rs @@ -6,7 +6,7 @@ use dojo_world::contracts::world::WorldContractReader; use starknet::core::types::{Event, Felt, Transaction}; use starknet::providers::Provider; use tokio::sync::Semaphore; -use torii_cache::{Cache, ContractClassCache}; +use torii_cache::{Cache, inmemory::ContractClassCache}; use torii_storage::Storage; mod constants; diff --git a/crates/processors/src/processors/store_transaction.rs b/crates/processors/src/processors/store_transaction.rs index 5674f291..d1e65be1 100644 --- a/crates/processors/src/processors/store_transaction.rs +++ b/crates/processors/src/processors/store_transaction.rs @@ -3,7 +3,7 @@ use cainome::cairo_serde_derive::CairoSerde; use cainome_cairo_serde::CairoSerde; use starknet::core::types::{BlockId, BlockTag, Felt, InvokeTransaction, Transaction}; use starknet::providers::Provider; -use torii_cache::{get_entrypoint_name_from_class, ContractClassCache}; +use torii_cache::inmemory::{get_entrypoint_name_from_class, ContractClassCache}; use torii_storage::types::{CallType, ParsedCall}; use crate::error::Error; diff --git a/crates/sqlite/sqlite/src/error.rs b/crates/sqlite/sqlite/src/error.rs index cdc7dd6d..1fcab223 100644 --- a/crates/sqlite/sqlite/src/error.rs +++ b/crates/sqlite/sqlite/src/error.rs @@ -26,8 +26,6 @@ pub enum Error { ExecutorQuery(#[from] Box), #[error(transparent)] Storage(#[from] torii_storage::StorageError), - #[error(transparent)] - Cache(#[from] torii_cache::error::Error), } #[derive(Debug, thiserror::Error)]