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

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

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 reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @yoavGrs).

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 made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ArielElp).


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

    let compiled_class_hash: &CompiledClassHash = compiled_class_hash_leaf.as_ref();
    let contract_class_leaf_version: Felt = Felt::from_hex(
        TreeHashFunctionImpl::CONTRACT_CLASS_LEAF_V0,

In the "global" namespace (TreeHashFunctionImpl), there is a constant defined only for compiled class hashes. In the same way, utils for compiled class hashes should be defined in the same place.

In addition, I prefer that the common place won't beTreeHashFunctionImpl. WDYT?

Code quote:

TreeHashFunctionImpl::CONTRACT_CLASS_LEAF_V0

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

    let contract_class_leaf_version: Felt = Felt::from_hex(
        TreeHashFunctionImpl::CONTRACT_CLASS_LEAF_V0,
    )

It's worth using the const function Felt::from_hex_unchecked for const strings.

Code quote:

    let contract_class_leaf_version: Felt = Felt::from_hex(
        TreeHashFunctionImpl::CONTRACT_CLASS_LEAF_V0,
    )

@ArielElp ArielElp force-pushed the ariel/generic_hash_leaves branch from 429b73c to e533d79 Compare December 23, 2025 13:40
@ArielElp ArielElp force-pushed the ariel/add_index_layout_leaves branch from 7501306 to 5ef8074 Compare December 23, 2025 13:40
@ArielElp ArielElp force-pushed the ariel/generic_hash_leaves branch from e533d79 to a243807 Compare December 23, 2025 15:10
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: 2 of 6 files reviewed, 2 unresolved discussions (waiting on @nimrod-starkware and @yoavGrs).


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

Previously, yoavGrs wrote…

In the "global" namespace (TreeHashFunctionImpl), there is a constant defined only for compiled class hashes. In the same way, utils for compiled class hashes should be defined in the same place.

In addition, I prefer that the common place won't beTreeHashFunctionImpl. WDYT?

Done.


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

Previously, yoavGrs wrote…

It's worth using the const function Felt::from_hex_unchecked for const strings.

Done.

@ArielElp ArielElp force-pushed the ariel/add_index_layout_leaves branch from 5ef8074 to aa16886 Compare December 23, 2025 15:36
@ArielElp ArielElp force-pushed the ariel/generic_hash_leaves branch from a243807 to 90e7204 Compare December 23, 2025 15:36
@ArielElp ArielElp force-pushed the ariel/add_index_layout_leaves branch from aa16886 to c737dbb Compare December 23, 2025 15:46
@ArielElp ArielElp force-pushed the ariel/generic_hash_leaves branch from 90e7204 to 3f524a2 Compare December 23, 2025 15:46
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 4 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArielElp).


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

Previously, ArielElp wrote…

Done.

I want this Felt to be calculated at compilation time. For this, the variable should be const (or static).
Please define at the top of the module:

const CONTRACT_CLASS_LEAF_VERSION: Felt = Felt::from_hex_unchecked(CONTRACT_CLASS_LEAF_V0);

@ArielElp ArielElp force-pushed the ariel/add_index_layout_leaves branch from c737dbb to b911edc Compare December 24, 2025 08:50
@ArielElp ArielElp force-pushed the ariel/generic_hash_leaves branch 2 times, most recently from 1c0264f to a2c5570 Compare December 24, 2025 11:38
@ArielElp ArielElp force-pushed the ariel/add_index_layout_leaves branch from b911edc to 2359a0b Compare December 24, 2025 11:38
@ArielElp ArielElp force-pushed the ariel/generic_hash_leaves branch from a2c5570 to b4a9eeb Compare December 24, 2025 11:41
@ArielElp ArielElp force-pushed the ariel/add_index_layout_leaves branch from 2359a0b to d3a873f Compare December 24, 2025 11:41
@ArielElp ArielElp force-pushed the ariel/generic_hash_leaves branch from b4a9eeb to 7348d98 Compare December 24, 2025 11:59
@ArielElp ArielElp force-pushed the ariel/add_index_layout_leaves branch from d3a873f to 4f38211 Compare December 24, 2025 11:59
@ArielElp ArielElp force-pushed the ariel/generic_hash_leaves branch from 7348d98 to f345f44 Compare December 24, 2025 12:13
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 1 comment.
Reviewable status: 2 of 6 files reviewed, 1 unresolved discussion (waiting on @yoavGrs).


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

Previously, yoavGrs wrote…

I want this Felt to be calculated at compilation time. For this, the variable should be const (or static).
Please define at the top of the module:

const CONTRACT_CLASS_LEAF_VERSION: Felt = Felt::from_hex_unchecked(CONTRACT_CLASS_LEAF_V0);

Done.

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 4 files 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/generic_hash_leaves branch from f345f44 to ee08d41 Compare December 24, 2025 13:16
@ArielElp ArielElp force-pushed the ariel/add_index_layout_leaves branch from 4f38211 to 47793bf Compare December 24, 2025 13:16
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 6 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ArielElp).


crates/starknet_committer/src/hash_function/hash.rs line 18 at r5 (raw file):

// The hex string corresponding to b'CONTRACT_CLASS_LEAF_V0' in big-endian.
pub const CONTRACT_CLASS_LEAF_V0: Felt =
    Felt::from_hex_unchecked("0x434f4e54524143545f434c4153535f4c4541465f5630");

this move of constants should have been a separate PR - broad change (many small diffs in different places), very easy to LGTM quickly, and self-contained

Code quote:

pub const CONTRACT_STATE_HASH_VERSION: Felt = Felt::ZERO;

// The hex string corresponding to b'CONTRACT_CLASS_LEAF_V0' in big-endian.
pub const CONTRACT_CLASS_LEAF_V0: Felt =
    Felt::from_hex_unchecked("0x434f4e54524143545f434c4153535f4c4541465f5630");

crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_impl.rs line 28 at r5 (raw file):

        self
    }
}

ditto

Code quote:

impl AsRef<ContractState> for ContractState {
    fn as_ref(&self) -> &ContractState {
        self
    }
}

crates/starknet_committer/src/patricia_merkle_tree/types.rs line 29 at r5 (raw file):

    fn as_ref(&self) -> &CompiledClassHash {
        self
    }

also, can't you derive_more::AsRef it?

Suggestion:

    fn as_ref(&self) -> &Self {
        self
    }

@ArielElp ArielElp force-pushed the ariel/add_index_layout_leaves branch from 47793bf to c1448aa Compare December 24, 2025 13:33
@ArielElp ArielElp force-pushed the ariel/generic_hash_leaves branch from ee08d41 to 450bebb Compare December 24, 2025 13:33
@ArielElp ArielElp force-pushed the ariel/add_index_layout_leaves branch from c1448aa to f89d76a Compare December 24, 2025 22:05
@ArielElp ArielElp force-pushed the ariel/generic_hash_leaves branch from 450bebb to 031bb06 Compare December 24, 2025 22:05
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: all files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware).


crates/starknet_committer/src/patricia_merkle_tree/types.rs line 29 at r5 (raw file):

Previously, dorimedini-starkware wrote…

also, can't you derive_more::AsRef it?

Nope, derive_more is for trivial wrappers Outer(inner).


crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_impl.rs line 28 at r5 (raw file):

Previously, dorimedini-starkware wrote…

ditto

Same as above

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