@@ -11,50 +11,18 @@ use starknet_committer::db::facts_db::create_facts_tree::get_leaves;
1111use starknet_committer:: patricia_merkle_tree:: leaf:: leaf_impl:: ContractState ;
1212use starknet_committer:: patricia_merkle_tree:: tree:: fetch_previous_and_new_patricia_paths;
1313use starknet_committer:: patricia_merkle_tree:: types:: RootHashes ;
14+ // `CommitmentInfo` and `StateCommitmentInfos` were relocated to `starknet_committer` so that
15+ // lower layers (e.g. `apollo_storage`) can store them without depending on `starknet_os`. They
16+ // are re-exported here to keep this module's public API stable for OS consumers.
17+ pub use starknet_committer:: patricia_merkle_tree:: types:: { CommitmentInfo , StateCommitmentInfos } ;
1418use starknet_patricia:: patricia_merkle_tree:: node_data:: inner_node:: flatten_preimages;
1519use starknet_patricia:: patricia_merkle_tree:: original_skeleton_tree:: errors:: OriginalSkeletonTreeError ;
1620use starknet_patricia:: patricia_merkle_tree:: traversal:: TraversalError ;
1721use starknet_patricia:: patricia_merkle_tree:: types:: { NodeIndex , SortedLeafIndices , SubTreeHeight } ;
1822use starknet_patricia_storage:: db_object:: EmptyKeyContext ;
1923use starknet_patricia_storage:: map_storage:: MapStorage ;
20- use starknet_types_core:: felt:: Felt ;
2124use thiserror:: Error ;
2225
23- #[ cfg_attr( feature = "deserialize" , derive( serde:: Deserialize ) ) ]
24- #[ cfg_attr( feature = "deserialize" , serde( deny_unknown_fields) ) ]
25- #[ derive( Debug ) ]
26- pub struct CommitmentInfo {
27- pub previous_root : HashOutput ,
28- pub updated_root : HashOutput ,
29- pub tree_height : SubTreeHeight ,
30- // TODO(Dori, 1/8/2025): The value type here should probably be more specific (NodeData<L> for
31- // L: Leaf). This poses a problem in deserialization, as a serialized edge node and a
32- // serialized contract state leaf are both currently vectors of 3 field elements; as the
33- // semantics of the values are unimportant for the OS commitments, we make do with a vector
34- // of field elements as values for now.
35- pub commitment_facts : HashMap < HashOutput , Vec < Felt > > ,
36- }
37-
38- #[ cfg( any( feature = "testing" , test) ) ]
39- impl Default for CommitmentInfo {
40- fn default ( ) -> CommitmentInfo {
41- CommitmentInfo {
42- previous_root : HashOutput :: default ( ) ,
43- updated_root : HashOutput :: default ( ) ,
44- tree_height : SubTreeHeight :: ACTUAL_HEIGHT ,
45- commitment_facts : HashMap :: default ( ) ,
46- }
47- }
48- }
49-
50- // TODO(Aviv): Use this struct in `OsBlockInput`
51- /// Contains all commitment information for a block's state trees.
52- pub struct StateCommitmentInfos {
53- pub contracts_trie_commitment_info : CommitmentInfo ,
54- pub classes_trie_commitment_info : CommitmentInfo ,
55- pub storage_tries_commitment_infos : HashMap < ContractAddress , CommitmentInfo > ,
56- }
57-
5826/// Error type for commitment infos creation.
5927#[ derive( Debug , Error ) ]
6028pub enum CommitmentInfosError {
@@ -68,6 +36,10 @@ pub enum CommitmentInfosError {
6836
6937/// Creates the commitment infos for the OS from previous and new state roots and the
7038/// keys that were read during execution.
39+ // TODO(ItamarS): Temporary — to be deleted once the committer builds `StateCommitmentInfos` from
40+ // its own storage; tests against that new committer API will be added then. Kept here (as a free
41+ // function rather than an inherent method) because the struct now lives in `starknet_committer`
42+ // and the orphan rule forbids an inherent impl on a foreign type.
7143pub async fn build_state_commitment_infos (
7244 previous_state_roots : & StateRoots ,
7345 new_state_roots : & StateRoots ,
0 commit comments