Skip to content

Commit 1bb4a46

Browse files
committed
starknet_committer: define StoragePathsReadTask
1 parent 4d43ae3 commit 1bb4a46

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

crates/starknet_committer/src/db/trie_traversal.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,48 @@ where
850850
}
851851
}
852852

853+
/// Storage task for fetching Patricia paths in a single storage trie.
854+
struct StoragePathsReadTask<'indices, Layout: NodeLayoutFor<StarknetStorageValue>> {
855+
address: ContractAddress,
856+
storage_root_hash: HashOutput,
857+
sorted_leaf_indices: SortedLeafIndices<'indices>,
858+
_layout: PhantomData<Layout>,
859+
}
860+
861+
impl<'indices, S, Layout> StorageTaskOutput<S> for StoragePathsReadTask<'indices, Layout>
862+
where
863+
S: ImmutableReadOnlyStorage,
864+
Layout: NodeLayoutFor<StarknetStorageValue> + Send + 'static,
865+
{
866+
type Output = TraversalResult<(ContractAddress, PreimageMap)>;
867+
}
868+
869+
#[async_trait]
870+
impl<'indices, 'storage, S, Layout> StorageTask<'storage, S>
871+
for StoragePathsReadTask<'indices, Layout>
872+
where
873+
S: ImmutableReadOnlyStorage + 'storage,
874+
Layout: NodeLayoutFor<StarknetStorageValue> + Send + 'static,
875+
<Layout as NodeLayoutFor<StarknetStorageValue>>::DbLeaf:
876+
HasStaticPrefix<KeyContext = ContractAddress>,
877+
{
878+
async fn run_with_storage(
879+
self,
880+
storage: &mut ReadsCollectorStorage<'storage, S>,
881+
) -> Self::Output {
882+
let leaves = None;
883+
let proof = fetch_patricia_paths::<Layout::DbLeaf, Layout>(
884+
storage,
885+
self.storage_root_hash,
886+
self.sorted_leaf_indices,
887+
leaves,
888+
&self.address,
889+
)
890+
.await?;
891+
Ok((self.address, proof))
892+
}
893+
}
894+
853895
async fn create_storage_tries_concurrently<'a, S, Layout>(
854896
storage: &mut S,
855897
actual_storage_updates: &HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>,

0 commit comments

Comments
 (0)