Skip to content

starknet_committer: define StarknetForestProofs serde#13994

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

starknet_committer: define StarknetForestProofs serde#13994
ArielElp merged 1 commit into
mainfrom
ariel/patricia_paths_storage_serialization

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

@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch from 2092a49 to f0e3f55 Compare May 7, 2026 12:40
@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from 19be0db to 7768006 Compare May 14, 2026 08:43
@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch 2 times, most recently from 6d8fca8 to f34a751 Compare May 18, 2026 11:56
@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/patricia_paths_storage_serialization branch from f34a751 to 540e432 Compare May 18, 2026 13:52
@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from 482d5eb to 8149407 Compare May 19, 2026 06:55
@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch 2 times, most recently from 48f73db to 40a2552 Compare May 19, 2026 07:08
@ArielElp ArielElp requested a review from yoavGrs May 19, 2026 07:09
@ArielElp ArielElp marked this pull request as ready for review May 19, 2026 07:09
@cursor
Copy link
Copy Markdown

cursor Bot commented May 19, 2026

PR Summary

Medium Risk
New wire format for state-commitment witnesses must stay compatible with OS expectations; mistakes could break proving input, though scope is feature-gated and covered by round-trip tests.

Overview
Adds zstd-compressed bincode serialization for StarknetForestProofs behind the os_input feature, producing DbValue payloads aligned with OS Patricia witness layout (classes/contract inner nodes, contract leaves, per-contract storage proofs).

serialize flattens preimage maps via flatten_preimages and packs a four-part tuple; deserialize rebuilds maps and rejects duplicate node hashes, contract leaves, or storage witnesses. Optional bincode and zstd deps are wired into os_input; Debug/PartialEq are added on proof structs and extend is made public for tests and callers.

Round-trip rstest cases cover empty/partial/full forest proof shapes when os_input is enabled in tests.

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

@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch 2 times, most recently from a5cc604 to 7b294f1 Compare May 26, 2026 13:11
@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch 2 times, most recently from 5a5ff22 to bfb567c Compare May 27, 2026 07:23
@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch from 7b294f1 to 982711b Compare May 27, 2026 07:23
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 5 files and all commit messages, made 2 comments, and resolved 4 discussions.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on ArielElp).


crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serde.rs line 67 at r6 (raw file):

            .collect();

        bincode::serialize(&(classes, contract_nodes, contract_leaves, storage))

general question: why did you choose this crate to convert to/from bytes?

Code quote:

bincode

crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serde.rs line 105 at r6 (raw file):

        let mut contracts_trie_storage_proofs = HashMap::new();
        for (addr, facts) in storage {

why not do the same into_iter().try_fold pattern as above?

Code quote:

        let mut contracts_trie_storage_proofs = HashMap::new();
        for (addr, facts) in storage {

@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch from 982711b to 8d5ff04 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
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 made 1 comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on ArielElp and dorimedini-starkware).


crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serde.rs line 67 at r6 (raw file):

Previously, dorimedini-starkware wrote…

general question: why did you choose this crate to convert to/from bytes?

What about this approach:

let bytes = serde_json::to_vec(self)?;
let compressed = compress(bytes.as_slice())?;

@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch from 8d5ff04 to 08c1864 Compare May 27, 2026 11:52
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 2 comments.
Reviewable status: 5 of 6 files reviewed, 2 unresolved discussions (waiting on dorimedini-starkware).


crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serde.rs line 67 at r6 (raw file):

Previously, yoavGrs wrote…

What about this approach:

let bytes = serde_json::to_vec(self)?;
let compressed = compress(bytes.as_slice())?;

Just a simple approach to storage that was recommended by AI. Given that everything is experimental and gated, it seemed weird to deep dive into the best representation. I'm fine with Yoav's suggestion too, though JSON is probably somewhat wasteful. Up to you.

Regarding compression, this is probably a must, given that we suspect this will be a non-trivial storage increase that we may need to prune regularly, but we can also compress bincode's bytes. Did it for now.


crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serde.rs line 105 at r6 (raw file):

Previously, dorimedini-starkware wrote…

why not do the same into_iter().try_fold pattern as above?

No good reason, changed.

@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch from 08c1864 to 0cfc5ca Compare May 27, 2026 12:00
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 3 files and all commit messages, and resolved 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArielElp).

@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from 7b6b74f to 22afd6e Compare May 27, 2026 12:24
@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch from 0cfc5ca to 21b871e Compare May 27, 2026 12:25
@ArielElp ArielElp force-pushed the ariel/accessed_keys_digest branch from 22afd6e to 5ab5e3f Compare May 27, 2026 14:31
@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch from 21b871e to 2e82fa4 Compare May 27, 2026 14:31
@ArielElp ArielElp changed the base branch from ariel/accessed_keys_digest to graphite-base/13994 May 27, 2026 15:30
@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch from 2e82fa4 to d978ebb Compare May 27, 2026 15:31
@ArielElp ArielElp changed the base branch from graphite-base/13994 to main May 27, 2026 15:31
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 27, 2026

@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch from d978ebb to 057831d Compare May 27, 2026 15:47
@ArielElp ArielElp force-pushed the ariel/patricia_paths_storage_serialization branch from 057831d to 1f3d5ed Compare May 27, 2026 16:20
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 3 files 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 401e67a 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