Skip to content

Commit a81bc8c

Browse files
blockifier: change input to felt_counts fn count_blake_opcodes
1 parent 8ac89c1 commit a81bc8c

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

crates/blockifier/src/execution/execution_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,9 @@ fn estimate_steps_of_encode_felt252_data_and_calc_blake_hash(
448448

449449
/// Returns the number of BLAKE opcodes needed to hash the given felts.
450450
/// Each BLAKE opcode processes 16 u32s (partial messages are padded).
451-
fn count_blake_opcode(n_big_felts: usize, n_small_felts: usize) -> usize {
451+
fn count_blake_opcode(felt_size_groups: &FeltSizeCount) -> usize {
452452
// Count the total number of u32s to be hashed.
453-
let total_u32s = total_u32s_from_felts(n_big_felts, n_small_felts);
453+
let total_u32s = total_u32s_from_felts(felt_size_groups.large, felt_size_groups.small);
454454
total_u32s.div_ceil(FeltSizeCount::U32_WORDS_PER_MESSAGE)
455455
}
456456

@@ -482,7 +482,7 @@ pub fn encode_and_blake_hash_resources(
482482

483483
EstimatedExecutionResources::V2Hash {
484484
resources,
485-
blake_count: count_blake_opcode(felt_size_groups.large, felt_size_groups.small),
485+
blake_count: count_blake_opcode(felt_size_groups),
486486
}
487487
}
488488

crates/blockifier/src/execution/execution_utils_test.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ fn test_u32_constants() {
3030
#[test]
3131
fn test_zero_inputs() {
3232
// logic was written.
33-
let steps = estimate_steps_of_encode_felt252_data_and_calc_blake_hash(&FeltSizeCount {
34-
large: 0,
35-
small: 0,
36-
});
33+
let steps =
34+
estimate_steps_of_encode_felt252_data_and_calc_blake_hash(&FeltSizeCount::default());
3735
assert_eq!(steps, STEPS_EMPTY_INPUT, "Unexpected base step cost for zero inputs");
3836

3937
// No opcodes should be emitted.
40-
let opcodes = count_blake_opcode(0, 0);
38+
let opcodes = count_blake_opcode(&FeltSizeCount::default());
4139
assert_eq!(opcodes, 0, "Expected zero BLAKE opcodes for zero inputs");
4240

4341
// Should result in base cost only (no opcode cost).

0 commit comments

Comments
 (0)