diff --git a/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs b/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs index bb43b99c..b6bb5d7e 100644 --- a/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs +++ b/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs @@ -1,13 +1,11 @@ use super::OriginalSkeletonTreeImpl; -use crate::block_committer::input::StarknetStorageValue; use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; -use crate::patricia_merkle_tree::filled_tree::node::{ClassHash, CompiledClassHash, Nonce}; use crate::patricia_merkle_tree::internal_test_utils::OriginalSkeletonMockTrieConfig; use crate::patricia_merkle_tree::internal_test_utils::{small_tree_index_to_full, MockLeaf}; use crate::patricia_merkle_tree::node_data::inner_node::EdgePath; use crate::patricia_merkle_tree::node_data::inner_node::{EdgePathLength, PathToBottom}; -use crate::patricia_merkle_tree::node_data::leaf::{ContractState, LeafModifications}; +use crate::patricia_merkle_tree::node_data::leaf::LeafModifications; use crate::patricia_merkle_tree::original_skeleton_tree::create_tree::SubTree; use crate::patricia_merkle_tree::original_skeleton_tree::node::OriginalSkeletonNode; use crate::patricia_merkle_tree::original_skeleton_tree::tree::OriginalSkeletonTree; @@ -422,26 +420,6 @@ pub(crate) fn create_mock_leaf_entry(val: u128) -> (StorageKey, StorageValue) { (leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize()) } -pub(crate) fn create_storage_leaf_entry(val: u128) -> (StorageKey, StorageValue) { - let leaf = StarknetStorageValue(Felt::from(val)); - (leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize()) -} - -pub(crate) fn create_compiled_class_leaf_entry(val: u128) -> (StorageKey, StorageValue) { - let leaf = CompiledClassHash(Felt::from(val)); - (leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize()) -} - -pub(crate) fn create_contract_state_leaf_entry(val: u128) -> (StorageKey, StorageValue) { - let felt = Felt::from(val); - let leaf = ContractState { - nonce: Nonce(felt), - storage_root_hash: HashOutput(felt), - class_hash: ClassHash(felt), - }; - (leaf.get_db_key(&felt.to_bytes_be()), leaf.serialize()) -} - fn create_patricia_key(val: u128) -> StorageKey { create_db_key( StarknetPrefix::InnerNode.to_storage_prefix(), diff --git a/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs b/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs index 3e9f019f..b1037eb2 100644 --- a/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs +++ b/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs @@ -11,22 +11,21 @@ use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::filled_tree::node::{ClassHash, CompiledClassHash, Nonce}; use crate::patricia_merkle_tree::node_data::leaf::ContractState; +use crate::patricia_merkle_tree::original_skeleton_tree::create_tree::create_tree_test::create_root_edge_entry; use crate::patricia_merkle_tree::original_skeleton_tree::create_tree::create_tree_test::{ create_32_bytes_entry, create_binary_entry, create_binary_skeleton_node, create_edge_entry, create_edge_skeleton_node, create_expected_skeleton_nodes, create_unmodified_subtree_skeleton_node, }; -use crate::patricia_merkle_tree::original_skeleton_tree::create_tree::create_tree_test::{ - create_compiled_class_leaf_entry, create_contract_state_leaf_entry, create_root_edge_entry, - create_storage_leaf_entry, -}; use crate::patricia_merkle_tree::types::NodeIndex; use crate::patricia_merkle_tree::types::SubTreeHeight; use crate::patricia_merkle_tree::{ original_skeleton_tree::skeleton_forest::ForestSortedIndices, original_skeleton_tree::tree::OriginalSkeletonTreeImpl, types::SortedLeafIndices, }; +use crate::storage::db_object::DBObject; use crate::storage::map_storage::MapStorage; +use crate::storage::storage_trait::{StorageKey, StorageValue}; macro_rules! compare_skeleton_tree { ($actual_skeleton:expr, $expected_skeleton:expr, $expected_indices:expr) => {{ @@ -38,6 +37,26 @@ macro_rules! compare_skeleton_tree { }}; } +pub(crate) fn create_storage_leaf_entry(val: u128) -> (StorageKey, StorageValue) { + let leaf = StarknetStorageValue(Felt::from(val)); + (leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize()) +} + +pub(crate) fn create_compiled_class_leaf_entry(val: u128) -> (StorageKey, StorageValue) { + let leaf = CompiledClassHash(Felt::from(val)); + (leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize()) +} + +pub(crate) fn create_contract_state_leaf_entry(val: u128) -> (StorageKey, StorageValue) { + let felt = Felt::from(val); + let leaf = ContractState { + nonce: Nonce(felt), + storage_root_hash: HashOutput(felt), + class_hash: ClassHash(felt), + }; + (leaf.get_db_key(&felt.to_bytes_be()), leaf.serialize()) +} + // This test assumes for simplicity that hash is addition (i.e hash(a,b) = a + b). // I.e., the value of a binary node is the sum of its children's values, and the value of an edge // node is the sum of its path, bottom value and path length.