Skip to content

Commit a662b3c

Browse files
starknet_committer: create storage tries based on config
1 parent b410637 commit a662b3c

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

crates/starknet_committer/src/db/trie_traversal.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ pub async fn create_original_skeleton_tree<'a, L: Leaf, Layout: NodeLayout<'a, L
338338
Ok(skeleton_tree)
339339
}
340340

341+
/// Creates the original skeleton trees of the storage tries of modified contracts.
342+
/// If [ReaderConfig::build_storage_tries_concurrently] is true, the tries are created concurrently.
343+
/// Otherwise, they are created sequentially.
341344
pub async fn create_storage_tries<'a, Layout: NodeLayoutFor<StarknetStorageValue>>(
342345
storage: &impl Storage,
343346
actual_storage_updates: &HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>,
@@ -349,14 +352,28 @@ where
349352
<Layout as NodeLayoutFor<StarknetStorageValue>>::DbLeaf:
350353
HasStaticPrefix<KeyContext = ContractAddress>,
351354
{
352-
create_storage_tries_sequentially::<Layout>(
353-
storage,
354-
actual_storage_updates,
355-
original_contracts_trie_leaves,
356-
config,
357-
storage_tries_sorted_indices,
358-
)
359-
.await
355+
match config.build_storage_tries_concurrently() {
356+
true => {
357+
create_storage_tries_concurrently::<Layout>(
358+
storage,
359+
actual_storage_updates,
360+
original_contracts_trie_leaves,
361+
config,
362+
storage_tries_sorted_indices,
363+
)
364+
.await
365+
}
366+
false => {
367+
create_storage_tries_sequentially::<Layout>(
368+
storage,
369+
actual_storage_updates,
370+
original_contracts_trie_leaves,
371+
config,
372+
storage_tries_sorted_indices,
373+
)
374+
.await
375+
}
376+
}
360377
}
361378

362379
/// Creates the contracts trie original skeleton.
@@ -449,8 +466,6 @@ where
449466
Ok(storage_tries)
450467
}
451468

452-
// TODO(Nimrod): Remove the `allow(dead_code)` once we use this function.
453-
#[allow(dead_code)]
454469
async fn create_storage_tries_concurrently<'a, Layout: NodeLayoutFor<StarknetStorageValue>>(
455470
storage: &impl Storage,
456471
actual_storage_updates: &HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>,

0 commit comments

Comments
 (0)