diff --git a/crates/starknet_committer/src/block_committer/commit.rs b/crates/starknet_committer/src/block_committer/commit.rs index 696ff973b4e..d8d4e41f686 100644 --- a/crates/starknet_committer/src/block_committer/commit.rs +++ b/crates/starknet_committer/src/block_committer/commit.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use starknet_api::core::{ClassHash, ContractAddress}; +use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_patricia::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices}; use starknet_patricia::storage::map_storage::MapStorage; use tracing::{info, warn}; @@ -18,7 +18,7 @@ use crate::forest::original_skeleton_forest::{ForestSortedIndices, OriginalSkele use crate::forest::updated_skeleton_forest::UpdatedSkeletonForest; use crate::hash_function::hash::TreeHashFunctionImpl; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; -use crate::patricia_merkle_tree::types::{from_class_hash_for_node_index, Nonce}; +use crate::patricia_merkle_tree::types::from_class_hash_for_node_index; type BlockCommitmentResult = Result; diff --git a/crates/starknet_committer/src/block_committer/input.rs b/crates/starknet_committer/src/block_committer/input.rs index 9318c73d352..184282f30ea 100644 --- a/crates/starknet_committer/src/block_committer/input.rs +++ b/crates/starknet_committer/src/block_committer/input.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, HashSet}; use std::fmt::Debug; -use starknet_api::core::{ClassHash, ContractAddress}; +use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::node_data::leaf::{LeafModifications, SkeletonLeaf}; use starknet_patricia::patricia_merkle_tree::types::NodeIndex; @@ -9,11 +9,7 @@ use starknet_patricia::storage::storage_trait::{StorageKey, StorageValue}; use starknet_types_core::felt::Felt; use tracing::level_filters::LevelFilter; -use crate::patricia_merkle_tree::types::{ - from_class_hash_for_node_index, - CompiledClassHash, - Nonce, -}; +use crate::patricia_merkle_tree::types::{from_class_hash_for_node_index, CompiledClassHash}; #[cfg(test)] #[path = "input_test.rs"] diff --git a/crates/starknet_committer/src/forest/filled_forest.rs b/crates/starknet_committer/src/forest/filled_forest.rs index bf1e66b461e..5797061b8fc 100644 --- a/crates/starknet_committer/src/forest/filled_forest.rs +++ b/crates/starknet_committer/src/forest/filled_forest.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use starknet_api::core::{ClassHash, ContractAddress}; +use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::filled_tree::tree::FilledTree; use starknet_patricia::patricia_merkle_tree::node_data::leaf::LeafModifications; @@ -22,7 +22,6 @@ use crate::patricia_merkle_tree::types::{ ClassesTrie, CompiledClassHash, ContractsTrie, - Nonce, StorageTrieMap, }; diff --git a/crates/starknet_committer/src/forest/skeleton_forest_test.rs b/crates/starknet_committer/src/forest/skeleton_forest_test.rs index 65c9a5a4d45..2cd379b3dc5 100644 --- a/crates/starknet_committer/src/forest/skeleton_forest_test.rs +++ b/crates/starknet_committer/src/forest/skeleton_forest_test.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use pretty_assertions::assert_eq; use rstest::rstest; -use starknet_api::core::{ClassHash, ContractAddress}; +use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::external_test_utils::{ create_32_bytes_entry, @@ -33,7 +33,7 @@ use crate::block_committer::input::{ }; use crate::forest::original_skeleton_forest::{ForestSortedIndices, OriginalSkeletonForest}; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; -use crate::patricia_merkle_tree::types::{CompiledClassHash, Nonce}; +use crate::patricia_merkle_tree::types::CompiledClassHash; macro_rules! compare_skeleton_tree { ($actual_skeleton:expr, $expected_skeleton:expr, $expected_indices:expr) => {{ diff --git a/crates/starknet_committer/src/forest/updated_skeleton_forest.rs b/crates/starknet_committer/src/forest/updated_skeleton_forest.rs index 049fe66e832..ca68fa51bfb 100644 --- a/crates/starknet_committer/src/forest/updated_skeleton_forest.rs +++ b/crates/starknet_committer/src/forest/updated_skeleton_forest.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use starknet_api::core::{ClassHash, ContractAddress}; +use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_patricia::patricia_merkle_tree::node_data::leaf::{LeafModifications, SkeletonLeaf}; use starknet_patricia::patricia_merkle_tree::types::NodeIndex; use starknet_patricia::patricia_merkle_tree::updated_skeleton_tree::tree::{ @@ -13,7 +13,6 @@ use crate::block_committer::input::from_contract_address_for_node_index; use crate::forest::forest_errors::{ForestError, ForestResult}; use crate::forest::original_skeleton_forest::OriginalSkeletonForest; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; -use crate::patricia_merkle_tree::types::Nonce; pub(crate) struct UpdatedSkeletonForest { pub(crate) classes_trie: UpdatedSkeletonTreeImpl, diff --git a/crates/starknet_committer/src/hash_function/hash_test.rs b/crates/starknet_committer/src/hash_function/hash_test.rs index 87c26d1c9dc..c62981de364 100644 --- a/crates/starknet_committer/src/hash_function/hash_test.rs +++ b/crates/starknet_committer/src/hash_function/hash_test.rs @@ -1,6 +1,6 @@ use hex; use rstest::rstest; -use starknet_api::core::ClassHash; +use starknet_api::core::{ClassHash, Nonce}; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::node_data::inner_node::{ BinaryData, @@ -16,7 +16,7 @@ use starknet_types_core::hash::Pedersen; use crate::block_committer::input::StarknetStorageValue; use crate::hash_function::hash::TreeHashFunctionImpl; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; -use crate::patricia_merkle_tree::types::{CompiledClassHash, Nonce}; +use crate::patricia_merkle_tree::types::CompiledClassHash; #[rstest] // Random StateTreeTuples and the expected hash results were generated and computed elsewhere. diff --git a/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_impl.rs b/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_impl.rs index 5d424d3b598..d4ffcacafa7 100644 --- a/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_impl.rs +++ b/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_impl.rs @@ -1,4 +1,4 @@ -use starknet_api::core::ClassHash; +use starknet_api::core::{ClassHash, Nonce}; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::filled_tree::tree::{FilledTree, FilledTreeImpl}; use starknet_patricia::patricia_merkle_tree::node_data::errors::{LeafError, LeafResult}; @@ -9,7 +9,7 @@ use starknet_types_core::felt::Felt; use crate::block_committer::input::StarknetStorageValue; use crate::hash_function::hash::TreeHashFunctionImpl; -use crate::patricia_merkle_tree::types::{CompiledClassHash, Nonce}; +use crate::patricia_merkle_tree::types::CompiledClassHash; #[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct ContractState { diff --git a/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde.rs b/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde.rs index 89a5728c73d..59f3c2a01bb 100644 --- a/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde.rs +++ b/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use serde_json::Value; -use starknet_api::core::ClassHash; +use starknet_api::core::{ClassHash, Nonce}; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::types::SubTreeHeight; use starknet_patricia::storage::db_object::{DBObject, Deserializable}; @@ -11,7 +11,7 @@ use starknet_types_core::felt::Felt; use crate::block_committer::input::StarknetStorageValue; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; -use crate::patricia_merkle_tree::types::{CompiledClassHash, Nonce}; +use crate::patricia_merkle_tree::types::CompiledClassHash; impl DBObject for StarknetStorageValue { /// Serializes the value into a 32-byte vector. @@ -98,7 +98,7 @@ impl Deserializable for ContractState { get_leaf_key(get_key_from_map(&deserialized_map, "storage_commitment_tree")?, "root")?; Ok(Self { - nonce: Nonce::from_hex(&nonce_as_hex)?, + nonce: Nonce(Felt::from_hex(&nonce_as_hex)?), storage_root_hash: HashOutput::from_hex(&root_hash_as_hex)?, class_hash: ClassHash(Felt::from_hex(&class_hash_as_hex)?), }) diff --git a/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde_test.rs b/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde_test.rs index 842d86d5ab8..d85dd070eda 100644 --- a/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde_test.rs +++ b/crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde_test.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; use rstest::rstest; -use starknet_api::core::ClassHash; +use starknet_api::core::{ClassHash, Nonce}; use starknet_api::felt; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::node_data::leaf::Leaf; @@ -11,7 +11,7 @@ use starknet_types_core::felt::Felt; use crate::block_committer::input::StarknetStorageValue; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; -use crate::patricia_merkle_tree::types::{CompiledClassHash, Nonce}; +use crate::patricia_merkle_tree::types::CompiledClassHash; #[rstest] #[case::zero_storage_leaf(StarknetStorageValue(Felt::ZERO))] @@ -63,7 +63,7 @@ fn test_deserialize_contract_state_without_nonce() { let contract_state = ContractState::deserialize(&serialized).unwrap(); // Validate the fields (nonce should be the default "0") - assert_eq!(contract_state.nonce, Nonce::from_hex("0x0").unwrap()); + assert_eq!(contract_state.nonce, Nonce(Felt::ZERO)); assert_eq!(contract_state.class_hash, ClassHash(felt!("0x1234abcd"))); assert_eq!(contract_state.storage_root_hash, HashOutput::from_hex("0x5678").unwrap()); } diff --git a/crates/starknet_committer/src/patricia_merkle_tree/types.rs b/crates/starknet_committer/src/patricia_merkle_tree/types.rs index 6cee87aff3f..9caa08a36ea 100644 --- a/crates/starknet_committer/src/patricia_merkle_tree/types.rs +++ b/crates/starknet_committer/src/patricia_merkle_tree/types.rs @@ -13,11 +13,6 @@ pub fn from_class_hash_for_node_index(class_hash: &ClassHash) -> NodeIndex { NodeIndex::from_leaf_felt(&class_hash.0) } -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -pub struct Nonce(pub Felt); - -impl_from_hex_for_felt_wrapper!(Nonce); - #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub struct CompiledClassHash(pub Felt); diff --git a/crates/starknet_committer_and_os_cli/src/committer_cli/parse_input/cast.rs b/crates/starknet_committer_and_os_cli/src/committer_cli/parse_input/cast.rs index 7d6cdcdc92a..ca218b38257 100644 --- a/crates/starknet_committer_and_os_cli/src/committer_cli/parse_input/cast.rs +++ b/crates/starknet_committer_and_os_cli/src/committer_cli/parse_input/cast.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use starknet_api::core::{ClassHash, ContractAddress}; +use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_committer::block_committer::input::{ ConfigImpl, Input, @@ -8,7 +8,7 @@ use starknet_committer::block_committer::input::{ StarknetStorageValue, StateDiff, }; -use starknet_committer::patricia_merkle_tree::types::{CompiledClassHash, Nonce}; +use starknet_committer::patricia_merkle_tree::types::CompiledClassHash; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::storage::errors::DeserializationError; use starknet_patricia::storage::storage_trait::{StorageKey, StorageValue}; diff --git a/crates/starknet_committer_and_os_cli/src/committer_cli/parse_input/read_test.rs b/crates/starknet_committer_and_os_cli/src/committer_cli/parse_input/read_test.rs index 420ca5971ac..b8c7a84c95d 100644 --- a/crates/starknet_committer_and_os_cli/src/committer_cli/parse_input/read_test.rs +++ b/crates/starknet_committer_and_os_cli/src/committer_cli/parse_input/read_test.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use pretty_assertions::assert_eq; -use starknet_api::core::{ClassHash, ContractAddress}; +use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_committer::block_committer::input::{ ConfigImpl, Input, @@ -9,7 +9,7 @@ use starknet_committer::block_committer::input::{ StarknetStorageValue, StateDiff, }; -use starknet_committer::patricia_merkle_tree::types::{CompiledClassHash, Nonce}; +use starknet_committer::patricia_merkle_tree::types::CompiledClassHash; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::storage::errors::DeserializationError; use starknet_patricia::storage::storage_trait::{StorageKey, StorageValue}; diff --git a/crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs b/crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs index a457f43f0e9..96e7c391f4b 100644 --- a/crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs +++ b/crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use ethnum::U256; use serde_json::json; -use starknet_api::core::{ClassHash, ContractAddress}; +use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_committer::block_committer::input::{ StarknetStorageKey, StarknetStorageValue, @@ -13,7 +13,7 @@ use starknet_committer::forest::filled_forest::FilledForest; use starknet_committer::hash_function::hash::TreeHashFunctionImpl; use starknet_committer::patricia_merkle_tree::leaf::leaf_impl::ContractState; use starknet_committer::patricia_merkle_tree::tree::OriginalSkeletonStorageTrieConfig; -use starknet_committer::patricia_merkle_tree::types::{CompiledClassHash, Nonce}; +use starknet_committer::patricia_merkle_tree::types::CompiledClassHash; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::external_test_utils::single_tree_flow_test; use starknet_patricia::patricia_merkle_tree::filled_tree::node::FilledNode; diff --git a/crates/starknet_committer_and_os_cli/src/committer_cli/tests/utils/random_structs.rs b/crates/starknet_committer_and_os_cli/src/committer_cli/tests/utils/random_structs.rs index 6a907098d2b..91713ac74e6 100644 --- a/crates/starknet_committer_and_os_cli/src/committer_cli/tests/utils/random_structs.rs +++ b/crates/starknet_committer_and_os_cli/src/committer_cli/tests/utils/random_structs.rs @@ -6,7 +6,7 @@ use rand::prelude::IteratorRandom; use rand::Rng; use rand_distr::num_traits::ToPrimitive; use rand_distr::{Distribution, Geometric}; -use starknet_api::core::{ClassHash, ContractAddress, PATRICIA_KEY_UPPER_BOUND}; +use starknet_api::core::{ClassHash, ContractAddress, Nonce, PATRICIA_KEY_UPPER_BOUND}; use starknet_api::felt; use starknet_committer::block_committer::input::StarknetStorageValue; use starknet_committer::forest::filled_forest::FilledForest; @@ -15,7 +15,6 @@ use starknet_committer::patricia_merkle_tree::types::{ ClassesTrie, CompiledClassHash, ContractsTrie, - Nonce, StorageTrie, StorageTrieMap, };