Skip to content

Commit 0240fc1

Browse files
starknet_committer: read in parallel for supported storages
1 parent 2bc269b commit 0240fc1

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

crates/starknet_committer/src/db/trie_traversal.rs

Lines changed: 25 additions & 8 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 the storage supports async operations, 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 storage.get_async_self() {
356+
Some(async_storage) => {
357+
create_storage_tries_concurrently::<Layout>(
358+
&async_storage,
359+
actual_storage_updates,
360+
original_contracts_trie_leaves,
361+
config,
362+
storage_tries_sorted_indices,
363+
)
364+
.await
365+
}
366+
None => {
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.

0 commit comments

Comments
 (0)