Skip to content

blockifier: move logic inside casm_v2hash_resource_estimate #8694

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/encode_blake_into_trait
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 marked this pull request as ready for review August 19, 2025 16:31
@avivg-starkware avivg-starkware changed the base branch from avivg/blockfier/move_logic_to_casm_estimation to graphite-base/8694 August 19, 2025 17:01
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch from f01435a to 9d6cd2b Compare August 19, 2025 17:01
@avivg-starkware avivg-starkware changed the base branch from graphite-base/8694 to avivg/blockifier/encode_blake_into_trait August 19, 2025 17:01
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch from 9d6cd2b to 6005d15 Compare August 20, 2025 05:28
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/encode_blake_into_trait branch from 7afade2 to af6faaa Compare August 20, 2025 07:34
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch from 6005d15 to 1305fdd Compare August 20, 2025 07:34
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch from 1305fdd to e0cd0c5 Compare August 20, 2025 07:52
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/encode_blake_into_trait branch from af6faaa to 511a4db Compare August 20, 2025 07:52
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/encode_blake_into_trait branch from 511a4db to d4ea96b Compare August 20, 2025 08:12
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch from e0cd0c5 to bad4524 Compare August 20, 2025 08:12
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 4 files reviewed, 1 unresolved discussion


crates/blockifier/src/execution/casm_hash_estimation.rs line 276 at r2 (raw file):

        .expect("Overflow computing small felt steps");
    big_steps.checked_add(small_steps).expect("Overflow computing total felt steps")
}

inserted this logic directly to estimate_steps_of_encode_felt252_data_and_calc_blake_hash and removed redundant "checked arithmetic"

Code quote:

fn base_steps_for_blake_hash(n_u32s: usize) -> usize {
    let rem_u32s = n_u32s % FeltSizeCount::U32_WORDS_PER_MESSAGE;
    if rem_u32s == 0 {
        blake_estimation::BASE_STEPS_FULL_MSG
    } else {
        // This computation is based on running blake2s with different inputs.
        // Note: all inputs expand to an even number of u32s --> `rem_u32s` is always even.
        blake_estimation::BASE_STEPS_PARTIAL_MSG
            + (rem_u32s / 2) * blake_estimation::STEPS_PER_2_U32_REMINDER
    }
}

fn felts_steps(n_big_felts: usize, n_small_felts: usize) -> usize {
    let big_steps = n_big_felts
        .checked_mul(blake_estimation::STEPS_BIG_FELT)
        .expect("Overflow computing big felt steps");
    let small_steps = n_small_felts
        .checked_mul(blake_estimation::STEPS_SMALL_FELT)
        .expect("Overflow computing small felt steps");
    big_steps.checked_add(small_steps).expect("Overflow computing total felt steps")
}

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch from bad4524 to 8aecc8d Compare August 20, 2025 08:39
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/encode_blake_into_trait branch from d4ea96b to 7568ef4 Compare August 20, 2025 08:39
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch from 8aecc8d to 8a8597d Compare August 20, 2025 08:46
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/encode_blake_into_trait branch 2 times, most recently from 0b986ac to f12c23e Compare August 20, 2025 08:55
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch 3 times, most recently from 68d0b25 to eda0a31 Compare August 20, 2025 10:24
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/encode_blake_into_trait branch 2 times, most recently from 71c9104 to e4ada08 Compare August 20, 2025 11:16
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch from eda0a31 to fe41410 Compare August 20, 2025 11:16
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/encode_blake_into_trait branch from e4ada08 to 8715ec2 Compare August 20, 2025 12:07
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch 2 times, most recently from 5a100c2 to 7c34d8a Compare August 20, 2025 13:28
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/encode_blake_into_trait branch from 8715ec2 to 1a5798f Compare August 20, 2025 13:28
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/move_logic_inside_casm_v2hash_struct branch from 7c34d8a to a11f641 Compare August 20, 2025 13:30
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/encode_blake_into_trait branch from 1a5798f to fa4087c Compare August 20, 2025 13:30
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.

2 participants