diff --git a/crates/katana/executor/src/implementation/blockifier/state.rs b/crates/katana/executor/src/implementation/blockifier/state.rs index be1fc0c2a1..4f7e0b85d8 100644 --- a/crates/katana/executor/src/implementation/blockifier/state.rs +++ b/crates/katana/executor/src/implementation/blockifier/state.rs @@ -94,8 +94,6 @@ impl Clone for CachedState { } } -// type DeclaredClass = (CompiledClass, ContractClass); - #[derive(Debug)] pub(super) struct CachedStateInner { pub(super) inner: cached_state::CachedState, @@ -240,47 +238,9 @@ impl StateReader for CachedState { } } -impl StateProofProvider for CachedState { - fn class_multiproof( - &self, - classes: Vec, - ) -> ProviderResult { - let _ = classes; - unimplemented!("not supported in executor's state") - } - - fn contract_multiproof( - &self, - addresses: Vec, - ) -> ProviderResult { - let _ = addresses; - unimplemented!("not supported in executor's state") - } - - fn storage_multiproof( - &self, - address: katana_primitives::ContractAddress, - key: Vec, - ) -> ProviderResult { - let _ = address; - let _ = key; - unimplemented!("not supported in executor's state") - } -} - -impl StateRootProvider for CachedState { - fn classes_root(&self) -> ProviderResult { - unimplemented!("not supported in executor's state") - } - - fn contracts_root(&self) -> ProviderResult { - unimplemented!("not supported in executor's state") - } +impl StateProofProvider for CachedState {} - fn storage_root(&self, _: katana_primitives::ContractAddress) -> ProviderResult> { - unimplemented!("not supported in executor's state") - } -} +impl StateRootProvider for CachedState {} #[cfg(test)] mod tests { diff --git a/crates/katana/storage/provider/src/error.rs b/crates/katana/storage/provider/src/error.rs index 4445edd795..7ec77fbab8 100644 --- a/crates/katana/storage/provider/src/error.rs +++ b/crates/katana/storage/provider/src/error.rs @@ -96,6 +96,12 @@ pub enum ProviderError { storage_key: StorageKey, }, + #[error("State proof not supported")] + StateProofNotSupported, + + #[error("State root not found")] + StateRootNotFound, + #[error(transparent)] ContractClassCompilation(#[from] ContractClassCompilationError), @@ -110,6 +116,6 @@ pub enum ProviderError { ForkedBackend(#[from] crate::providers::fork::backend::BackendError), /// Any error that is not covered by the other variants. - #[error("soemthing went wrong: {0}")] + #[error("Something went wrong: {0}")] Other(String), } diff --git a/crates/katana/storage/provider/src/providers/fork/state.rs b/crates/katana/storage/provider/src/providers/fork/state.rs index 7ab28ca869..08f64f3d9b 100644 --- a/crates/katana/storage/provider/src/providers/fork/state.rs +++ b/crates/katana/storage/provider/src/providers/fork/state.rs @@ -102,40 +102,8 @@ impl ContractClassProvider for ForkedStateDb { } } -impl StateProofProvider for ForkedStateDb { - fn class_multiproof(&self, _: Vec) -> ProviderResult { - Ok(katana_trie::MultiProof(Default::default())) - } - - fn contract_multiproof( - &self, - _: Vec, - ) -> ProviderResult { - Ok(katana_trie::MultiProof(Default::default())) - } - - fn storage_multiproof( - &self, - _: ContractAddress, - _: Vec, - ) -> ProviderResult { - Ok(katana_trie::MultiProof(Default::default())) - } -} - -impl StateRootProvider for ForkedStateDb { - fn classes_root(&self) -> ProviderResult { - Ok(katana_primitives::Felt::ZERO) - } - - fn contracts_root(&self) -> ProviderResult { - Ok(katana_primitives::Felt::ZERO) - } - - fn storage_root(&self, _: ContractAddress) -> ProviderResult> { - Ok(Some(katana_primitives::Felt::ZERO)) - } -} +impl StateProofProvider for ForkedStateDb {} +impl StateRootProvider for ForkedStateDb {} #[derive(Debug)] pub(super) struct LatestStateProvider(pub(super) Arc); @@ -178,40 +146,8 @@ impl ContractClassProvider for LatestStateProvider { } } -impl StateProofProvider for LatestStateProvider { - fn class_multiproof(&self, _: Vec) -> ProviderResult { - Ok(katana_trie::MultiProof(Default::default())) - } - - fn contract_multiproof( - &self, - _: Vec, - ) -> ProviderResult { - Ok(katana_trie::MultiProof(Default::default())) - } - - fn storage_multiproof( - &self, - _: ContractAddress, - _: Vec, - ) -> ProviderResult { - Ok(katana_trie::MultiProof(Default::default())) - } -} - -impl StateRootProvider for LatestStateProvider { - fn classes_root(&self) -> ProviderResult { - Ok(katana_primitives::Felt::ZERO) - } - - fn contracts_root(&self) -> ProviderResult { - Ok(katana_primitives::Felt::ZERO) - } - - fn storage_root(&self, _: ContractAddress) -> ProviderResult> { - Ok(Some(katana_primitives::Felt::ZERO)) - } -} +impl StateProofProvider for LatestStateProvider {} +impl StateRootProvider for LatestStateProvider {} impl StateProvider for ForkedSnapshot { fn nonce(&self, address: ContractAddress) -> ProviderResult> { @@ -285,40 +221,8 @@ impl ContractClassProvider for ForkedSnapshot { } } -impl StateProofProvider for ForkedSnapshot { - fn class_multiproof(&self, _: Vec) -> ProviderResult { - Ok(katana_trie::MultiProof(Default::default())) - } - - fn contract_multiproof( - &self, - _: Vec, - ) -> ProviderResult { - Ok(katana_trie::MultiProof(Default::default())) - } - - fn storage_multiproof( - &self, - _: ContractAddress, - _: Vec, - ) -> ProviderResult { - Ok(katana_trie::MultiProof(Default::default())) - } -} - -impl StateRootProvider for ForkedSnapshot { - fn classes_root(&self) -> ProviderResult { - Ok(katana_primitives::Felt::ZERO) - } - - fn contracts_root(&self) -> ProviderResult { - Ok(katana_primitives::Felt::ZERO) - } - - fn storage_root(&self, _: ContractAddress) -> ProviderResult> { - Ok(Some(katana_primitives::Felt::ZERO)) - } -} +impl StateProofProvider for ForkedSnapshot {} +impl StateRootProvider for ForkedSnapshot {} #[cfg(test)] mod tests { diff --git a/crates/katana/storage/provider/src/traits/state.rs b/crates/katana/storage/provider/src/traits/state.rs index 36e81d62d0..cfcd64b31c 100644 --- a/crates/katana/storage/provider/src/traits/state.rs +++ b/crates/katana/storage/provider/src/traits/state.rs @@ -7,6 +7,7 @@ use starknet::macros::short_string; use starknet_types_core::hash::StarkHash; use super::contract::ContractClassProvider; +use crate::error::ProviderError; use crate::ProviderResult; #[auto_impl::auto_impl(&, Box, Arc)] @@ -22,13 +23,20 @@ pub trait StateRootProvider: Send + Sync { } /// Retrieves the root of the classes trie. - fn classes_root(&self) -> ProviderResult; + fn classes_root(&self) -> ProviderResult { + Err(ProviderError::StateRootNotFound) + } /// Retrieves the root of the contracts trie. - fn contracts_root(&self) -> ProviderResult; + fn contracts_root(&self) -> ProviderResult { + Err(ProviderError::StateRootNotFound) + } /// Retrieves the root of a contract's storage trie. - fn storage_root(&self, contract: ContractAddress) -> ProviderResult>; + fn storage_root(&self, contract: ContractAddress) -> ProviderResult> { + let _ = contract; + Ok(None) + } } #[auto_impl::auto_impl(&, Box, Arc)] @@ -91,9 +99,19 @@ pub trait StateProofProvider: Send + Sync { &self, address: ContractAddress, key: Vec, - ) -> ProviderResult; + ) -> ProviderResult { + let _ = address; + let _ = key; + Err(ProviderError::StateProofNotSupported) + } - fn contract_multiproof(&self, addresses: Vec) -> ProviderResult; + fn contract_multiproof(&self, addresses: Vec) -> ProviderResult { + let _ = addresses; + Err(ProviderError::StateProofNotSupported) + } - fn class_multiproof(&self, classes: Vec) -> ProviderResult; + fn class_multiproof(&self, classes: Vec) -> ProviderResult { + let _ = classes; + Err(ProviderError::StateProofNotSupported) + } }