11use ethnum:: U256 ;
22use starknet_api:: hash:: HashOutput ;
3+ use starknet_patricia:: patricia_merkle_tree:: filled_tree:: node:: FilledNode ;
4+ use starknet_patricia:: patricia_merkle_tree:: node_data:: inner_node:: {
5+ BinaryData ,
6+ EdgeData ,
7+ EdgePathLength ,
8+ NodeData ,
9+ PathToBottom ,
10+ } ;
11+ use starknet_patricia:: patricia_merkle_tree:: node_data:: leaf:: Leaf ;
312use starknet_patricia_storage:: db_object:: {
413 DBObject ,
514 EmptyDeserializationContext ,
@@ -10,15 +19,7 @@ use starknet_patricia_storage::errors::{DeserializationError, SerializationResul
1019use starknet_patricia_storage:: storage_trait:: { create_db_key, DbKey , DbKeyPrefix , DbValue } ;
1120use starknet_types_core:: felt:: Felt ;
1221
13- use crate :: patricia_merkle_tree:: filled_tree:: node:: { FactDbFilledNode , FilledNode } ;
14- use crate :: patricia_merkle_tree:: node_data:: inner_node:: {
15- BinaryData ,
16- EdgeData ,
17- EdgePathLength ,
18- NodeData ,
19- PathToBottom ,
20- } ;
21- use crate :: patricia_merkle_tree:: node_data:: leaf:: Leaf ;
22+ use crate :: db:: facts_db:: db:: FactDbFilledNode ;
2223
2324pub const FACTS_DB_KEY_SEPARATOR : & [ u8 ] = b":" ;
2425
@@ -46,12 +47,12 @@ impl From<PatriciaPrefix> for DbKeyPrefix {
4647 }
4748}
4849
49- impl < L : Leaf > HasDynamicPrefix for FilledNode < L , HashOutput > {
50+ impl < L : Leaf > HasDynamicPrefix for FactDbFilledNode < L > {
5051 // Inherit the KeyContext from the HasStaticPrefix implementation of the leaf.
5152 type KeyContext = <L as HasStaticPrefix >:: KeyContext ;
5253
5354 fn get_prefix ( & self , key_context : & Self :: KeyContext ) -> DbKeyPrefix {
54- match & self . data {
55+ match & self . 0 . data {
5556 NodeData :: Binary ( _) | NodeData :: Edge ( _) => PatriciaPrefix :: InnerNode ,
5657 NodeData :: Leaf ( _) => PatriciaPrefix :: Leaf ( L :: get_static_prefix ( key_context) ) ,
5758 }
@@ -73,7 +74,7 @@ impl<L: Leaf> DBObject for FactDbFilledNode<L> {
7374 /// - For edge nodes: Concatenates bottom hash, path, and path length.
7475 /// - For leaf nodes: use leaf.serialize() method.
7576 fn serialize ( & self ) -> SerializationResult < DbValue > {
76- match & self . data {
77+ match & self . 0 . data {
7778 NodeData :: Binary ( BinaryData { left_data : left_hash, right_data : right_hash } ) => {
7879 // Serialize left and right hashes to byte arrays.
7980 let left: [ u8 ; SERIALIZE_HASH_BYTES ] = left_hash. 0 . to_bytes_be ( ) ;
@@ -105,14 +106,14 @@ impl<L: Leaf> DBObject for FactDbFilledNode<L> {
105106 deserialize_context : & Self :: DeserializeContext ,
106107 ) -> Result < Self , DeserializationError > {
107108 if deserialize_context. is_leaf {
108- return Ok ( Self {
109+ return Ok ( Self ( FilledNode {
109110 hash : deserialize_context. node_hash ,
110111 data : NodeData :: Leaf ( L :: deserialize ( value, & EmptyDeserializationContext ) ?) ,
111- } ) ;
112+ } ) ) ;
112113 }
113114
114115 if value. 0 . len ( ) == BINARY_BYTES {
115- Ok ( Self {
116+ Ok ( Self ( FilledNode {
116117 hash : deserialize_context. node_hash ,
117118 data : NodeData :: Binary ( BinaryData {
118119 left_data : HashOutput ( Felt :: from_bytes_be_slice (
@@ -122,7 +123,7 @@ impl<L: Leaf> DBObject for FactDbFilledNode<L> {
122123 & value. 0 [ SERIALIZE_HASH_BYTES ..] ,
123124 ) ) ,
124125 } ) ,
125- } )
126+ } ) )
126127 } else {
127128 assert_eq ! (
128129 value. 0 . len( ) ,
@@ -132,7 +133,7 @@ impl<L: Leaf> DBObject for FactDbFilledNode<L> {
132133 EDGE_BYTES ,
133134 BINARY_BYTES
134135 ) ;
135- Ok ( Self {
136+ Ok ( Self ( FilledNode {
136137 hash : deserialize_context. node_hash ,
137138 data : NodeData :: Edge ( EdgeData {
138139 bottom_data : HashOutput ( Felt :: from_bytes_be_slice (
@@ -150,7 +151,7 @@ impl<L: Leaf> DBObject for FactDbFilledNode<L> {
150151 )
151152 . map_err ( |error| DeserializationError :: ValueError ( Box :: new ( error) ) ) ?,
152153 } ) ,
153- } )
154+ } ) )
154155 }
155156 }
156157
0 commit comments