Skip to content

starknet_committer: compute and store accessed keys digest#13993

Merged
ArielElp merged 1 commit into
mainfrom
ariel/accessed_keys_digest
May 27, 2026
Merged

starknet_committer: compute and store accessed keys digest#13993
ArielElp merged 1 commit into
mainfrom
ariel/accessed_keys_digest

Conversation

@ArielElp
Copy link
Copy Markdown
Contributor

@ArielElp ArielElp commented May 7, 2026

No description provided.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@cursor
Copy link
Copy Markdown

cursor Bot commented May 14, 2026

PR Summary

Medium Risk
Introduces a canonical hash over accessed trie indices used for OS/committer input; encoding mistakes would break cross-component agreement, but the logic is feature-gated and self-contained in this diff.

Overview
Adds an os_input Cargo feature (optional blake2 / digest) and accessed_keys_digest, which hashes a SortedLeavesRequest with BLAKE2s-256 using a fixed, length-prefixed encoding of class, contract, and per-contract storage NodeIndex values (storage contract keys sorted at hash time).

Also notes a future BTreeMap change for storage_sorted in Patricia path fetching.

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

Copy link
Copy Markdown
Contributor

@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 reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ArielElp).


crates/starknet_committer/src/db/serde_db_utils.rs line 60 at r1 (raw file):

) -> [u8; 32] {
    let mut class_hashes: Vec<ClassHash> = class_hashes.iter().copied().collect();
    class_hashes.sort();

In the previous PR you sort it. Define a "sorted" struct?

Code quote:

class_hashes.sort();

@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from 7768006 to 88273cc Compare May 18, 2026 11:56
@ArielElp ArielElp force-pushed the ariel/get_leaf_indicies_utility branch 2 times, most recently from 13ea978 to d58523d Compare May 18, 2026 13:52
@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from 88273cc to 482d5eb Compare May 18, 2026 13:52
@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from 22efed7 to 093fc19 Compare May 25, 2026 14:13
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 and all commit messages, made 1 comment, and resolved 3 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ArielElp).


crates/starknet_committer/src/db/serde_db_utils.rs line 63 at r4 (raw file):

Previously, ArielElp wrote…

AI decision, it's supposed to be marginally faster, and you know there are no duplications here (it's the keys from a HashMap).

but with a HashMap, order is not well defined, and you could get different digests for the same input. right?

Copy link
Copy Markdown
Contributor Author

@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 made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware).


crates/starknet_committer/src/db/serde_db_utils.rs line 63 at r4 (raw file):

Previously, dorimedini-starkware wrote…

but with a HashMap, order is not well defined, and you could get different digests for the same input. right?

Hence the sort, sort unstable is just about ordering of equal elements

@ArielElp ArielElp force-pushed the ariel/get_leaf_indicies_utility branch from 2e17706 to 300a545 Compare May 26, 2026 10:08
@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch 2 times, most recently from 11d186a to c9ac657 Compare May 26, 2026 13:03
@ArielElp ArielElp force-pushed the ariel/get_leaf_indicies_utility branch from 300a545 to c381bc4 Compare May 26, 2026 13:03
@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from c9ac657 to 5a5ff22 Compare May 26, 2026 13:11
@ArielElp ArielElp force-pushed the ariel/get_leaf_indicies_utility branch from c381bc4 to 1b083d2 Compare May 26, 2026 13:11
@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from 5a5ff22 to bfb567c Compare May 27, 2026 07:23
@ArielElp ArielElp force-pushed the ariel/get_leaf_indicies_utility branch from 1b083d2 to 9885436 Compare May 27, 2026 07:23
@graphite-app graphite-app Bot changed the base branch from ariel/get_leaf_indicies_utility to graphite-base/13993 May 27, 2026 07:53
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: all files reviewed, 1 unresolved discussion (waiting on ArielElp).


crates/starknet_committer/src/db/serde_db_utils.rs line 63 at r4 (raw file):

Previously, ArielElp wrote…

Hence the sort, sort unstable is just about ordering of equal elements

ah, right.
why not use a BTreeMap in your struct though?

@ArielElp ArielElp force-pushed the graphite-base/13993 branch from 9885436 to 4a95405 Compare May 27, 2026 09:45
@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from bfb567c to 7b6b74f Compare May 27, 2026 09:45
@ArielElp ArielElp changed the base branch from graphite-base/13993 to main May 27, 2026 09:45
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

@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 made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware).


crates/starknet_committer/src/db/serde_db_utils.rs line 63 at r4 (raw file):

Previously, dorimedini-starkware wrote…

ah, right.
why not use a BTreeMap in your struct though?

The fields here eventually go to the various fetch_patricia_paths functions that expect HashMap, I didn't want to change multiple signatures just for the digest.

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: all files reviewed, 1 unresolved discussion (waiting on ArielElp).


crates/starknet_committer/src/db/serde_db_utils.rs line 63 at r4 (raw file):

Previously, ArielElp wrote…

The fields here eventually go to the various fetch_patricia_paths functions that expect HashMap, I didn't want to change multiple signatures just for the digest.

mmmmm can you add a TODO to do it separately? I see no harm in changing all the signatures to BTreeMap, unless there is some storage-backed object that is already in storage with a HashMap or something non backwards-compatible like that

Copy link
Copy Markdown
Contributor Author

@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 made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware).


crates/starknet_committer/src/db/serde_db_utils.rs line 63 at r4 (raw file):

Previously, dorimedini-starkware wrote…

mmmmm can you add a TODO to do it separately? I see no harm in changing all the signatures to BTreeMap, unless there is some storage-backed object that is already in storage with a HashMap or something non backwards-compatible like that

Done.

@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from 7b6b74f to 22afd6e Compare May 27, 2026 12:24
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).

@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from 22afd6e to 5ab5e3f Compare May 27, 2026 14:31
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.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArielElp).

@ArielElp ArielElp added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit 70b36c3 May 27, 2026
40 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