Skip to content

starknet_committer: support both layouts in fetch_patricia_paths#13958

Open
ArielElp wants to merge 1 commit into
mainfrom
ariel/refactor_fetch_patricia_paths
Open

starknet_committer: support both layouts in fetch_patricia_paths#13958
ArielElp wants to merge 1 commit into
mainfrom
ariel/refactor_fetch_patricia_paths

Conversation

@ArielElp
Copy link
Copy Markdown
Contributor

@ArielElp ArielElp commented May 5, 2026

No description provided.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Contributor Author

ArielElp commented May 5, 2026

@ArielElp ArielElp force-pushed the ariel/refactor_fetch_patricia_paths branch from 1ace527 to 61f0e7e Compare May 5, 2026 08:51
@ArielElp ArielElp force-pushed the ariel/refactor_fetch_patricia_paths branch from 61f0e7e to b6f331e Compare May 7, 2026 12:02
@ArielElp ArielElp marked this pull request as ready for review May 7, 2026 14:31
@cursor
Copy link
Copy Markdown

cursor Bot commented May 7, 2026

PR Summary

Medium Risk
Touches core Patricia witness generation used for proofs by refactoring and changing traversal logic to handle both storage layouts; incorrect hashing/traversal could produce invalid witnesses.

Overview
Moves fetch_patricia_paths/fetch_patricia_paths_inner out of facts_db::traversal into trie_traversal and makes them generic over NodeLayout, so the same API can fetch witnesses for both facts and non-facts DB layouts.

Updates the traversal algorithm to cope with layouts where child hashes aren’t embedded in the parent value by queuing “hash-only” reads for unmodified children and deferring PreimageMap inserts until required child hashes are available.

Adjusts call sites in patricia_merkle_tree/tree.rs to pass FactsNodeLayout, and relocates the traversal tests accordingly.

Reviewed by Cursor Bugbot for commit 22de1c4. 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 made 1 comment.
Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on ArielElp).


a discussion (no related file):
Please separate moving the file from the changes made inside it. It’ll make it easier for me to review the changes.

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 1 file, made 6 comments, and resolved 1 discussion.
Reviewable status: 1 of 4 files reviewed, 6 unresolved discussions (waiting on ArielElp).


crates/starknet_committer/src/db/facts_db/traversal.rs line 53 at r1 (raw file):

}

// TODO(Rotem): Match the python logic of fetching the nodes.

What about this TODO?
On this point, is there a note in the test that we are collecting too many nodes?

Code quote:

// TODO(Rotem): Match the python logic of fetching the nodes.

crates/starknet_committer/src/db/trie_traversal.rs line 57 at r1 (raw file):

#[cfg(test)]
#[path = "facts_db/traversal_test.rs"]

The test should be beside the corresponding module.

Code quote:

"facts_db/traversal_test.rs"

crates/starknet_committer/src/db/trie_traversal.rs line 61 at r1 (raw file):

/// Logs out a warning of a trivial modification.
macro_rules! log_trivial_modification {

Move it down, please.
(Top-down Ordering)

Code quote:

macro_rules! log_trivial_modification 

crates/starknet_committer/src/db/trie_traversal.rs line 67 at r1 (raw file):

}

/// Returns the Patricia inner nodes ([PreimageMap]) in the paths to the given `leaf_indices` in the

With the siblings?

Code quote:

in the paths to the given `leaf_indices`

crates/starknet_committer/src/db/trie_traversal.rs line 101 at r1 (raw file):

/// Required for `patricia_update` function in Cairo.
/// Extra preimages (more than the data required to verify merkle paths) are required to verify
/// correctness of final tree topology; for more details see 'traverse_edge' in 'patricia.cairo'.

Not in this repo

Code quote:

 see 'traverse_edge' in 'patricia.cairo'

crates/starknet_committer/src/db/trie_traversal.rs line 129 at r1 (raw file):

    while !current_traversal.is_empty() || !current_hash_only.is_empty() {
        read_hashes::<L, Layout>(&current_hash_only, storage, key_context, &mut hash_by_index)
            .await?;

Can you read all the hashes for the waiting hash-only vector outside the loop?

Code quote:

        read_hashes::<L, Layout>(&current_hash_only, storage, key_context, &mut hash_by_index)
            .await?;

@ArielElp ArielElp force-pushed the ariel/refactor_fetch_patricia_paths branch from b6f331e to 22de1c4 Compare May 14, 2026 08:43
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