Skip to content

starknet_committer: derive skeleton updates from actual updates#14214

Merged
yoavGrs merged 1 commit into
mainfrom
yoav/skeleton-updates-from-actual
May 29, 2026
Merged

starknet_committer: derive skeleton updates from actual updates#14214
yoavGrs merged 1 commit into
mainfrom
yoav/skeleton-updates-from-actual

Conversation

@yoavGrs
Copy link
Copy Markdown
Contributor

@yoavGrs yoavGrs commented May 27, 2026

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

Copy link
Copy Markdown
Contributor Author

yoavGrs commented May 27, 2026

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@yoavGrs yoavGrs self-assigned this May 27, 2026
@yoavGrs yoavGrs requested a review from ArielElp May 27, 2026 08:47
@yoavGrs yoavGrs marked this pull request as ready for review May 27, 2026 08:47
@cursor
Copy link
Copy Markdown

cursor Bot commented May 27, 2026

PR Summary

Medium Risk
Touches the block commitment compute path where skeleton vs actual updates must stay aligned; logic is a refactor but incorrect mapping would change trie topology.

Overview
Skeleton trie inputs for forest updates are now derived from the already-computed actual leaf modifications instead of being rebuilt by walking StateDiff again.

compute_updated_forest passes skeleton_trie_updates / skeleton_storage_updates built from actual_classes_updates and actual_storage_updates, and only threads address_to_class_hash and address_to_nonce where contract metadata is still needed. The old StateDiff::skeleton_* helpers are removed in favor of a generic skeleton_trie_updates mapper plus From conversions on StarknetStorageValue and CompiledClassHash into SkeletonLeaf (zero vs non-zero).

Reviewed by Cursor Bugbot for commit 058f53b. Bugbot is set up for automated code reviews on this repo. Configure here.

@yoavGrs yoavGrs force-pushed the yoav/split-commit-block-read-compute branch from 8e57dd9 to 5566cc1 Compare May 27, 2026 10:31
@yoavGrs yoavGrs force-pushed the yoav/skeleton-updates-from-actual branch from c98f499 to 6f28096 Compare May 27, 2026 10:31
@yoavGrs yoavGrs force-pushed the yoav/skeleton-updates-from-actual branch from 6f28096 to 73461ba Compare May 28, 2026 07:26
@yoavGrs yoavGrs force-pushed the yoav/split-commit-block-read-compute branch from 5566cc1 to 775a5f6 Compare May 28, 2026 07:26
Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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,

Copy link
Copy Markdown
Contributor Author

@yoavGrs yoavGrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 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.

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?

Copy link
Copy Markdown
Contributor Author

@yoavGrs yoavGrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 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?

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.

Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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_updates is created - iterating over state_diff.accessed_addresses() for the address keys, and then mapping state_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))
}

@yoavGrs yoavGrs force-pushed the yoav/skeleton-updates-from-actual branch from 73461ba to 98f94f2 Compare May 28, 2026 08:07
Copy link
Copy Markdown
Contributor Author

@yoavGrs yoavGrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorimedini-starkware reviewed 1 file and all commit messages, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArielElp).

Copy link
Copy Markdown
Contributor

@ArielElp ArielElp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArielElp reviewed 3 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on yoavGrs).

@yoavGrs yoavGrs changed the base branch from yoav/split-commit-block-read-compute to main May 28, 2026 12:51
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>
@yoavGrs yoavGrs force-pushed the yoav/skeleton-updates-from-actual branch from 98f94f2 to 058f53b Compare May 28, 2026 12:52
Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorimedini-starkware reviewed 6 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on yoavGrs).

@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented May 28, 2026

Merge activity

  • May 28, 12:53 PM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.

Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on yoavGrs).

@yoavGrs yoavGrs added this pull request to the merge queue May 29, 2026
Merged via the queue into main with commit 399a721 May 29, 2026
29 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants