diff --git a/crates/cheatnet/src/constants.rs b/crates/cheatnet/src/constants.rs index 34de50f737..8095601aac 100644 --- a/crates/cheatnet/src/constants.rs +++ b/crates/cheatnet/src/constants.rs @@ -78,7 +78,6 @@ pub fn build_testing_state() -> DictStateReader { DictStateReader { address_to_class_hash, class_hash_to_class, - ..Default::default() } } diff --git a/crates/runtime/src/starknet/state.rs b/crates/runtime/src/starknet/state.rs index 777b695f3c..8531976bca 100644 --- a/crates/runtime/src/starknet/state.rs +++ b/crates/runtime/src/starknet/state.rs @@ -1,5 +1,4 @@ use blockifier::execution::contract_class::ContractClass; -use blockifier::state::cached_state::StorageEntry; use blockifier::state::errors::StateError; use blockifier::state::state_api::{StateReader, StateResult}; use starknet_api::core::CompiledClassHash; @@ -11,11 +10,8 @@ use std::collections::HashMap; /// A simple implementation of `StateReader` using `HashMap`s as storage. #[derive(Debug, Default)] pub struct DictStateReader { - pub storage_view: HashMap, - pub address_to_nonce: HashMap, pub address_to_class_hash: HashMap, pub class_hash_to_class: HashMap, - pub class_hash_to_compiled_class_hash: HashMap, } impl StateReader for DictStateReader { @@ -24,21 +20,15 @@ impl StateReader for DictStateReader { contract_address: ContractAddress, key: StorageKey, ) -> StateResult { - self.storage_view - .get(&(contract_address, key)) - .copied() - .ok_or(StateError::StateReadError(format!( + Err(StateError::StateReadError(format!( "Unable to get storage at address: {contract_address:?} and key: {key:?} form DictStateReader" ))) } fn get_nonce_at(&self, contract_address: ContractAddress) -> StateResult { - self.address_to_nonce - .get(&contract_address) - .copied() - .ok_or(StateError::StateReadError(format!( - "Unable to get nonce at {contract_address:?} from DictStateReader" - ))) + Err(StateError::StateReadError(format!( + "Unable to get nonce at {contract_address:?} from DictStateReader" + ))) } fn get_class_hash_at(&self, contract_address: ContractAddress) -> StateResult { @@ -57,11 +47,6 @@ impl StateReader for DictStateReader { } fn get_compiled_class_hash(&self, class_hash: ClassHash) -> StateResult { - let compiled_class_hash = self - .class_hash_to_compiled_class_hash - .get(&class_hash) - .copied() - .unwrap_or_default(); - Ok(compiled_class_hash) + Err(StateError::UndeclaredClassHash(class_hash)) } }