Skip to content

Commit 6e19b77

Browse files
blockifier: encode blake in trait
1 parent 6cbb062 commit 6e19b77

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

crates/blockifier/src/execution/casm_hash_estimation.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::execution::contract_class::{
1010
FeltSizeCount,
1111
NestedFeltCounts,
1212
};
13-
use crate::execution::execution_utils::poseidon_hash_many_cost;
13+
use crate::execution::execution_utils::{encode_and_blake_hash_resources, poseidon_hash_many_cost};
1414
use crate::utils::u64_from_usize;
1515

1616
#[cfg(test)]
@@ -151,8 +151,7 @@ trait EstimateCasmHashResources {
151151
/// Estimates the Cairo execution resources used when applying the hash function during CASM
152152
/// hashing.
153153
fn estimated_resources_of_hash_function(
154-
&mut self,
155-
_felt_count: FeltSizeCount,
154+
_felt_size_groups: &FeltSizeCount,
156155
) -> EstimatedExecutionResources;
157156

158157
/// Estimates the Cairo execution resources for `compiled_class_hash` in the
@@ -177,12 +176,11 @@ impl EstimateCasmHashResources for CasmV1HashResourceEstimate {
177176
}
178177

179178
fn estimated_resources_of_hash_function(
180-
&mut self,
181-
felt_count: FeltSizeCount,
179+
felt_size_groups: &FeltSizeCount,
182180
) -> EstimatedExecutionResources {
183181
EstimatedExecutionResources::V1Hash {
184182
// TODO(AvivG): Consider inlining `poseidon_hash_many_cost` logic here.
185-
resources: poseidon_hash_many_cost(felt_count.n_felts()),
183+
resources: poseidon_hash_many_cost(felt_size_groups.n_felts()),
186184
}
187185
}
188186
}
@@ -197,10 +195,8 @@ impl EstimateCasmHashResources for CasmV2HashResourceEstimate {
197195
}
198196

199197
fn estimated_resources_of_hash_function(
200-
&mut self,
201-
_felt_count: FeltSizeCount,
198+
felt_size_groups: &FeltSizeCount,
202199
) -> EstimatedExecutionResources {
203-
// TODO(AvivG): Use `cost_of_encode_felt252_data_and_calc_blake_hash` once it returns ER.
204-
EstimatedExecutionResources::new(HashVersion::V2)
200+
encode_and_blake_hash_resources(felt_size_groups)
205201
}
206202
}

crates/blockifier/src/execution/contract_class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl FeltSizeCount {
8686
}
8787

8888
/// Returns the total number of `u32` words required to encode all felts
89-
/// according to the small/large felt encoding scheme.
89+
/// according to `encode_felts_to_u32s` function.
9090
pub(crate) fn encoded_u32_len(&self) -> usize {
9191
self.large * Self::U32_WORDS_PER_LARGE_FELT + self.small * Self::U32_WORDS_PER_SMALL_FELT
9292
}

0 commit comments

Comments
 (0)