diff --git a/crates/starknet_os/src/hints.rs b/crates/starknet_os/src/hints.rs index cfa8ccae57..eed34a0615 100644 --- a/crates/starknet_os/src/hints.rs +++ b/crates/starknet_os/src/hints.rs @@ -1,6 +1,7 @@ pub mod block_context; pub mod bls_field; pub mod builtins; +pub mod compiled_class; pub mod enum_definition; pub mod enum_generation; pub mod error; diff --git a/crates/starknet_os/src/hints/compiled_class.rs b/crates/starknet_os/src/hints/compiled_class.rs new file mode 100644 index 0000000000..2c4f3afba4 --- /dev/null +++ b/crates/starknet_os/src/hints/compiled_class.rs @@ -0,0 +1,49 @@ +use std::collections::HashMap; + +use cairo_vm::hint_processor::hint_processor_definition::HintReference; +use cairo_vm::serde::deserialize_program::ApTracking; +use cairo_vm::types::exec_scope::ExecutionScopes; +use cairo_vm::vm::vm_core::VirtualMachine; +use starknet_types_core::felt::Felt; + +use crate::hints::error::HintResult; + +pub fn assign_bytecode_segments( + _vm: &mut VirtualMachine, + _exec_scopes: &mut ExecutionScopes, + _ids_data: &HashMap, + _ap_tracking: &ApTracking, + _constants: &HashMap, +) -> HintResult { + todo!() +} + +pub fn assert_end_of_bytecode_segments( + _vm: &mut VirtualMachine, + _exec_scopes: &mut ExecutionScopes, + _ids_data: &HashMap, + _ap_tracking: &ApTracking, + _constants: &HashMap, +) -> HintResult { + todo!() +} + +pub fn iter_current_segment_info( + _vm: &mut VirtualMachine, + _exec_scopes: &mut ExecutionScopes, + _ids_data: &HashMap, + _ap_tracking: &ApTracking, + _constants: &HashMap, +) -> HintResult { + todo!() +} + +pub fn set_ap_to_segment_hash( + _vm: &mut VirtualMachine, + _exec_scopes: &mut ExecutionScopes, + _ids_data: &HashMap, + _ap_tracking: &ApTracking, + _constants: &HashMap, +) -> HintResult { + todo!() +} diff --git a/crates/starknet_os/src/hints/enum_definition.rs b/crates/starknet_os/src/hints/enum_definition.rs index dc424d0da8..3fc996c450 100644 --- a/crates/starknet_os/src/hints/enum_definition.rs +++ b/crates/starknet_os/src/hints/enum_definition.rs @@ -26,6 +26,12 @@ use crate::hints::block_context::{ }; use crate::hints::bls_field::compute_ids_low; use crate::hints::builtins::{select_builtin, selected_builtins, update_builtin_ptrs}; +use crate::hints::compiled_class::{ + assert_end_of_bytecode_segments, + assign_bytecode_segments, + iter_current_segment_info, + set_ap_to_segment_hash, +}; use crate::hints::error::{HintExtensionResult, HintResult, OsHintError}; use crate::hints::types::{HintEnum, HintExtensionImplementation, HintImplementation}; use crate::{define_hint_enum, define_hint_extension_enum}; @@ -184,6 +190,45 @@ define_hint_enum!( ), )"# } + ), + ( + AssignBytecodeSegments, + assign_bytecode_segments, + indoc! {r#" + bytecode_segments = iter(bytecode_segment_structure.segments)"# + } + ), + ( + AssertEndOfBytecodeSegments, + assert_end_of_bytecode_segments, + indoc! {r#" + assert next(bytecode_segments, None) is None"# + } + ), + ( + IterCurrentSegmentInfo, + iter_current_segment_info, + indoc! {r#" + current_segment_info = next(bytecode_segments) + + is_used = current_segment_info.is_used + ids.is_segment_used = 1 if is_used else 0 + + is_used_leaf = is_used and isinstance(current_segment_info.inner_structure, BytecodeLeaf) + ids.is_used_leaf = 1 if is_used_leaf else 0 + + ids.segment_length = current_segment_info.segment_length + vm_enter_scope(new_scope_locals={ + "bytecode_segment_structure": current_segment_info.inner_structure, + })"# + } + ), + ( + SetApToSegmentHash, + set_ap_to_segment_hash, + indoc! {r#" + memory[ap] = to_felt_or_relocatable(bytecode_segment_structure.hash())"# + } ) );