@@ -361,7 +361,7 @@ pub async fn create_storage_tries<'a, Layout: NodeLayoutFor<StarknetStorageValue
361361 original_contracts_trie_leaves : & HashMap < NodeIndex , ContractState > ,
362362 config : & ReaderConfig ,
363363 storage_tries_sorted_indices : & HashMap < ContractAddress , SortedLeafIndices < ' a > > ,
364- ) -> ForestResult < HashMap < ContractAddress , OriginalSkeletonTreeImpl < ' a > > >
364+ ) -> ForestResult < ( HashMap < ContractAddress , OriginalSkeletonTreeImpl < ' a > > , DbHashMap ) >
365365where
366366 <Layout as NodeLayoutFor < StarknetStorageValue > >:: DbLeaf :
367367 HasStaticPrefix < KeyContext = ContractAddress > ,
@@ -460,14 +460,15 @@ async fn create_storage_tries_sequentially<'a, Layout: NodeLayoutFor<StarknetSto
460460 original_contracts_trie_leaves : & HashMap < NodeIndex , ContractState > ,
461461 config : & ReaderConfig ,
462462 storage_tries_sorted_indices : & HashMap < ContractAddress , SortedLeafIndices < ' a > > ,
463- ) -> ForestResult < HashMap < ContractAddress , OriginalSkeletonTreeImpl < ' a > > >
463+ ) -> ForestResult < ( HashMap < ContractAddress , OriginalSkeletonTreeImpl < ' a > > , DbHashMap ) >
464464where
465465 <Layout as NodeLayoutFor < StarknetStorageValue > >:: DbLeaf :
466466 HasStaticPrefix < KeyContext = ContractAddress > ,
467467{
468+ let mut all_siblings = DbHashMap :: new ( ) ;
468469 let mut storage_tries = HashMap :: new ( ) ;
469470 for ( address, updates) in actual_storage_updates {
470- let ( address, original_skeleton) = create_storage_trie_for_contract :: < Layout > (
471+ let ( address, original_skeleton, siblings ) = create_storage_trie_for_contract :: < Layout > (
471472 storage,
472473 * address,
473474 updates,
@@ -478,8 +479,9 @@ where
478479 . await ?;
479480
480481 storage_tries. insert ( address, original_skeleton) ;
482+ all_siblings. extend ( siblings) ;
481483 }
482- Ok ( storage_tries)
484+ Ok ( ( storage_tries, all_siblings ) )
483485}
484486
485487async fn create_storage_tries_concurrently < ' a , Layout : NodeLayoutFor < StarknetStorageValue > > (
@@ -488,11 +490,12 @@ async fn create_storage_tries_concurrently<'a, Layout: NodeLayoutFor<StarknetSto
488490 original_contracts_trie_leaves : & HashMap < NodeIndex , ContractState > ,
489491 config : & ReaderConfig ,
490492 storage_tries_sorted_indices : & HashMap < ContractAddress , SortedLeafIndices < ' a > > ,
491- ) -> ForestResult < HashMap < ContractAddress , OriginalSkeletonTreeImpl < ' a > > >
493+ ) -> ForestResult < ( HashMap < ContractAddress , OriginalSkeletonTreeImpl < ' a > > , DbHashMap ) >
492494where
493495 <Layout as NodeLayoutFor < StarknetStorageValue > >:: DbLeaf :
494496 HasStaticPrefix < KeyContext = ContractAddress > ,
495497{
498+ let mut all_siblings = DbHashMap :: new ( ) ;
496499 let mut futures = FuturesUnordered :: new ( ) ;
497500 let mut storage_tries = HashMap :: new ( ) ;
498501
@@ -513,11 +516,12 @@ where
513516
514517 // Collect all results as they complete.
515518 while let Some ( result) = futures. next ( ) . await {
516- let ( address, original_skeleton) = result?;
519+ let ( address, original_skeleton, siblings ) = result?;
517520 storage_tries. insert ( address, original_skeleton) ;
521+ all_siblings. extend ( siblings) ;
518522 }
519523
520- Ok ( storage_tries)
524+ Ok ( ( storage_tries, all_siblings ) )
521525}
522526
523527/// Helper function to create a storage trie for a single contract.
@@ -528,11 +532,12 @@ async fn create_storage_trie_for_contract<'a, Layout: NodeLayoutFor<StarknetStor
528532 original_contracts_trie_leaves : & HashMap < NodeIndex , ContractState > ,
529533 storage_tries_sorted_indices : & HashMap < ContractAddress , SortedLeafIndices < ' a > > ,
530534 warn_on_trivial_modifications : bool ,
531- ) -> ForestResult < ( ContractAddress , OriginalSkeletonTreeImpl < ' a > ) >
535+ ) -> ForestResult < ( ContractAddress , OriginalSkeletonTreeImpl < ' a > , DbHashMap ) >
532536where
533537 <Layout as NodeLayoutFor < StarknetStorageValue > >:: DbLeaf :
534538 HasStaticPrefix < KeyContext = ContractAddress > ,
535539{
540+ let mut siblings_map = DbHashMap :: new ( ) ;
536541 // Extract data needed for this contract.
537542 let sorted_leaf_indices = * storage_tries_sorted_indices
538543 . get ( & address)
@@ -558,10 +563,10 @@ where
558563 & trie_config,
559564 & leaf_modifications,
560565 None ,
561- None ,
566+ Some ( & mut siblings_map ) ,
562567 & address,
563568 )
564569 . await ?;
565570
566- Ok ( ( address, original_skeleton) )
571+ Ok ( ( address, original_skeleton, siblings_map ) )
567572}
0 commit comments