@@ -4,7 +4,7 @@ use std::fmt::Debug;
44
55use starknet_api:: core:: ContractAddress ;
66use starknet_api:: hash:: HashOutput ;
7- use starknet_patricia:: db_layout:: { NodeLayout , TrieType } ;
7+ use starknet_patricia:: db_layout:: { NodeLayout , NodeLayoutFor , TrieType } ;
88use starknet_patricia:: patricia_merkle_tree:: filled_tree:: node:: FilledNode ;
99use starknet_patricia:: patricia_merkle_tree:: node_data:: inner_node:: {
1010 BinaryData ,
@@ -341,11 +341,7 @@ pub async fn create_original_skeleton_tree<'a, L: Leaf, Layout: NodeLayout<'a, L
341341 Ok ( skeleton_tree)
342342}
343343
344- pub async fn create_storage_tries <
345- ' a ,
346- L : Leaf + From < StarknetStorageValue > ,
347- Layout : NodeLayout < ' a , L > ,
348- > (
344+ pub async fn create_storage_tries < ' a , Layout : NodeLayoutFor < StarknetStorageValue > > (
349345 storage : & mut impl Storage ,
350346 actual_storage_updates : & HashMap < ContractAddress , LeafModifications < StarknetStorageValue > > ,
351347 original_contracts_trie_leaves : & HashMap < NodeIndex , ContractState > ,
@@ -364,14 +360,14 @@ pub async fn create_storage_tries<
364360 config. warn_on_trivial_modifications ( ) ,
365361 ) ;
366362
367- let original_skeleton = create_original_skeleton_tree :: < L , Layout > (
363+ let original_skeleton = create_original_skeleton_tree :: < Layout :: DbLeaf , Layout > (
368364 storage,
369365 contract_state. storage_root_hash ,
370366 * sorted_leaf_indices,
371367 & config,
372368 // TODO(Ariel): Change `LeafModifications` in `actual_storage_updates` to be an
373369 // iterator over borrowed data so that the conversion below is costless.
374- & updates. iter ( ) . map ( |( idx, value) | ( * idx, L :: from ( * value) ) ) . collect ( ) ,
370+ & updates. iter ( ) . map ( |( idx, value) | ( * idx, Layout :: DbLeaf :: from ( * value) ) ) . collect ( ) ,
375371 None ,
376372 & Layout :: generate_key_context ( TrieType :: StorageTrie ( * address) ) ,
377373 )
@@ -383,15 +379,15 @@ pub async fn create_storage_tries<
383379
384380/// Creates the contracts trie original skeleton.
385381/// Also returns the previous contracts state of the modified contracts.
386- pub async fn create_contracts_trie < ' a , L : Leaf + Into < ContractState > , Layout : NodeLayout < ' a , L > > (
382+ pub async fn create_contracts_trie < ' a , Layout : NodeLayoutFor < ContractState > > (
387383 storage : & mut impl Storage ,
388384 contracts_trie_root_hash : HashOutput ,
389385 contracts_trie_sorted_indices : SortedLeafIndices < ' a > ,
390386) -> ForestResult < ( OriginalSkeletonTreeImpl < ' a > , HashMap < NodeIndex , ContractState > ) > {
391387 let config = OriginalSkeletonTrieConfig :: new_for_contracts_trie ( ) ;
392388
393389 let mut leaves = HashMap :: new ( ) ;
394- let skeleton_tree = create_original_skeleton_tree :: < L , Layout > (
390+ let skeleton_tree = create_original_skeleton_tree :: < Layout :: DbLeaf , Layout > (
395391 storage,
396392 contracts_trie_root_hash,
397393 contracts_trie_sorted_indices,
@@ -408,11 +404,7 @@ pub async fn create_contracts_trie<'a, L: Leaf + Into<ContractState>, Layout: No
408404 Ok ( ( skeleton_tree, leaves) )
409405}
410406
411- pub async fn create_classes_trie <
412- ' a ,
413- L : Leaf + From < CompiledClassHash > ,
414- Layout : NodeLayout < ' a , L > ,
415- > (
407+ pub async fn create_classes_trie < ' a , Layout : NodeLayoutFor < CompiledClassHash > > (
416408 storage : & mut impl Storage ,
417409 actual_classes_updates : & LeafModifications < CompiledClassHash > ,
418410 classes_trie_root_hash : HashOutput ,
@@ -423,14 +415,17 @@ pub async fn create_classes_trie<
423415 config. warn_on_trivial_modifications ( ) ,
424416 ) ;
425417
426- Ok ( create_original_skeleton_tree :: < L , Layout > (
418+ Ok ( create_original_skeleton_tree :: < Layout :: DbLeaf , Layout > (
427419 storage,
428420 classes_trie_root_hash,
429421 contracts_trie_sorted_indices,
430422 & config,
431423 // TODO(Ariel): Change `actual_classes_updates` to be an iterator over borrowed data so
432424 // that the conversion below is costless.
433- & actual_classes_updates. iter ( ) . map ( |( idx, value) | ( * idx, L :: from ( * value) ) ) . collect ( ) ,
425+ & actual_classes_updates
426+ . iter ( )
427+ . map ( |( idx, value) | ( * idx, Layout :: DbLeaf :: from ( * value) ) )
428+ . collect ( ) ,
434429 None ,
435430 & Layout :: generate_key_context ( TrieType :: ClassesTrie ) ,
436431 )
0 commit comments