Skip to content

blockifier: move logic inside felt_size_count #8692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: avivg/blockifier/move_const_fo_felt_size_count
Choose a base branch
from

Conversation

avivg-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@avivg-starkware avivg-starkware changed the base branch from avivg/blockifier/encode_recieve_felts_counts to graphite-base/8692 August 20, 2025 07:34
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_to_feltsize branch from 56419e6 to 592d498 Compare August 20, 2025 07:34
@avivg-starkware avivg-starkware changed the base branch from graphite-base/8692 to avivg/blockifier/felt_count_input_to_count_blake August 20, 2025 07:35
@avivg-starkware avivg-starkware changed the base branch from avivg/blockifier/felt_count_input_to_count_blake to graphite-base/8692 August 20, 2025 07:52
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_to_feltsize branch from 592d498 to 889cd06 Compare August 20, 2025 07:52
@avivg-starkware avivg-starkware changed the base branch from graphite-base/8692 to avivg/blockifier/felt_count_input_to_count_blake_opcode August 20, 2025 07:53
Copy link
Contributor Author

@avivg-starkware avivg-starkware 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: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @AvivYossef-starkware and @noaov1)


crates/blockifier/src/execution/execution_utils.rs line 409 at r1 (raw file):

/// Calculates the total number of u32s required to encode the given number of big and small felts.
/// Big felts encode to 8 u32s each, small felts encode to 2 u32s each.
fn total_u32s_from_felts(n_big_felts: usize, n_small_felts: usize) -> usize {

Changed the name of the func to this:

Suggestion:

encoded_u32_len

crates/blockifier/src/execution/execution_utils.rs line 416 at r1 (raw file):

        .checked_mul(blake_encoding::N_U32S_SMALL_FELT)
        .expect("Overflow computing small felts u32s");
    big_u32s.checked_add(small_u32s).expect("Overflow computing total u32s")

removed checked_add safety
Seems redundant when looking at other places in the code in which arithmetics with n_steps are done (steps > u32 count)

Suggestion:

    let big_u32s = n_big_felts
        .checked_mul(blake_encoding::N_U32S_BIG_FELT)
        .expect("Overflow computing big felts u32s");
    let small_u32s = n_small_felts
        .checked_mul(blake_encoding::N_U32S_SMALL_FELT)
        .expect("Overflow computing small felts u32s");
    big_u32s.checked_add(small_u32s).expect("Overflow computing total u32s"

crates/blockifier/src/execution/execution_utils.rs line 459 at r1 (raw file):

/// Returns the number of BLAKE opcodes needed to hash the given felts.
/// Each BLAKE opcode processes 16 u32s (partial messages are padded).
fn count_blake_opcode(n_big_felts: usize, n_small_felts: usize) -> usize {

Changed the name of the func to this:

Suggestion:

blake_opcode_count

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_to_feltsize branch from 889cd06 to a519a77 Compare August 20, 2025 08:12
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/felt_count_input_to_count_blake_opcode branch 2 times, most recently from 86ab5e4 to 9c31a44 Compare August 20, 2025 08:39
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_to_feltsize branch 2 times, most recently from 90a20d7 to 7a2291c Compare August 20, 2025 11:16
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/felt_count_input_to_count_blake_opcode branch from 9c31a44 to 7777a53 Compare August 20, 2025 11:16
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_to_feltsize branch from 7a2291c to 53418be Compare August 20, 2025 12:07
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/felt_count_input_to_count_blake_opcode branch from 7777a53 to 58de25c Compare August 20, 2025 12:07
Copy link
Contributor

@AvivYossef-starkware AvivYossef-starkware left a comment

Choose a reason for hiding this comment

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

@AvivYossef-starkware reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @noaov1)


crates/blockifier/src/execution/contract_class.rs line 89 at r2 (raw file):

    /// Returns the total number of `u32` words required to encode all felts
    /// according to the small/large felt encoding scheme.

Suggestion:

encode_felts_to_u32s func

crates/blockifier/src/execution/contract_class.rs line 92 at r2 (raw file):

    pub(crate) fn encoded_u32_len(&self) -> usize {
        self.large * Self::U32_WORDS_PER_LARGE_FELT + self.small * Self::U32_WORDS_PER_SMALL_FELT
    }

plz add test that compare it to the actual encoding

Code quote:

    pub(crate) fn encoded_u32_len(&self) -> usize {
        self.large * Self::U32_WORDS_PER_LARGE_FELT + self.small * Self::U32_WORDS_PER_SMALL_FELT
    }

Copy link
Contributor Author

@avivg-starkware avivg-starkware 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: all files reviewed, 4 unresolved discussions (waiting on @avivg-starkware and @noaov1)


crates/blockifier/src/execution/contract_class.rs line 92 at r2 (raw file):

Previously, AvivYossef-starkware wrote…

plz add test that compare it to the actual encoding

Working on it


crates/blockifier/src/execution/contract_class.rs line 89 at r2 (raw file):

    /// Returns the total number of `u32` words required to encode all felts
    /// according to the small/large felt encoding scheme.

done

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/felt_count_input_to_count_blake_opcode branch from 58de25c to a81bc8c Compare August 20, 2025 13:28
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_to_feltsize branch from 53418be to 6cbb062 Compare August 20, 2025 13:28
Copy link
Contributor

@AvivYossef-starkware AvivYossef-starkware left a comment

Choose a reason for hiding this comment

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

@AvivYossef-starkware reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avivg-starkware and @noaov1)


crates/blockifier/src/execution/contract_class.rs line 89 at r2 (raw file):

Previously, avivg-starkware wrote…

done

where?

@avivg-starkware avivg-starkware changed the base branch from avivg/blockifier/felt_count_input_to_count_blake_opcode to graphite-base/8692 August 20, 2025 15:00
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_to_feltsize branch from 6cbb062 to 2547751 Compare August 20, 2025 15:19
@avivg-starkware avivg-starkware changed the base branch from graphite-base/8692 to avivg/blockifier/move_const_fo_felt_size_count August 20, 2025 15:19
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_to_feltsize branch from 2547751 to f5713fd Compare August 20, 2025 15:35
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_const_fo_felt_size_count branch from b76d138 to bbca19d Compare August 20, 2025 15:35
Copy link
Contributor Author

@avivg-starkware avivg-starkware 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: 1 of 4 files reviewed, 4 unresolved discussions (waiting on @AvivYossef-starkware and @noaov1)


crates/blockifier/src/execution/contract_class.rs line 89 at r2 (raw file):

Previously, AvivYossef-starkware wrote…

where?

sorry, now


crates/blockifier/src/execution/contract_class.rs line 92 at r2 (raw file):

Previously, avivg-starkware wrote…

Working on it

added

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