Skip to content

Conversation

@ArielElp
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

ArielElp commented Dec 10, 2025

@ArielElp ArielElp marked this pull request as ready for review December 10, 2025 13:18
@ArielElp ArielElp changed the base branch from ariel/db_keys to graphite-base/10679 December 10, 2025 15:06
@ArielElp ArielElp force-pushed the graphite-base/10679 branch from de081a6 to 6d13cf1 Compare December 10, 2025 15:06
@ArielElp ArielElp changed the base branch from graphite-base/10679 to ariel/add_deserialization_context December 10, 2025 15:07
Copy link
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 16 of 16 files at r1, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @ArielElp)


crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/node.rs line 8 at r1 (raw file):

#[derive(Clone, Debug, PartialEq, Eq)]
/// A node in a Patricia-Merkle tree, complete with its hash and data.
pub struct FilledNode<L: Leaf> {

I'm guessing that this will be the next step here, right?

Suggestion:

pub struct FilledNode<L: Leaf, HashOutput>

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

    /// Computes the hash for the given node data.
    fn compute_node_hash(node_data: &NodeData<L, HashOutput>) -> HashOutput;

Same question in this file.

Suggestion:

 fn compute_node_hash<T>(node_data: &NodeData<L, T>) -> HashOutput;

crates/starknet_patricia/src/patricia_merkle_tree/internal_test_utils.rs line 27 at r1 (raw file):

    }

    fn compute_node_hash(node_data: &NodeData<MockLeaf, HashOutput>) -> HashOutput {

Same question

Suggestion:

 fn compute_node_hash<T>(node_data: &NodeData<MockLeaf, T>) -> HashOutput {

crates/starknet_committer/src/hash_function/hash.rs line 54 at r1 (raw file):

        ))
    }
    fn compute_node_hash(node_data: &NodeData<ContractState, HashOutput>) -> HashOutput {

Why does it work only for HashOutput type?
Same question below.

Suggestion:

fn compute_node_hash<T>(node_data: &NodeData<ContractState, T>) -> HashOutput

crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 22 at r1 (raw file):

#[cfg_attr(any(test, feature = "testing"), derive(strum_macros::EnumDiscriminants))]
#[cfg_attr(any(test, feature = "testing"), strum_discriminants(derive(strum_macros::EnumIter)))]
// A Patricia-Merkle tree node's data, i.e., the pre-image of its hash.

Is it correct?

Code quote:

// A Patricia-Merkle tree node's data, i.e., the pre-image of its hash.

crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 39 at r1 (raw file):

        vec![self.left_data.0, self.right_data.0]
    }
}

Are you going to move it under facts_db?
If it is not in the next PR, please add TODO.

Code quote:

impl BinaryData<HashOutput> {
    pub fn flatten(&self) -> Vec<Felt> {
        vec![self.left_data.0, self.right_data.0]
    }
}

crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 157 at r1 (raw file):

        ]
    }
}

Same question.

Code quote:

impl EdgeData<HashOutput> {
    pub fn flatten(&self) -> Vec<Felt> {
        vec![
            self.path_to_bottom.length.into(),
            (&self.path_to_bottom.path).into(),
            self.bottom_data.0,
        ]
    }
}

crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 204 at r1 (raw file):

#[derive(Clone, Debug, PartialEq)]
pub enum Preimage {

Is it relevant for both layers?
If not, please add a TODO for moving it under facts_db.

Code quote:

pub enum Preimage {

@ArielElp ArielElp force-pushed the ariel/add_deserialization_context branch from 6d13cf1 to a185e9a Compare December 10, 2025 15:35
@ArielElp ArielElp force-pushed the abstract_node_data branch 2 times, most recently from 00cd7a5 to 560776a Compare December 10, 2025 15:41
@ArielElp ArielElp force-pushed the ariel/add_deserialization_context branch from a185e9a to 743c49b Compare December 10, 2025 15:41
@ArielElp ArielElp force-pushed the abstract_node_data branch 2 times, most recently from e1719c0 to 1470e1e Compare December 10, 2025 19:46
Copy link
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.

Reviewable status: 15 of 16 files reviewed, 8 unresolved discussions (waiting on @yoavGrs)


crates/starknet_committer/src/hash_function/hash.rs line 54 at r1 (raw file):

Previously, yoavGrs wrote…

Why does it work only for HashOutput type?
Same question below.

The hashing logic assumes a node carries the hash of its children, otherwise it can't compute the hash of the node. Even if this were generic you'd need some way to do T --> Hash.

This isn't really layout-dependent code.


crates/starknet_patricia/src/patricia_merkle_tree/internal_test_utils.rs line 27 at r1 (raw file):

Previously, yoavGrs wrote…

Same question

See above


crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/node.rs line 8 at r1 (raw file):

Previously, yoavGrs wrote…

I'm guessing that this will be the next step here, right?

Sort of, the next step is to make it generic, FilledNode<L, ChildData>


crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 22 at r1 (raw file):

Previously, yoavGrs wrote…

Is it correct?

The second part is no longer correct, removing


crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 39 at r1 (raw file):

Previously, yoavGrs wrote…

Are you going to move it under facts_db?
If it is not in the next PR, please add TODO.

ATM it's still there. There's some issues with moving it:

  1. It's used in Preimage and in the starknet_os crate. That's not really a blocker since we can move the entire Preimage logic, and starknet_os already depends on the committer
  2. We need BinaryData next to NodeData, so we'll need to add a flatten trait in starknet_patricia and make Preimage work on things that implement this trait (we can't impl directly for the type since the type is foreign in starknet_committer)

crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 157 at r1 (raw file):

Previously, yoavGrs wrote…

Same question.

See above


crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 204 at r1 (raw file):

Previously, yoavGrs wrote…

Is it relevant for both layers?
If not, please add a TODO for moving it under facts_db.

Nope, we can move it modulo slight refactor to preimage. Added TODO


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

Previously, yoavGrs wrote…

Same question in this file.

See above

@ArielElp ArielElp force-pushed the ariel/add_deserialization_context branch from b50df9d to d41c9d5 Compare December 10, 2025 19:58
@ArielElp ArielElp force-pushed the abstract_node_data branch 2 times, most recently from 68f6987 to 2c6a229 Compare December 11, 2025 06:51
@ArielElp ArielElp force-pushed the ariel/add_deserialization_context branch 2 times, most recently from ae7da9d to 17c75e3 Compare December 11, 2025 08:45
Copy link
Contributor

@nimrod-starkware nimrod-starkware left a comment

Choose a reason for hiding this comment

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

@nimrod-starkware reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @yoavGrs)

@ArielElp ArielElp force-pushed the ariel/add_deserialization_context branch from 17c75e3 to 31faa1a Compare December 11, 2025 12:28
@ArielElp ArielElp force-pushed the abstract_node_data branch 2 times, most recently from 8d7c15c to fd1d090 Compare December 11, 2025 13:04
@ArielElp ArielElp force-pushed the ariel/add_deserialization_context branch 2 times, most recently from 539461a to ba38be7 Compare December 11, 2025 13:22
@ArielElp ArielElp force-pushed the abstract_node_data branch 2 times, most recently from 71c89a6 to c4727df Compare December 11, 2025 13:43
@ArielElp ArielElp force-pushed the ariel/add_deserialization_context branch from ba38be7 to 27a9372 Compare December 11, 2025 13:43
@ArielElp ArielElp changed the base branch from ariel/add_deserialization_context to graphite-base/10679 December 11, 2025 13:46
@ArielElp ArielElp force-pushed the graphite-base/10679 branch from 27a9372 to 71f9ce7 Compare December 11, 2025 14:36
@ArielElp ArielElp changed the base branch from graphite-base/10679 to ariel/add_deserialization_context December 11, 2025 14:37
@ArielElp ArielElp force-pushed the ariel/add_deserialization_context branch from 126e08c to 76dfba8 Compare December 11, 2025 16:31
@ArielElp ArielElp force-pushed the abstract_node_data branch 2 times, most recently from 12afbd4 to 2732847 Compare December 11, 2025 16:56
@ArielElp ArielElp force-pushed the ariel/add_deserialization_context branch from 76dfba8 to 61ce00b Compare December 11, 2025 16:56
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.

5 participants