Skip to content

Conversation

@ArielElp
Copy link
Contributor

@ArielElp ArielElp commented Feb 10, 2026

Note

Low Risk
Additive API change that reuses existing hashing logic with fixed constants; low risk aside from potential downstream assumptions about hash semantics/usage.

Overview
Adds a new PartialBlockHash wrapper type representing the hash of PartialBlockHashComponents only (excluding state root and parent hash).

PartialBlockHash::from_partial_block_hash_components reuses the existing calculate_block_hash formula by fixing state_root and parent_hash to zero constants, and introduces the needed StarkHash import/serialization traits for the new type.

Written by Cursor Bugbot for commit e529641. This will update automatically on new commits. Configure here.

@reviewable-StarkWare
Copy link

This change is Reviewable

@github-actions
Copy link

github-actions bot commented Feb 10, 2026

Copy link
Contributor Author

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 1 comment.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @ArielElp).


crates/starknet_api/src/block_hash/block_hash_calculator.rs line 260 at r1 (raw file):

    )?;
    Ok(PartialBlockHash(block_hash.0))
}

consider this
IMO it's cleaner

Suggestion:

/// Hash of [`PartialBlockHashComponents`] only (no state root or parent hash).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PartialBlockHash(pub StarkHash);

impl PartialBlockHash {
    const GLOBAL_ROOT_FOR_PARTIAL_BLOCK_HASH = ..
    const PARENT_HASH_FOR_PARTIAL_BLOCK_HASH = ..
    
/// Hash of [`PartialBlockHashComponents`].
/// Uses the same formula as [`calculate_block_hash`] with the constants above for state root and
/// parent hash.
pub fn from_partial_components(
    partial_block_hash_components: &PartialBlockHashComponents,
) -> StarknetApiResult<Self> {
    let block_hash = calculate_block_hash(
        partial_block_hash_components,
        Self::GLOBAL_ROOT_FOR_PARTIAL_BLOCK_HASH,
        Self::PARENT_HASH_FOR_PARTIAL_BLOCK_HASH,
    )?;
    Ok(Self(block_hash.0))
}

@ArielElp ArielElp force-pushed the ariel/partial_block_hash_definition branch from 71a6a74 to 9d1db12 Compare February 10, 2026 15:14
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: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @nimrod-starkware).


crates/starknet_api/src/block_hash/block_hash_calculator.rs line 260 at r1 (raw file):

Previously, nimrod-starkware wrote…

consider this
IMO it's cleaner

Done.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

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


crates/starknet_api/src/block_hash/block_hash_calculator.rs line 179 at r2 (raw file):

    /// Hash of [`PartialBlockHashComponents`].
    /// Uses the same formula as [`calculate_block_hash`] with the fixed constants above for the
    /// state root and parent hash..

Suggestion:

state root and parent hash.

crates/starknet_api/src/block_hash/block_hash_calculator.rs line 180 at r2 (raw file):

    /// Uses the same formula as [`calculate_block_hash`] with the fixed constants above for the
    /// state root and parent hash..
    fn from_partial_block_hash_components(

Suggestion:

pub fn from_partial_block_hash_components(

crates/starknet_api/src/block_hash/block_hash_calculator.rs line 188 at r2 (raw file):

            Self::PARENT_HASH_FOR_PARTIAL_BLOCK_HASH,
        )?;
        Ok(PartialBlockHash(block_hash.0))

Suggestion:

Self

@ArielElp ArielElp force-pushed the ariel/partial_block_hash_definition branch from 9d1db12 to fc53903 Compare February 10, 2026 15:21
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 3 comments.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @nimrod-starkware).


crates/starknet_api/src/block_hash/block_hash_calculator.rs line 179 at r2 (raw file):

    /// Hash of [`PartialBlockHashComponents`].
    /// Uses the same formula as [`calculate_block_hash`] with the fixed constants above for the
    /// state root and parent hash..

Done.


crates/starknet_api/src/block_hash/block_hash_calculator.rs line 180 at r2 (raw file):

    /// Uses the same formula as [`calculate_block_hash`] with the fixed constants above for the
    /// state root and parent hash..
    fn from_partial_block_hash_components(

Done.


crates/starknet_api/src/block_hash/block_hash_calculator.rs line 188 at r2 (raw file):

            Self::PARENT_HASH_FOR_PARTIAL_BLOCK_HASH,
        )?;
        Ok(PartialBlockHash(block_hash.0))

Done.

@ArielElp ArielElp force-pushed the ariel/partial_block_hash_definition branch from fc53903 to e529641 Compare February 10, 2026 15:23
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 1 file and all commit messages, made 1 comment, and resolved 3 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArielElp).

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