Skip to content

starknet_patricia: assert unmodified-subtree binary child is present in the skeleton#14614

Merged
yoavGrs merged 1 commit into
mainfrom
assert_unmodified_subtree_child_present
Jun 24, 2026
Merged

starknet_patricia: assert unmodified-subtree binary child is present in the skeleton#14614
yoavGrs merged 1 commit into
mainfrom
assert_unmodified_subtree_child_present

Conversation

@yoavGrs

@yoavGrs yoavGrs commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Mirror the leaf sanity-check in finalize_binary_child: an unmodified subtree child
must already be finalized in the skeleton (from finalize_bottom_layer).

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

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@cursor

cursor Bot commented Jun 23, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small defensive invariant in Patricia Merkle skeleton construction; no API or behavior change beyond catching internal bugs earlier.

Overview
In finalize_binary_child, unmodified subtree children of a binary node now get the same skeleton presence check as leaves: if the child is already finalized in the bottom layer, the code asserts skeleton_tree contains that index instead of returning silently.

The assert message is generalized from “Leaf index” to “Index” because both node kinds use the same path.

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

@yoavGrs yoavGrs requested a review from nimrod-starkware June 23, 2026 13:45

@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: 0 of 1 files reviewed, 1 unresolved discussion (waiting on yoavGrs).


crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper.rs line 259 at r1 (raw file):

                    "Leaf index {index:?} doesn't appear in the skeleton."
                );
                return;

Suggestion:

            TempSkeletonNode::Original(OriginalSkeletonNode::UnmodifiedSubTree(_)) | TempSkeletonNode::Leaf
                assert!(
                    self.skeleton_tree.contains_key(&index),
                    "Index {index:?} doesn't appear in the skeleton."
                );
                return;
            }

@yoavGrs yoavGrs force-pushed the assert_unmodified_subtree_child_present branch 2 times, most recently from d9b2493 to 9d0aed4 Compare June 23, 2026 14:27

@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: 0 of 1 files reviewed, 1 unresolved discussion (waiting on nimrod-starkware).


crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper.rs line 259 at r1 (raw file):

                    "Leaf index {index:?} doesn't appear in the skeleton."
                );
                return;

Done.

@yoavGrs yoavGrs force-pushed the assert_unmodified_subtree_child_present branch from 9d0aed4 to e077fca Compare June 23, 2026 14:38
@yoavGrs yoavGrs force-pushed the refactor_node_from_binary_data branch 2 times, most recently from 2e27bf5 to aa3a0d3 Compare June 24, 2026 06:33
@yoavGrs yoavGrs force-pushed the assert_unmodified_subtree_child_present branch from e077fca to 066e368 Compare June 24, 2026 06:33
@yoavGrs yoavGrs changed the base branch from refactor_node_from_binary_data to graphite-base/14614 June 24, 2026 10:20
@yoavGrs yoavGrs force-pushed the assert_unmodified_subtree_child_present branch from 066e368 to f55877e Compare June 24, 2026 10:20
@yoavGrs yoavGrs force-pushed the graphite-base/14614 branch from aa3a0d3 to ea03ddc Compare June 24, 2026 10:20
@yoavGrs yoavGrs changed the base branch from graphite-base/14614 to main June 24, 2026 10:20
…in the skeleton

Mirror the leaf sanity-check in finalize_binary_child: an unmodified subtree child
must already be finalized in the skeleton (from finalize_bottom_layer).

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

@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 reviewed 1 file and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on yoavGrs).

@yoavGrs yoavGrs added this pull request to the merge queue Jun 24, 2026
Merged via the queue into main with commit 9ba09bb Jun 24, 2026
30 of 33 checks passed

Copy link
Copy Markdown
Contributor

Security scan complete — no issues detected.


Generated by Claude Code

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