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
2324// Const describe the size of the serialized node.
2425pub const SERIALIZE_HASH_BYTES : usize = 32 ;
@@ -44,12 +45,12 @@ impl From<PatriciaPrefix> for DbKeyPrefix {
4445 }
4546}
4647
47- impl < L : Leaf > HasDynamicPrefix for FilledNode < L , HashOutput > {
48+ impl < L : Leaf > HasDynamicPrefix for FactDbFilledNode < L > {
4849 // Inherit the KeyContext from the HasStaticPrefix implementation of the leaf.
4950 type KeyContext = <L as HasStaticPrefix >:: KeyContext ;
5051
5152 fn get_prefix ( & self , key_context : & Self :: KeyContext ) -> DbKeyPrefix {
52- match & self . data {
53+ match & self . 0 . data {
5354 NodeData :: Binary ( _) | NodeData :: Edge ( _) => PatriciaPrefix :: InnerNode ,
5455 NodeData :: Leaf ( _) => PatriciaPrefix :: Leaf ( L :: get_static_prefix ( key_context) ) ,
5556 }
@@ -71,7 +72,7 @@ impl<L: Leaf> DBObject for FactDbFilledNode<L> {
7172 /// - For edge nodes: Concatenates bottom hash, path, and path length.
7273 /// - For leaf nodes: use leaf.serialize() method.
7374 fn serialize ( & self ) -> SerializationResult < DbValue > {
74- match & self . data {
75+ match & self . 0 . data {
7576 NodeData :: Binary ( BinaryData { left_data : left_hash, right_data : right_hash } ) => {
7677 // Serialize left and right hashes to byte arrays.
7778 let left: [ u8 ; SERIALIZE_HASH_BYTES ] = left_hash. 0 . to_bytes_be ( ) ;
@@ -103,14 +104,14 @@ impl<L: Leaf> DBObject for FactDbFilledNode<L> {
103104 deserialize_context : & Self :: DeserializeContext ,
104105 ) -> Result < Self , DeserializationError > {
105106 if deserialize_context. is_leaf {
106- return Ok ( Self {
107+ return Ok ( Self ( FilledNode {
107108 hash : deserialize_context. node_hash ,
108109 data : NodeData :: Leaf ( L :: deserialize ( value, & EmptyDeserializationContext ) ?) ,
109- } ) ;
110+ } ) ) ;
110111 }
111112
112113 if value. 0 . len ( ) == BINARY_BYTES {
113- Ok ( Self {
114+ Ok ( Self ( FilledNode {
114115 hash : deserialize_context. node_hash ,
115116 data : NodeData :: Binary ( BinaryData {
116117 left_data : HashOutput ( Felt :: from_bytes_be_slice (
@@ -120,7 +121,7 @@ impl<L: Leaf> DBObject for FactDbFilledNode<L> {
120121 & value. 0 [ SERIALIZE_HASH_BYTES ..] ,
121122 ) ) ,
122123 } ) ,
123- } )
124+ } ) )
124125 } else {
125126 assert_eq ! (
126127 value. 0 . len( ) ,
@@ -130,7 +131,7 @@ impl<L: Leaf> DBObject for FactDbFilledNode<L> {
130131 EDGE_BYTES ,
131132 BINARY_BYTES
132133 ) ;
133- Ok ( Self {
134+ Ok ( Self ( FilledNode {
134135 hash : deserialize_context. node_hash ,
135136 data : NodeData :: Edge ( EdgeData {
136137 bottom_data : HashOutput ( Felt :: from_bytes_be_slice (
@@ -148,7 +149,7 @@ impl<L: Leaf> DBObject for FactDbFilledNode<L> {
148149 )
149150 . map_err ( |error| DeserializationError :: ValueError ( Box :: new ( error) ) ) ?,
150151 } ) ,
151- } )
152+ } ) )
152153 }
153154 }
154155
0 commit comments