Skip to content

starknet_patricia: collapse leaf handling to a single match#14583

Merged
yoavGrs merged 1 commit into
mainfrom
leaf_handling_in_a_single_match
Jun 23, 2026
Merged

starknet_patricia: collapse leaf handling to a single match#14583
yoavGrs merged 1 commit into
mainfrom
leaf_handling_in_a_single_match

Conversation

@yoavGrs

@yoavGrs yoavGrs commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Match on LeafSource exactly once in compute_filled_tree_rec: the ExistingLeaves read is
inlined and the helper (renamed compute_leaf) now only handles the ComputeLeaves case,
returning the leaf and its output directly instead of an Option.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@yoavGrs yoavGrs self-assigned this Jun 21, 2026
@yoavGrs yoavGrs marked this pull request as ready for review June 21, 2026 13:21
@cursor

cursor Bot commented Jun 21, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Internal refactor within Patricia filled-tree construction; behavior should be equivalent with clearer control flow and no API surface change.

Overview
Filled tree leaf handling in compute_filled_tree_rec is restructured so LeafSource is matched once at the leaf skeleton node instead of inside a shared helper.

get_or_compute_leaf is renamed to compute_leaf and narrowed to the ComputeLeaves path only: it takes the leaf input map and index, returns (L, L::Output) (no Option on the output). ExistingLeaves is handled inline in the UpdatedSkeletonNode::Leaf arm via L::from_modifications.

For ComputeLeaves, leaf output is written to leaf_index_to_leaf_output in that same arm right after compute_leaf, removing the follow-up if let that previously wrote outputs after hashing the leaf node.

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 997083a. Configure here.

@yoavGrs yoavGrs requested a review from nimrod-starkware June 21, 2026 13:57

@nimrod-starkware nimrod-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nimrod-starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on yoavGrs).

@yoavGrs yoavGrs left a comment

Copy link
Copy Markdown
Contributor Author

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 nimrod-starkware).

@nimrod-starkware nimrod-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nimrod-starkware made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on yoavGrs).

@nimrod-starkware nimrod-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nimrod-starkware resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on yoavGrs).

@nimrod-starkware nimrod-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:lgtm:

@nimrod-starkware made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on yoavGrs).

Match on LeafSource exactly once in compute_filled_tree_rec: the ExistingLeaves read is
inlined and the helper (renamed compute_leaf) now only handles the ComputeLeaves case,
returning the leaf and its output directly instead of an Option.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yoavGrs yoavGrs changed the base branch from patricia_leaf_source_enum to main June 23, 2026 13:30
@yoavGrs yoavGrs force-pushed the leaf_handling_in_a_single_match branch from 997083a to 3efa5f7 Compare June 23, 2026 13:44
@yoavGrs yoavGrs added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit 01f17ad Jun 23, 2026
33 of 36 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.

3 participants