Skip to content

Commit 48dd3a9

Browse files
starknet_patricia,starknet_committer: dont pass storage mut when not needed
1 parent 42bb057 commit 48dd3a9

File tree

14 files changed

+27
-27
lines changed

14 files changed

+27
-27
lines changed

crates/starknet_committer/src/db/create_original_skeleton_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub(crate) fn tree_of_height_4_with_long_edge() -> CreateTreeCase {
161161
}
162162

163163
pub(crate) async fn test_create_original_skeleton<L, Layout>(
164-
storage: &mut MapStorage,
164+
storage: &MapStorage,
165165
leaf_modifications: &LeafModifications<L>,
166166
root_hash: HashOutput,
167167
expected_skeleton_nodes: &HashMap<NodeIndex, OriginalSkeletonNode>,

crates/starknet_committer/src/db/facts_db/create_facts_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub mod create_facts_tree_test;
1919
/// Note that ATM, the Rust committer does not manage history and is not used for storage proofs;
2020
/// Thus, this function assumes facts layout.
2121
pub async fn get_leaves<'a, L: Leaf>(
22-
storage: &mut impl Storage,
22+
storage: &impl Storage,
2323
root_hash: HashOutput,
2424
sorted_leaf_indices: SortedLeafIndices<'a>,
2525
key_context: &<L as HasStaticPrefix>::KeyContext,

crates/starknet_committer/src/db/facts_db/create_facts_tree_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use crate::db::facts_db::db::FactsNodeLayout;
1313
#[rstest]
1414
#[tokio::test]
1515
async fn test_create_tree_facts_layout(
16-
#[case] mut case: CreateTreeCase,
16+
#[case] case: CreateTreeCase,
1717
#[values(true, false)] compare_modified_leaves: bool,
1818
) {
1919
test_create_original_skeleton::<MockLeaf, FactsNodeLayout>(
20-
&mut case.storage,
20+
&case.storage,
2121
&case.leaf_modifications,
2222
case.root_hash,
2323
&case.expected_skeleton_nodes,

crates/starknet_committer/src/db/facts_db/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<S: Storage> ForestReader for FactsDb<S> {
113113
config: ReaderConfig,
114114
) -> ForestResult<(OriginalSkeletonForest<'a>, HashMap<NodeIndex, ContractState>)> {
115115
read_forest::<S, FactsNodeLayout>(
116-
&mut self.storage,
116+
&self.storage,
117117
roots,
118118
storage_updates,
119119
classes_updates,

crates/starknet_committer/src/db/facts_db/traversal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub mod traversal_test;
2525
/// If `leaves` is not `None`, it also fetches the modified leaves and inserts them into the
2626
/// provided map.
2727
pub async fn fetch_patricia_paths<L: Leaf>(
28-
storage: &mut impl Storage,
28+
storage: &impl Storage,
2929
root_hash: HashOutput,
3030
sorted_leaf_indices: SortedLeafIndices<'_>,
3131
leaves: Option<&mut HashMap<NodeIndex, L>>,
@@ -60,7 +60,7 @@ pub async fn fetch_patricia_paths<L: Leaf>(
6060
/// If `leaves` is not `None`, it also fetches the modified leaves and inserts them into the
6161
/// provided map.
6262
pub(crate) async fn fetch_patricia_paths_inner<'a, L: Leaf>(
63-
storage: &mut impl Storage,
63+
storage: &impl Storage,
6464
subtrees: Vec<FactsSubTree<'a>>,
6565
witnesses: &mut PreimageMap,
6666
mut leaves: Option<&mut HashMap<NodeIndex, L>>,

crates/starknet_committer/src/db/facts_db/traversal_test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ async fn test_fetch_patricia_paths_inner_impl(
5858
height: SubTreeHeight,
5959
expected_nodes: PreimageMap,
6060
) {
61-
let mut storage = storage;
6261
let expected_fetched_leaves = leaf_indices
6362
.iter()
6463
.map(|&idx| {
@@ -84,7 +83,7 @@ async fn test_fetch_patricia_paths_inner_impl(
8483
let mut fetched_leaves = HashMap::new();
8584

8685
fetch_patricia_paths_inner::<MockLeaf>(
87-
&mut storage,
86+
&storage,
8887
vec![main_subtree],
8988
&mut nodes,
9089
Some(&mut fetched_leaves),

crates/starknet_committer/src/db/forest_trait.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub trait ForestMetadata {
6262
}
6363
}
6464

65+
// TODO(Nimrod): Make this trait take `&self` instead of `&mut self`.
6566
/// Trait for reading an original skeleton forest from some storage.
6667
/// The implementation may depend on the underlying storage layout.
6768
#[async_trait]
@@ -86,7 +87,7 @@ pub trait ForestReader {
8687

8788
/// Helper function containing layout-common read logic.
8889
pub(crate) async fn read_forest<'a, S, Layout>(
89-
storage: &mut S,
90+
storage: &S,
9091
roots: StateRoots,
9192
storage_updates: &'a HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>,
9293
classes_updates: &'a LeafModifications<CompiledClassHash>,

crates/starknet_committer/src/db/index_db/create_index_tree_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async fn test_create_tree_index_layout(
3333
#[case] mut case: CreateTreeCase,
3434
#[values(true, false)] compare_modified_leaves: bool,
3535
) {
36-
let mut storage = convert_facts_db_to_index_db::<MockLeaf, MockLeaf, EmptyKeyContext>(
36+
let storage = convert_facts_db_to_index_db::<MockLeaf, MockLeaf, EmptyKeyContext>(
3737
&mut case.storage,
3838
case.root_hash,
3939
&EmptyKeyContext,
@@ -42,7 +42,7 @@ async fn test_create_tree_index_layout(
4242
.await;
4343

4444
test_create_original_skeleton::<MockLeaf, IndexNodeLayout>(
45-
&mut storage,
45+
&storage,
4646
&case.leaf_modifications,
4747
case.root_hash,
4848
&case.expected_skeleton_nodes,

crates/starknet_committer/src/db/index_db/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<S: Storage> ForestReader for IndexDb<S> {
183183
config: ReaderConfig,
184184
) -> ForestResult<(OriginalSkeletonForest<'a>, HashMap<NodeIndex, ContractState>)> {
185185
read_forest::<S, IndexNodeLayout>(
186-
&mut self.storage,
186+
&self.storage,
187187
roots,
188188
storage_updates,
189189
classes_updates,

crates/starknet_committer/src/db/trie_traversal.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ macro_rules! log_trivial_modification {
5757
pub(crate) async fn fetch_nodes<'a, L, Layout>(
5858
skeleton_tree: &mut OriginalSkeletonTreeImpl<'a>,
5959
subtrees: Vec<Layout::SubTree>,
60-
storage: &mut impl Storage,
60+
storage: &impl Storage,
6161
leaf_modifications: &LeafModifications<L>,
6262
config: &impl OriginalSkeletonTreeConfig,
6363
mut previous_leaves: Option<&mut HashMap<NodeIndex, L>>,
@@ -241,7 +241,7 @@ fn handle_child_subtree<'a, SubTree: SubTreeTrait<'a>>(
241241
// TODO(Aviv, 17/07/2024): Split between storage prefix implementation and function logic.
242242
pub async fn get_roots_from_storage<'a, L: Leaf, Layout: NodeLayout<'a, L>>(
243243
subtrees: &[Layout::SubTree],
244-
storage: &mut impl Storage,
244+
storage: &impl Storage,
245245
key_context: &<L as HasStaticPrefix>::KeyContext,
246246
) -> TraversalResult<Vec<FilledNode<L, Layout::NodeData>>> {
247247
let mut subtrees_roots = vec![];
@@ -293,7 +293,7 @@ pub(crate) fn log_warning_for_empty_leaves<L: Leaf, T: Borrow<NodeIndex> + Debug
293293
/// fetching nodes from storage.
294294
/// - `leaf_modifications` and `previous_leaves`: Their leaf type `L` is constrained by `Layout`.
295295
pub async fn create_original_skeleton_tree<'a, L: Leaf, Layout: NodeLayout<'a, L>>(
296-
storage: &mut impl Storage,
296+
storage: &impl Storage,
297297
root_hash: HashOutput,
298298
sorted_leaf_indices: SortedLeafIndices<'a>,
299299
config: &impl OriginalSkeletonTreeConfig,
@@ -338,7 +338,7 @@ pub async fn create_original_skeleton_tree<'a, L: Leaf, Layout: NodeLayout<'a, L
338338
}
339339

340340
pub async fn create_storage_tries<'a, Layout: NodeLayoutFor<StarknetStorageValue>>(
341-
storage: &mut impl Storage,
341+
storage: &impl Storage,
342342
actual_storage_updates: &HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>,
343343
original_contracts_trie_leaves: &HashMap<NodeIndex, ContractState>,
344344
config: &ReaderConfig,
@@ -380,7 +380,7 @@ where
380380
/// Creates the contracts trie original skeleton.
381381
/// Also returns the previous contracts state of the modified contracts.
382382
pub async fn create_contracts_trie<'a, Layout: NodeLayoutFor<ContractState>>(
383-
storage: &mut impl Storage,
383+
storage: &impl Storage,
384384
contracts_trie_root_hash: HashOutput,
385385
contracts_trie_sorted_indices: SortedLeafIndices<'a>,
386386
) -> ForestResult<(OriginalSkeletonTreeImpl<'a>, HashMap<NodeIndex, ContractState>)>
@@ -408,7 +408,7 @@ where
408408
}
409409

410410
pub async fn create_classes_trie<'a, Layout: NodeLayoutFor<CompiledClassHash>>(
411-
storage: &mut impl Storage,
411+
storage: &impl Storage,
412412
actual_classes_updates: &LeafModifications<CompiledClassHash>,
413413
classes_trie_root_hash: HashOutput,
414414
config: &ReaderConfig,

0 commit comments

Comments
 (0)