Skip to content

Commit 9416084

Browse files
starknet_patricia,starknet_committer: dont pass storage mut when not needed
1 parent 253a0f6 commit 9416084

File tree

8 files changed

+18
-19
lines changed

8 files changed

+18
-19
lines changed

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
@@ -198,7 +198,7 @@ use crate::patricia_merkle_tree::tree::OriginalSkeletonTrieConfig;
198198
SubTreeHeight::new(4),
199199
)]
200200
async fn test_create_tree(
201-
#[case] mut storage: MapStorage,
201+
#[case] storage: MapStorage,
202202
#[case] leaf_modifications: LeafModifications<MockLeaf>,
203203
#[case] root_hash: HashOutput,
204204
#[case] expected_skeleton_nodes: HashMap<NodeIndex, OriginalSkeletonNode>,
@@ -213,7 +213,7 @@ async fn test_create_tree(
213213
let mut sorted_leaf_indices: Vec<NodeIndex> = leaf_modifications.keys().copied().collect();
214214
let sorted_leaf_indices = SortedLeafIndices::new(&mut sorted_leaf_indices);
215215
let skeleton_tree = create_original_skeleton_tree::<MockLeaf, FactsNodeLayout>(
216-
&mut storage,
216+
&storage,
217217
root_hash,
218218
sorted_leaf_indices,
219219
&config,

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/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
)

crates/starknet_os_flow_tests/src/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ pub(crate) struct CommitmentInfos {
229229
pub(crate) async fn create_cached_state_input_and_commitment_infos(
230230
previous_state_roots: &StateRoots,
231231
new_state_roots: &StateRoots,
232-
commitments: &mut MapStorage,
232+
commitments: &MapStorage,
233233
extended_state_diff: &StateMaps,
234234
class_hashes_from_execution_infos: &HashSet<ClassHash>,
235235
) -> (CachedStateInput, CommitmentInfos) {
@@ -374,7 +374,7 @@ pub(crate) async fn get_previous_states_and_new_storage_roots<
374374
contract_addresses: I,
375375
previous_contract_trie_root: HashOutput,
376376
new_contract_trie_root: HashOutput,
377-
commitments: &mut MapStorage,
377+
commitments: &MapStorage,
378378
) -> (HashMap<NodeIndex, ContractState>, HashMap<ContractAddress, HashOutput>) {
379379
let mut contract_leaf_indices: Vec<NodeIndex> =
380380
contract_addresses.map(|address| NodeIndex::from_leaf_felt(&address.0)).collect();
@@ -468,7 +468,7 @@ pub(crate) fn get_class_hash_of_feature_contract(feature_contract: FeatureContra
468468

469469
async fn fetch_storage_proofs_from_state_maps(
470470
state_maps: &StateMaps,
471-
storage: &mut MapStorage,
471+
storage: &MapStorage,
472472
classes_trie_root_hashes: RootHashes,
473473
contracts_trie_root_hashes: RootHashes,
474474
class_hashes_from_execution_infos: &HashSet<ClassHash>,

0 commit comments

Comments
 (0)