diff --git a/crates/blockifier/src/execution/contract_class.rs b/crates/blockifier/src/execution/contract_class.rs index 1e257619b7..54c8c1f389 100644 --- a/crates/blockifier/src/execution/contract_class.rs +++ b/crates/blockifier/src/execution/contract_class.rs @@ -122,14 +122,6 @@ impl ContractClassV0 { self.entry_points_by_type.values().map(|vec| vec.len()).sum() } - pub fn n_builtins(&self) -> usize { - self.program.builtins_len() - } - - pub fn bytecode_length(&self) -> usize { - self.program.data_len() - } - fn estimate_casm_hash_computation_resources(&self) -> ExecutionResources { let hashed_data_size = (constants::CAIRO0_ENTRY_POINT_STRUCT_SIZE * self.n_entry_points()) + self.n_builtins() @@ -145,6 +137,14 @@ impl ContractClassV0 { } } + pub fn n_builtins(&self) -> usize { + self.program.builtins_len() + } + + pub fn bytecode_length(&self) -> usize { + self.program.data_len() + } + pub fn try_from_json_string(raw_contract_class: &str) -> Result { let contract_class: ContractClassV0Inner = serde_json::from_str(raw_contract_class)?; Ok(ContractClassV0(Arc::new(contract_class))) @@ -185,6 +185,23 @@ impl ContractClassV1 { Some(self.0.entry_points_by_type[&EntryPointType::Constructor].first()?.selector) } + /// Returns the estimated VM resources required for computing Casm hash. + /// This is an empiric measurement of several bytecode lengths, which constitutes as the + /// dominant factor in it. + fn estimate_casm_hash_computation_resources(&self) -> ExecutionResources { + estimate_casm_hash_computation_resources(&self.bytecode_segment_lengths) + } + + // Returns the set of segments that were visited according to the given visited PCs. + // Each visited segment must have its starting PC visited, and is represented by it. + fn get_visited_segments( + &self, + visited_pcs: &HashSet, + ) -> Result, TransactionExecutionError> { + let mut reversed_visited_pcs: Vec<_> = visited_pcs.iter().cloned().sorted().rev().collect(); + get_visited_segments(&self.bytecode_segment_lengths, &mut reversed_visited_pcs, &mut 0) + } + pub fn bytecode_length(&self) -> usize { self.program.data_len() } @@ -219,23 +236,6 @@ impl ContractClassV1 { } } - /// Returns the estimated VM resources required for computing Casm hash. - /// This is an empiric measurement of several bytecode lengths, which constitutes as the - /// dominant factor in it. - fn estimate_casm_hash_computation_resources(&self) -> ExecutionResources { - estimate_casm_hash_computation_resources(&self.bytecode_segment_lengths) - } - - // Returns the set of segments that were visited according to the given visited PCs. - // Each visited segment must have its starting PC visited, and is represented by it. - fn get_visited_segments( - &self, - visited_pcs: &HashSet, - ) -> Result, TransactionExecutionError> { - let mut reversed_visited_pcs: Vec<_> = visited_pcs.iter().cloned().sorted().rev().collect(); - get_visited_segments(&self.bytecode_segment_lengths, &mut reversed_visited_pcs, &mut 0) - } - pub fn try_from_json_string(raw_contract_class: &str) -> Result { let casm_contract_class: CasmContractClass = serde_json::from_str(raw_contract_class)?; let contract_class: ContractClassV1 = casm_contract_class.try_into()?;