Skip to content

Commit 30f2fe3

Browse files
starknet_patricia,starknet_committer: dont pass storage mut when not needed
1 parent 0476bff commit 30f2fe3

File tree

11 files changed

+26
-27
lines changed

11 files changed

+26
-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/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/index_db/create_index_tree_test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ impl TreeHashFunction<MockLeaf> for TreeHashFunctionImpl {
3030
#[rstest]
3131
#[tokio::test]
3232
async fn test_create_tree_index_layout(
33-
#[case] mut case: CreateTreeCase,
33+
#[case] case: CreateTreeCase,
3434
#[values(true, false)] compare_modified_leaves: bool,
3535
) {
36-
let mut storage = convert_facts_db_to_index_db::<MockLeaf, MockLeaf, EmptyKeyContext>(
37-
&mut case.storage,
36+
let storage = convert_facts_db_to_index_db::<MockLeaf, MockLeaf, EmptyKeyContext>(
37+
&case.storage,
3838
case.root_hash,
3939
&EmptyKeyContext,
4040
&mut None,
4141
)
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/test_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub async fn convert_facts_forest_db_to_index_db(
8989
/// Converts a single Facts-layout trie to Index-layout.
9090
/// Expects all nodes to exist (panics if a node is missing).
9191
pub async fn convert_facts_db_to_index_db<FactsLeaf, IndexLeaf, KeyContext>(
92-
storage: &mut MapStorage,
92+
storage: &MapStorage,
9393
root_hash: HashOutput,
9494
key_context: &KeyContext,
9595
current_leaves: &mut Option<&mut Vec<(NodeIndex, FactsLeaf)>>,
@@ -105,7 +105,7 @@ where
105105

106106
/// Converts a single trie from Facts-layout to Index-layout.
107107
async fn convert_single_trie<FactsLeaf, IndexLeaf, KeyContext>(
108-
storage: &mut MapStorage,
108+
storage: &MapStorage,
109109
root_hash: HashOutput,
110110
key_context: &KeyContext,
111111
current_leaves: &mut Option<&mut Vec<(NodeIndex, FactsLeaf)>>,
@@ -136,7 +136,7 @@ where
136136
/// Recursively traverses a Facts-layout trie and converts each node to Index-layout.
137137
#[async_recursion]
138138
async fn traverse_and_convert<FactsLeaf, IndexLeaf, KeyContext>(
139-
facts_storage: &mut MapStorage,
139+
facts_storage: &MapStorage,
140140
index_layout_storage: &mut MapStorage,
141141
subtree: FactsSubTree<'async_recursion>,
142142
key_context: &KeyContext,

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,

crates/starknet_committer/src/patricia_merkle_tree/tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl OriginalSkeletonTreeConfig for OriginalSkeletonTrieConfig {
5555
/// Assumption: `contract_sorted_leaf_indices` contains all `contract_storage_sorted_leaf_indices`
5656
/// keys.
5757
async fn fetch_all_patricia_paths(
58-
storage: &mut impl Storage,
58+
storage: &impl Storage,
5959
classes_trie_root_hash: HashOutput,
6060
contracts_trie_root_hash: HashOutput,
6161
class_sorted_leaf_indices: SortedLeafIndices<'_>,
@@ -163,7 +163,7 @@ async fn fetch_all_patricia_paths(
163163
/// and contracts storage tries for both the previous and new root hashes.
164164
/// Fetch the leaves in the contracts trie only, to be able to get the storage root hashes.
165165
pub async fn fetch_previous_and_new_patricia_paths(
166-
storage: &mut impl Storage,
166+
storage: &impl Storage,
167167
classes_trie_root_hashes: RootHashes,
168168
contracts_trie_root_hashes: RootHashes,
169169
class_hashes: &[ClassHash],

crates/starknet_os_flow_tests/src/test_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ impl<S: FlowTestState> TestManager<S> {
675675
create_cached_state_input_and_commitment_infos(
676676
&previous_state_roots,
677677
&new_state_roots,
678-
&mut map_storage,
678+
&map_storage,
679679
&extended_state_diff,
680680
&class_hashes_from_execution_infos,
681681
)

0 commit comments

Comments
 (0)