@@ -4,8 +4,8 @@ use serde_json::json;
44use starknet_api:: hash:: HashOutput ;
55use starknet_patricia:: patricia_merkle_tree:: filled_tree:: tree:: { FilledTree , FilledTreeImpl } ;
66use starknet_patricia:: patricia_merkle_tree:: node_data:: leaf:: {
7+ Leaf ,
78 LeafModifications ,
8- LeafWithEmptyKeyContext ,
99 SkeletonLeaf ,
1010} ;
1111use starknet_patricia:: patricia_merkle_tree:: original_skeleton_tree:: config:: OriginalSkeletonTreeConfig ;
@@ -15,7 +15,7 @@ use starknet_patricia::patricia_merkle_tree::updated_skeleton_tree::tree::{
1515 UpdatedSkeletonTree ,
1616 UpdatedSkeletonTreeImpl ,
1717} ;
18- use starknet_patricia_storage:: db_object:: EmptyKeyContext ;
18+ use starknet_patricia_storage:: db_object:: HasStaticPrefix ;
1919use starknet_patricia_storage:: map_storage:: MapStorage ;
2020
2121use crate :: db:: facts_db:: db:: FactsNodeLayout ;
@@ -27,10 +27,11 @@ pub async fn tree_computation_flow<L, TH>(
2727 storage : & mut MapStorage ,
2828 root_hash : HashOutput ,
2929 config : impl OriginalSkeletonTreeConfig ,
30+ key_context : & <L as HasStaticPrefix >:: KeyContext ,
3031) -> FilledTreeImpl < L >
3132where
3233 TH : TreeHashFunction < L > + ' static ,
33- L : LeafWithEmptyKeyContext + ' static ,
34+ L : Leaf + ' static ,
3435{
3536 let mut sorted_leaf_indices: Vec < NodeIndex > = leaf_modifications. keys ( ) . copied ( ) . collect ( ) ;
3637 let sorted_leaf_indices = SortedLeafIndices :: new ( & mut sorted_leaf_indices) ;
4142 & config,
4243 & leaf_modifications,
4344 None ,
44- & EmptyKeyContext ,
45+ key_context ,
4546 )
4647 . await
4748 . expect ( "Failed to create the original skeleton tree" ) ;
@@ -68,14 +69,12 @@ where
6869 . expect ( "Failed to create the filled tree" )
6970}
7071
71- pub async fn single_tree_flow_test <
72- L : LeafWithEmptyKeyContext + ' static ,
73- TH : TreeHashFunction < L > + ' static ,
74- > (
72+ pub async fn single_tree_flow_test < L : Leaf + ' static , TH : TreeHashFunction < L > + ' static > (
7573 leaf_modifications : LeafModifications < L > ,
7674 storage : & mut MapStorage ,
7775 root_hash : HashOutput ,
7876 config : impl OriginalSkeletonTreeConfig ,
77+ key_context : & <L as HasStaticPrefix >:: KeyContext ,
7978) -> String {
8079 // Move from leaf number to actual index.
8180 let leaf_modifications = leaf_modifications
@@ -84,7 +83,8 @@ pub async fn single_tree_flow_test<
8483 . collect :: < LeafModifications < L > > ( ) ;
8584
8685 let filled_tree =
87- tree_computation_flow :: < L , TH > ( leaf_modifications, storage, root_hash, config) . await ;
86+ tree_computation_flow :: < L , TH > ( leaf_modifications, storage, root_hash, config, key_context)
87+ . await ;
8888
8989 let hash_result = filled_tree. get_root_hash ( ) ;
9090
@@ -93,7 +93,7 @@ pub async fn single_tree_flow_test<
9393 let json_hash = & json ! ( hash_result. 0 . to_hex_string( ) ) ;
9494 result_map. insert ( "root_hash" , json_hash) ;
9595 // Serlialize the storage modifications.
96- let json_storage = & json ! ( filled_tree. serialize( & EmptyKeyContext ) . unwrap( ) ) ;
96+ let json_storage = & json ! ( filled_tree. serialize( key_context ) . unwrap( ) ) ;
9797 result_map. insert ( "storage_changes" , json_storage) ;
9898 serde_json:: to_string ( & result_map) . expect ( "serialization failed" )
9999}
0 commit comments