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 23, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ArielElp ArielElp force-pushed the ariel/enrich_layout_for_serialization branch from af9d87d to fb3bd7a Compare December 23, 2025 13:00
@ArielElp ArielElp force-pushed the ariel/layout_based_filled_tree branch 2 times, most recently from 4f377b7 to 81e3b32 Compare December 23, 2025 15:36
@ArielElp ArielElp force-pushed the ariel/enrich_layout_for_serialization branch 2 times, most recently from 3473676 to 9f2ba58 Compare December 24, 2025 08:50
@ArielElp ArielElp force-pushed the ariel/layout_based_filled_tree branch from 81e3b32 to 3c052e3 Compare December 24, 2025 08:50
@ArielElp ArielElp force-pushed the ariel/enrich_layout_for_serialization branch from 9f2ba58 to 3d47fa4 Compare December 24, 2025 11:41
@ArielElp ArielElp force-pushed the ariel/layout_based_filled_tree branch from 3c052e3 to 3653d2e Compare December 24, 2025 11:41
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.

:lgtm:

@yoavGrs reviewed 9 files and all commit messages, made 2 comments, and resolved 5 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArielElp and @nimrod-starkware).


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

/// While the same underlying type as `FactDbFilledNode`, this alias is not used in the context of
/// the DB-represnentation of the node.
pub type HashFilledNode<L> = FilledNode<L, HashOutput>;

Consider

Suggestion:

/// A node in an updated trie, where all the hashes were commputed. Used in the `FilledTree` trait.
///
/// While the same underlying type as `FactDbFilledNode`, this alias is not used in the context of
/// the DB-represnentation of the node.
pub type HashFilledNode<L> = FilledNode<L, HashOutput>;

pub type FactDbFilledNode<L> = HashFilledNode<L>;

@ArielElp ArielElp force-pushed the ariel/remove_generate_key_context branch from a6d209a to 921a6ab Compare January 13, 2026 09:34
@ArielElp ArielElp force-pushed the ariel/layout_based_filled_tree branch from 2072f41 to 6e88a70 Compare January 13, 2026 09:34
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 made 2 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArielElp).


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

pub type FactDbFilledNode<L> = FilledNode<L, HashOutput>;

/// A node in an updated trie, where all the hashes were commputed. Used in the `FilledTree` trait.

In our terminology updated can be updated skeleton and can confuse.

Suggestion:

/// A node in a filled trie, where all the hashes were commputed. Used in the `FilledTree` trait.

crates/starknet_committer/src/db/external_test_utils.rs line 43 at r6 (raw file):

        sorted_leaf_indices,
        &config,
        &leaf_modifications.iter().map(|(k, v)| (*k, v.clone().into())).collect(),

works?

Suggestion:

&leaf_modifications.into_iter().map(|(k, v)| (k, v.into())).collect(),

@ArielElp ArielElp force-pushed the ariel/layout_based_filled_tree branch from 6e88a70 to b85aed7 Compare January 13, 2026 15:21
@ArielElp ArielElp force-pushed the ariel/remove_generate_key_context branch from 921a6ab to 3cfa249 Compare January 13, 2026 15:21
@ArielElp ArielElp force-pushed the ariel/layout_based_filled_tree branch from b85aed7 to 1227dc3 Compare January 13, 2026 15:27
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.

@ArielElp made 2 comments.
Reviewable status: 8 of 9 files reviewed, 3 unresolved discussions (waiting on @nimrod-starkware and @yoavGrs).


crates/starknet_committer/src/db/external_test_utils.rs line 43 at r6 (raw file):

Previously, nimrod-starkware wrote…

works?

Here yes but it consumes leaf_modifications which is needed later.


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

Previously, nimrod-starkware wrote…

In our terminology updated can be updated skeleton and can confuse.

Done.

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.

:lgtm:

@nimrod-starkware made 1 comment and resolved 2 discussions.
Reviewable status: 8 of 9 files reviewed, 1 unresolved discussion (waiting on @ArielElp and @yoavGrs).

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.

@ArielElp resolved 1 discussion.
Reviewable status: 8 of 9 files reviewed, all discussions resolved (waiting on @dorimedini-starkware and @yoavGrs).

@ArielElp ArielElp force-pushed the ariel/layout_based_filled_tree branch 2 times, most recently from 1558fa6 to e91d422 Compare January 14, 2026 11:34
@ArielElp ArielElp force-pushed the ariel/remove_generate_key_context branch from 3cfa249 to a3bd7c3 Compare January 14, 2026 11:34
Copy link
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 9 files and all commit messages, and made 6 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArielElp).


crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs line 21 at r8 (raw file):

use crate::patricia_merkle_tree::updated_skeleton_tree::node::UpdatedSkeletonNode;
use crate::patricia_merkle_tree::updated_skeleton_tree::tree::UpdatedSkeletonTree;
#[cfg(test)]

revert line deletion

Suggestion:

use crate::patricia_merkle_tree::updated_skeleton_tree::tree::UpdatedSkeletonTree;

#[cfg(test)]

crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs line 57 at r8 (raw file):

pub struct FilledTreeImpl<L>
where
    L: Leaf,

why this diff?

Code quote:

pub struct FilledTreeImpl<L>
where
    L: Leaf,

crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs line 390 at r8 (raw file):

            })
            .collect::<Result<_, _>>()
    }

I don't like the cloning here
in a separate PR, can you check if serialize can be consuming?
if you add a get_all_nodes_owned method?

intuitively I'd say after serializing a trie you won't want to keep using the trie

Suggestion:

    fn serialize<Layout: NodeLayoutFor<L>>(
        self,
        key_context: &<Layout::DbLeaf as HasStaticPrefix>::KeyContext,
    ) -> SerializationResult<DbHashMap> {
        // This function iterates over each node in the tree, using the node's `db_key` as the
        // hashmap key and the result of the node's `serialize` method as the value.
        self.get_all_nodes_owned()
            .into_iter()
            .map(|(index, node)| {
                let (db_key, node_db_object) =
                    Layout::get_db_object(index, key_context, node);
                let db_value = node_db_object.serialize()?;
                Ok((db_key, db_value))
            })
            .collect::<Result<_, _>>()
    }

crates/starknet_committer/src/db/forest_trait.rs line 134 at r8 (raw file):

    <Layout as NodeLayoutFor<ContractState>>::DbLeaf: HasStaticPrefix<KeyContext = EmptyKeyContext>,
    <Layout as NodeLayoutFor<CompiledClassHash>>::DbLeaf:
        HasStaticPrefix<KeyContext = EmptyKeyContext>,

these trait bounds can (and should) be defined on the trait definition of Layout, right? this bound is always needed for every layout?

Code quote:

    Layout: NodeLayoutFor<StarknetStorageValue>
        + NodeLayoutFor<ContractState>
        + NodeLayoutFor<CompiledClassHash>,
    <Layout as NodeLayoutFor<StarknetStorageValue>>::DbLeaf:
        HasStaticPrefix<KeyContext = ContractAddress>,
    <Layout as NodeLayoutFor<ContractState>>::DbLeaf: HasStaticPrefix<KeyContext = EmptyKeyContext>,
    <Layout as NodeLayoutFor<CompiledClassHash>>::DbLeaf:
        HasStaticPrefix<KeyContext = EmptyKeyContext>,

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

/// While the same underlying type as `FactDbFilledNode`, this alias is not used in the context of
/// the DB-representation of the node.
pub type HashFilledNode<L> = FilledNode<L, HashOutput>;

compiler won't block you from sending a HashFilledNode<L> to a FactDbFilledNode<L> API or vice-versa, right?
since that's the case, I think instead of another name for the same type, we just need a better name (more general?)

Code quote:

/// A node in a filled tree, where all the hashes were computed. Used in the `FilledTree` trait.
///
/// While the same underlying type as `FactDbFilledNode`, this alias is not used in the context of
/// the DB-representation of the node.
pub type HashFilledNode<L> = FilledNode<L, HashOutput>;

crates/starknet_committer_and_os_cli/benches/main.rs line 52 at r8 (raw file):

                runtime.block_on(tree_computation_flow::<
                    StarknetStorageValue,
                    FactsNodeLayout,

maybe add a TODO to make this benchmark generic...?
we want to be able to benchmark both layouts (we will use both in production).
I'm imagining something like fn single_tree_flow_benchmark<Layout>(..)

Code quote:

FactsNodeLayout,

Copy link
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 and resolved 1 discussion.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ArielElp).


crates/starknet_committer/src/db/forest_trait.rs line 134 at r8 (raw file):

Previously, dorimedini-starkware wrote…

these trait bounds can (and should) be defined on the trait definition of Layout, right? this bound is always needed for every layout?

ah... next PR, I see

@ArielElp ArielElp force-pushed the ariel/layout_based_filled_tree branch from e91d422 to 660cdd6 Compare January 15, 2026 14:12
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.

@ArielElp made 2 comments.
Reviewable status: 8 of 9 files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware and @yoavGrs).


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

Previously, dorimedini-starkware wrote…

compiler won't block you from sending a HashFilledNode<L> to a FactDbFilledNode<L> API or vice-versa, right?
since that's the case, I think instead of another name for the same type, we just need a better name (more general?)

It won't, alias only helps you understand which type should be used where, but it doesn't stop you from using the "wrong" one.

If it helps, this PR https://reviewable.io/reviews/starkware-libs/sequencer/11644#- (last in the stack, after tests) uses a new wrapper of FilledNode for the DB type (not for naming reasons, only due to orphan rules, but this also helps your cause).


crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs line 21 at r8 (raw file):

Previously, dorimedini-starkware wrote…

revert line deletion

Done.

Copy link
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 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArielElp).

@ArielElp ArielElp force-pushed the ariel/remove_generate_key_context branch from a3bd7c3 to 27f9a13 Compare January 18, 2026 08:43
@ArielElp ArielElp force-pushed the ariel/layout_based_filled_tree branch from 660cdd6 to 0386f73 Compare January 18, 2026 08:43
@ArielElp ArielElp changed the base branch from ariel/remove_generate_key_context to graphite-base/10988 January 18, 2026 09:56
@ArielElp ArielElp force-pushed the ariel/layout_based_filled_tree branch from 0386f73 to 2b9093b Compare January 18, 2026 09:56
@ArielElp ArielElp force-pushed the graphite-base/10988 branch from 27f9a13 to 2787ec6 Compare January 18, 2026 09:56
@ArielElp ArielElp changed the base branch from graphite-base/10988 to main-v0.14.1-committer January 18, 2026 09:57
@ArielElp ArielElp added this pull request to the merge queue Jan 18, 2026
Merged via the queue into main-v0.14.1-committer with commit f7663a9 Jan 18, 2026
18 of 32 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.

6 participants