Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: no need to recalculate the actual updates #307

Merged
merged 1 commit into from
Jul 15, 2024
Merged
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
9 changes: 6 additions & 3 deletions crates/committer/src/block_committer/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ pub async fn commit_block(input: Input<ConfigImpl>) -> BlockCommitmentResult<Fil
contracts_trie_sorted_indices: SortedLeafIndices::new(&mut contracts_trie_indices),
classes_trie_sorted_indices: SortedLeafIndices::new(&mut classes_trie_indices),
};
let actual_storage_updates = input.state_diff.actual_storage_updates();
let actual_classes_updates = input.state_diff.actual_classes_updates();
let (mut original_forest, original_contracts_trie_leaves) = OriginalSkeletonForest::create(
MapStorage::from(input.storage),
input.contracts_trie_root_hash,
input.classes_trie_root_hash,
&input.state_diff,
&actual_storage_updates,
&actual_classes_updates,
&forest_sorted_indices,
&input.config,
)?;
Expand All @@ -59,8 +62,8 @@ pub async fn commit_block(input: Input<ConfigImpl>) -> BlockCommitmentResult<Fil

Ok(FilledForest::create::<TreeHashFunctionImpl>(
updated_forest,
input.state_diff.actual_storage_updates(),
input.state_diff.actual_classes_updates(),
actual_storage_updates,
actual_classes_updates,
&original_contracts_trie_leaves,
&input.state_diff.address_to_class_hash,
&input.state_diff.address_to_nonce,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::block_committer::input::Config;
use crate::block_committer::input::ContractAddress;
use crate::block_committer::input::StarknetStorageValue;
use crate::block_committer::input::StateDiff;
use crate::forest_errors::ForestError;
use crate::forest_errors::ForestResult;
use crate::hash::hash_trait::HashOutput;
Expand Down Expand Up @@ -37,7 +36,8 @@ impl<'a> OriginalSkeletonForest<'a> {
storage: impl Storage,
contracts_trie_root_hash: HashOutput,
classes_trie_root_hash: HashOutput,
state_diff: &StateDiff,
storage_updates: &HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>,
classes_updates: &LeafModifications<CompiledClassHash>,
forest_sorted_indices: &ForestSortedIndices<'a>,
config: &impl Config,
) -> ForestResult<(Self, HashMap<NodeIndex, ContractState>)>
Expand All @@ -50,14 +50,14 @@ impl<'a> OriginalSkeletonForest<'a> {
forest_sorted_indices.contracts_trie_sorted_indices,
)?;
let storage_tries = Self::create_storage_tries(
&state_diff.actual_storage_updates(),
storage_updates,
&original_contracts_trie_leaves,
&storage,
config,
&forest_sorted_indices.storage_tries_sorted_indices,
)?;
let classes_trie = Self::create_classes_trie(
&state_diff.actual_classes_updates(),
classes_updates,
classes_trie_root_hash,
&storage,
config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ fn test_create_original_skeleton_forest(
MapStorage::from(input.storage),
input.contracts_trie_root_hash,
input.classes_trie_root_hash,
&input.state_diff,
&input.state_diff.actual_storage_updates(),
&input.state_diff.actual_classes_updates(),
&forest_sorted_indices,
&ConfigImpl::new(false),
)
Expand Down
Loading