starknet_committer: derive skeleton updates from actual updates#14214
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 058f53b. Bugbot is set up for automated code reviews on this repo. Configure here. |
8e57dd9 to
5566cc1
Compare
c98f499 to
6f28096
Compare
6f28096 to
73461ba
Compare
5566cc1 to
775a5f6
Compare
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on ArielElp and yoavGrs).
crates/starknet_committer/src/block_committer/commit.rs line 128 at r1 (raw file):
actual_storage_updates: HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>, actual_classes_updates: LeafModifications<CompiledClassHash>, state_diff: &StateDiff,
previously the relevant modifications were read directly from the state_diff, but now you use the actual updates.
Can you prove it's equivalent?
Code quote:
actual_storage_updates: HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>,
actual_classes_updates: LeafModifications<CompiledClassHash>,
state_diff: &StateDiff,
yoavGrs
left a comment
There was a problem hiding this comment.
@yoavGrs made 1 comment.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on ArielElp and dorimedini-starkware).
crates/starknet_committer/src/block_committer/commit.rs line 128 at r1 (raw file):
Previously, dorimedini-starkware wrote…
previously the relevant modifications were read directly from the state_diff, but now you use the actual updates.
Can you prove it's equivalent?
If I understand your question:
Look at the previous version of skeleton_storage_updates and actual_storage_updates. They collect entries using the same logic but map them to different types.
The same claim for skeleton_classes_updates and actual_classes_updates.
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware made 1 comment.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on ArielElp and yoavGrs).
crates/starknet_committer/src/block_committer/commit.rs line 128 at r1 (raw file):
Previously, yoavGrs wrote…
If I understand your question:
Look at the previous version ofskeleton_storage_updatesandactual_storage_updates. They collect entries using the same logic but map them to different types.
The same claim forskeleton_classes_updatesandactual_classes_updates.
state_diff.skeleton_storage_updates() would iterated over state_diff.accessed_addresses() for the address keys, and then map state_diff.storage_updates[address] to the skeleton nodes. you are saying this is the same as mapping actual_storage_updates to skeleton nodes? how can I see it?
yoavGrs
left a comment
There was a problem hiding this comment.
@yoavGrs made 1 comment.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on ArielElp and dorimedini-starkware).
crates/starknet_committer/src/block_committer/commit.rs line 128 at r1 (raw file):
Previously, dorimedini-starkware wrote…
state_diff.skeleton_storage_updates()would iterated overstate_diff.accessed_addresses()for the address keys, and then mapstate_diff.storage_updates[address]to the skeleton nodes. you are saying this is the same as mappingactual_storage_updatesto skeleton nodes? how can I see it?
Look at the way that actual_storage_updates is created - iterating over state_diff.accessed_addresses() for the address keys, and then mapping state_diff.storage_updates[address] to storage updates.
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 2 files, made 2 comments, and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ArielElp and yoavGrs).
crates/starknet_committer/src/block_committer/commit.rs line 128 at r1 (raw file):
Previously, yoavGrs wrote…
Look at the way that
actual_storage_updatesis created - iterating overstate_diff.accessed_addresses()for the address keys, and then mappingstate_diff.storage_updates[address]to storage updates.
ah. in that case, see below
crates/starknet_committer/src/block_committer/commit.rs line 167 at r1 (raw file):
} /// Compares the previous state's nonce and class hash with the given in the state diff.
passing both a state diff AND input that is derived from state diff is not optimal
Suggestion:
/// Computes the updated forest topology, its new hashes, and the nodes deleted by the state diff.
async fn compute_updated_forest<M: MeasurementsTrait + Send>(
original_forest: OriginalSkeletonForest<'_>,
original_contracts_trie_leaves: HashMap<NodeIndex, ContractState>,
actual_storage_updates: HashMap<ContractAddress, LeafModifications<StarknetStorageValue>>,
actual_classes_updates: LeafModifications<CompiledClassHash>,
address_to_class_hash: &HashMap<ContractAddress, ClassHash>,
address_to_nonce: &HashMap<ContractAddress, Nonce>,
measurements: &mut M,
) -> BlockCommitmentResult<(FilledForest, DeletedNodes)> {
measurements.start_measurement(Action::Compute);
// Compute the new topology.
let updated_forest = UpdatedSkeletonForest::create(
&original_forest,
&state_diff.skeleton_classes_updates(),
&state_diff.skeleton_storage_updates(),
&original_contracts_trie_leaves,
address_to_class_hash,
address_to_nonce,
)?;
debug!("Updated skeleton forest created successfully.");
// Find deleted nodes.
let deleted_nodes = find_deleted_nodes(
&original_forest,
&updated_forest,
&actual_storage_updates,
&actual_classes_updates,
&original_contracts_trie_leaves,
);
// Compute the new hashes.
let filled_forest = FilledForest::create::<TreeHashFunctionImpl>(
updated_forest,
actual_storage_updates,
actual_classes_updates,
&original_contracts_trie_leaves,
address_to_class_hash,
address_to_nonce,
)
.await?;
measurements.attempt_to_stop_measurement(Action::Compute, 0).ok();
debug!("Filled forest created successfully.");
Ok((filled_forest, deleted_nodes))
}73461ba to
98f94f2
Compare
yoavGrs
left a comment
There was a problem hiding this comment.
@yoavGrs made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ArielElp and dorimedini-starkware).
crates/starknet_committer/src/block_committer/commit.rs line 167 at r1 (raw file):
Previously, dorimedini-starkware wrote…
passing both a state diff AND input that is derived from state diff is not optimal
Done.
It would be nice if actual_storage_updates borrowed the state diff, but not now.
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 1 file and all commit messages, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on ArielElp).
ArielElp
left a comment
There was a problem hiding this comment.
@ArielElp reviewed 3 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on yoavGrs).
read_original_forest now takes &Input. The skeleton updates fed to UpdatedSkeletonForest are derived from the already-computed actual updates via a generic skeleton_trie_updates (pure value mapping), instead of re-walking the state diff. Adds From<_> for SkeletonLeaf impls for the leaf value types to back the generic bound. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
98f94f2 to
058f53b
Compare
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 6 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on yoavGrs).
Merge activity
|
dorimedini-starkware
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on yoavGrs).

read_original_forest now takes &Input. The skeleton updates fed to
UpdatedSkeletonForest are derived from the already-computed actual
updates via a generic skeleton_trie_updates (pure value mapping),
instead of re-walking the state diff. Adds From<_> for SkeletonLeaf
impls for the leaf value types to back the generic bound.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com