Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub(crate) fn tree_of_height_4_with_long_edge() -> CreateTreeCase {
}

pub(crate) async fn test_create_original_skeleton<L, Layout>(
storage: &mut MapStorage,
storage: &MapStorage,
leaf_modifications: &LeafModifications<L>,
root_hash: HashOutput,
expected_skeleton_nodes: &HashMap<NodeIndex, OriginalSkeletonNode>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub mod create_facts_tree_test;
/// Note that ATM, the Rust committer does not manage history and is not used for storage proofs;
/// Thus, this function assumes facts layout.
pub async fn get_leaves<'a, L: Leaf>(
storage: &mut impl Storage,
storage: &impl Storage,
root_hash: HashOutput,
sorted_leaf_indices: SortedLeafIndices<'a>,
key_context: &<L as HasStaticPrefix>::KeyContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use crate::db::facts_db::FactsNodeLayout;
#[rstest]
#[tokio::test]
async fn test_create_tree_facts_layout(
#[case] mut case: CreateTreeCase,
#[case] case: CreateTreeCase,
#[values(true, false)] compare_modified_leaves: bool,
) {
test_create_original_skeleton::<MockLeaf, FactsNodeLayout>(
&mut case.storage,
&case.storage,
&case.leaf_modifications,
case.root_hash,
&case.expected_skeleton_nodes,
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_committer/src/db/facts_db/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<S: Storage> ForestReader for FactsDb<S> {
config: ReaderConfig,
) -> ForestResult<(OriginalSkeletonForest<'a>, HashMap<NodeIndex, ContractState>)> {
read_forest::<S, FactsNodeLayout>(
&mut self.storage,
&self.storage,
roots,
storage_updates,
classes_updates,
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_committer/src/db/facts_db/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub mod traversal_test;
/// If `leaves` is not `None`, it also fetches the modified leaves and inserts them into the
/// provided map.
pub async fn fetch_patricia_paths<L: Leaf>(
storage: &mut impl Storage,
storage: &impl Storage,
root_hash: HashOutput,
sorted_leaf_indices: SortedLeafIndices<'_>,
leaves: Option<&mut HashMap<NodeIndex, L>>,
Expand Down Expand Up @@ -60,7 +60,7 @@ pub async fn fetch_patricia_paths<L: Leaf>(
/// If `leaves` is not `None`, it also fetches the modified leaves and inserts them into the
/// provided map.
pub(crate) async fn fetch_patricia_paths_inner<'a, L: Leaf>(
storage: &mut impl Storage,
storage: &impl Storage,
subtrees: Vec<FactsSubTree<'a>>,
witnesses: &mut PreimageMap,
mut leaves: Option<&mut HashMap<NodeIndex, L>>,
Expand Down
3 changes: 1 addition & 2 deletions crates/starknet_committer/src/db/facts_db/traversal_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ async fn test_fetch_patricia_paths_inner_impl(
height: SubTreeHeight,
expected_nodes: PreimageMap,
) {
let mut storage = storage;
let expected_fetched_leaves = leaf_indices
.iter()
.map(|&idx| {
Expand All @@ -84,7 +83,7 @@ async fn test_fetch_patricia_paths_inner_impl(
let mut fetched_leaves = HashMap::new();

fetch_patricia_paths_inner::<MockLeaf>(
&mut storage,
&storage,
vec![main_subtree],
&mut nodes,
Some(&mut fetched_leaves),
Expand Down
3 changes: 2 additions & 1 deletion crates/starknet_committer/src/db/forest_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub trait ForestMetadata {
}
}

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

/// Helper function containing layout-common read logic.
pub(crate) async fn read_forest<'a, S, Layout>(
storage: &mut S,
storage: &S,
roots: StateRoots,
storage_updates: &'a HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>,
classes_updates: &'a LeafModifications<CompiledClassHash>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async fn test_create_tree_index_layout(
#[case] mut case: CreateTreeCase,
#[values(true, false)] compare_modified_leaves: bool,
) {
let mut storage = convert_facts_db_to_index_db::<MockLeaf, MockLeaf, EmptyKeyContext>(
let storage = convert_facts_db_to_index_db::<MockLeaf, MockLeaf, EmptyKeyContext>(
&mut case.storage,
case.root_hash,
&EmptyKeyContext,
Expand All @@ -42,7 +42,7 @@ async fn test_create_tree_index_layout(
.await;

test_create_original_skeleton::<MockLeaf, IndexNodeLayout<MockTreeHashFunction>>(
&mut storage,
&storage,
&case.leaf_modifications,
case.root_hash,
&case.expected_skeleton_nodes,
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_committer/src/db/index_db/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ where
config: ReaderConfig,
) -> ForestResult<(OriginalSkeletonForest<'a>, HashMap<NodeIndex, ContractState>)> {
read_forest::<S, IndexNodeLayout<H>>(
&mut self.storage,
&self.storage,
roots,
storage_updates,
classes_updates,
Expand Down
12 changes: 6 additions & 6 deletions crates/starknet_committer/src/db/trie_traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ macro_rules! log_trivial_modification {
pub(crate) async fn fetch_nodes<'a, L, Layout>(
skeleton_tree: &mut OriginalSkeletonTreeImpl<'a>,
subtrees: Vec<Layout::SubTree>,
storage: &mut impl Storage,
storage: &impl Storage,
leaf_modifications: &LeafModifications<L>,
config: &impl OriginalSkeletonTreeConfig,
mut previous_leaves: Option<&mut HashMap<NodeIndex, L>>,
Expand Down Expand Up @@ -241,7 +241,7 @@ fn handle_child_subtree<'a, SubTree: SubTreeTrait<'a>>(
// TODO(Aviv, 17/07/2024): Split between storage prefix implementation and function logic.
pub async fn get_roots_from_storage<'a, L: Leaf, Layout: NodeLayout<'a, L>>(
subtrees: &[Layout::SubTree],
storage: &mut impl Storage,
storage: &impl Storage,
key_context: &<L as HasStaticPrefix>::KeyContext,
) -> TraversalResult<Vec<FilledNode<L, Layout::NodeData>>> {
let mut subtrees_roots = vec![];
Expand Down Expand Up @@ -293,7 +293,7 @@ pub(crate) fn log_warning_for_empty_leaves<L: Leaf, T: Borrow<NodeIndex> + Debug
/// fetching nodes from storage.
/// - `leaf_modifications` and `previous_leaves`: Their leaf type `L` is constrained by `Layout`.
pub async fn create_original_skeleton_tree<'a, L: Leaf, Layout: NodeLayout<'a, L>>(
storage: &mut impl Storage,
storage: &impl Storage,
root_hash: HashOutput,
sorted_leaf_indices: SortedLeafIndices<'a>,
config: &impl OriginalSkeletonTreeConfig,
Expand Down Expand Up @@ -338,7 +338,7 @@ pub async fn create_original_skeleton_tree<'a, L: Leaf, Layout: NodeLayout<'a, L
}

pub async fn create_storage_tries<'a, Layout: NodeLayoutFor<StarknetStorageValue>>(
storage: &mut impl Storage,
storage: &impl Storage,
actual_storage_updates: &HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>,
original_contracts_trie_leaves: &HashMap<NodeIndex, ContractState>,
config: &ReaderConfig,
Expand Down Expand Up @@ -380,7 +380,7 @@ where
/// Creates the contracts trie original skeleton.
/// Also returns the previous contracts state of the modified contracts.
pub async fn create_contracts_trie<'a, Layout: NodeLayoutFor<ContractState>>(
storage: &mut impl Storage,
storage: &impl Storage,
contracts_trie_root_hash: HashOutput,
contracts_trie_sorted_indices: SortedLeafIndices<'a>,
) -> ForestResult<(OriginalSkeletonTreeImpl<'a>, HashMap<NodeIndex, ContractState>)>
Expand Down Expand Up @@ -408,7 +408,7 @@ where
}

pub async fn create_classes_trie<'a, Layout: NodeLayoutFor<CompiledClassHash>>(
storage: &mut impl Storage,
storage: &impl Storage,
actual_classes_updates: &LeafModifications<CompiledClassHash>,
classes_trie_root_hash: HashOutput,
config: &ReaderConfig,
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_committer/src/patricia_merkle_tree/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl OriginalSkeletonTreeConfig for OriginalSkeletonTrieConfig {
/// Assumption: `contract_sorted_leaf_indices` contains all `contract_storage_sorted_leaf_indices`
/// keys.
async fn fetch_all_patricia_paths(
storage: &mut impl Storage,
storage: &impl Storage,
classes_trie_root_hash: HashOutput,
contracts_trie_root_hash: HashOutput,
class_sorted_leaf_indices: SortedLeafIndices<'_>,
Expand Down Expand Up @@ -163,7 +163,7 @@ async fn fetch_all_patricia_paths(
/// and contracts storage tries for both the previous and new root hashes.
/// Fetch the leaves in the contracts trie only, to be able to get the storage root hashes.
pub async fn fetch_previous_and_new_patricia_paths(
storage: &mut impl Storage,
storage: &impl Storage,
classes_trie_root_hashes: RootHashes,
contracts_trie_root_hashes: RootHashes,
class_hashes: &[ClassHash],
Expand Down
6 changes: 3 additions & 3 deletions crates/starknet_os/src/commitment_infos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub enum CommitmentInfosError {
pub async fn create_commitment_infos(
previous_state_roots: &StateRoots,
new_state_roots: &StateRoots,
commitments: &mut MapStorage,
commitments: &MapStorage,
initial_reads_keys: &StateChangesKeys,
) -> Result<StateCommitmentInfos, CommitmentInfosError> {
let (previous_contract_states, new_storage_roots) = get_previous_states_and_new_storage_roots(
Expand Down Expand Up @@ -178,7 +178,7 @@ pub async fn get_previous_states_and_new_storage_roots<I: Iterator<Item = Contra
contract_addresses: I,
previous_contract_trie_root: HashOutput,
new_contract_trie_root: HashOutput,
commitments: &mut MapStorage,
commitments: &MapStorage,
) -> Result<
(HashMap<NodeIndex, ContractState>, HashMap<ContractAddress, HashOutput>),
CommitmentInfosError,
Expand Down Expand Up @@ -218,7 +218,7 @@ pub async fn get_previous_states_and_new_storage_roots<I: Iterator<Item = Contra

async fn fetch_storage_proofs_from_state_changes_keys(
initial_reads_keys: &StateChangesKeys,
storage: &mut MapStorage,
storage: &MapStorage,
classes_trie_root_hashes: RootHashes,
contracts_trie_root_hashes: RootHashes,
) -> Result<StarknetForestProofs, CommitmentInfosError> {
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_os_flow_tests/src/test_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ impl<S: FlowTestState> TestBuilder<S> {
let commitment_infos = create_commitment_infos(
&previous_state_roots,
&new_state_roots,
&mut map_storage,
&map_storage,
&initial_reads.keys(),
)
.await
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_os_runner/src/running/storage_proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl RpcStorageProofsProvider {
let previous_state_roots = StateRoots { contracts_trie_root_hash, classes_trie_root_hash };

// Consume the new facts from the committer storage.
let mut map_storage: MapStorage = facts_db.consume_storage();
let map_storage: MapStorage = facts_db.consume_storage();

// Get extended initial reads keys.
let initial_reads_keys = extended_initial_reads.keys();
Expand All @@ -221,7 +221,7 @@ impl RpcStorageProofsProvider {
let mut commitment_infos = create_commitment_infos(
&previous_state_roots,
&new_roots,
&mut map_storage,
&map_storage,
&initial_reads_keys,
)
.await
Expand Down
Loading