diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/cairo_types/dict_access.rs b/cairo_vm_hints/src/cairo_types/dict_access.rs similarity index 100% rename from cairo_vm_hints/src/hints/lib/contract_bootloader/cairo_types/dict_access.rs rename to cairo_vm_hints/src/cairo_types/dict_access.rs diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/cairo_types/mod.rs b/cairo_vm_hints/src/cairo_types/mod.rs similarity index 100% rename from cairo_vm_hints/src/hints/lib/contract_bootloader/cairo_types/mod.rs rename to cairo_vm_hints/src/cairo_types/mod.rs diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/cairo_types/new_syscalls.rs b/cairo_vm_hints/src/cairo_types/new_syscalls.rs similarity index 100% rename from cairo_vm_hints/src/hints/lib/contract_bootloader/cairo_types/new_syscalls.rs rename to cairo_vm_hints/src/cairo_types/new_syscalls.rs diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/cairo_types/structs.rs b/cairo_vm_hints/src/cairo_types/structs.rs similarity index 100% rename from cairo_vm_hints/src/hints/lib/contract_bootloader/cairo_types/structs.rs rename to cairo_vm_hints/src/cairo_types/structs.rs diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/cairo_types/traits.rs b/cairo_vm_hints/src/cairo_types/traits.rs similarity index 100% rename from cairo_vm_hints/src/hints/lib/contract_bootloader/cairo_types/traits.rs rename to cairo_vm_hints/src/cairo_types/traits.rs diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/mod.rs b/cairo_vm_hints/src/hints/lib/contract_bootloader/mod.rs index 9969cdc9..306fbe37 100644 --- a/cairo_vm_hints/src/hints/lib/contract_bootloader/mod.rs +++ b/cairo_vm_hints/src/hints/lib/contract_bootloader/mod.rs @@ -10,11 +10,9 @@ use cairo_vm::{ Felt252, }; -pub mod cairo_types; pub mod dict_manager; pub mod program; pub mod scopes; -pub mod syscall; pub fn run_hint( vm: &mut VirtualMachine, diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/program.rs b/cairo_vm_hints/src/hints/lib/contract_bootloader/program.rs index 54824b47..ee14913b 100644 --- a/cairo_vm_hints/src/hints/lib/contract_bootloader/program.rs +++ b/cairo_vm_hints/src/hints/lib/contract_bootloader/program.rs @@ -1,4 +1,3 @@ -use super::{cairo_types::structs::CompiledClass, scopes::CONTRACT_CLASS}; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use cairo_vm::{ any_box, @@ -14,6 +13,10 @@ use cairo_vm::{ }; use std::collections::HashMap; +use crate::cairo_types::structs::CompiledClass; + +use super::scopes::CONTRACT_CLASS; + pub const LOAD_PROGRAM: &str = "vm_load_program(\n compiled_class.get_runnable_program(entrypoint_builtins=[]),\n ids.compiled_class.bytecode_ptr\n)"; pub fn load_program( diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/scopes.rs b/cairo_vm_hints/src/hints/lib/contract_bootloader/scopes.rs index 4b143a03..27fd98a7 100644 --- a/cairo_vm_hints/src/hints/lib/contract_bootloader/scopes.rs +++ b/cairo_vm_hints/src/hints/lib/contract_bootloader/scopes.rs @@ -1,5 +1,6 @@ use std::{any::Any, collections::HashMap}; +use crate::syscall_handler::SyscallHandlerWrapper; use cairo_vm::{ hint_processor::builtin_hint_processor::builtin_hint_processor_definition::HintProcessorData, types::exec_scope::ExecutionScopes, @@ -7,8 +8,6 @@ use cairo_vm::{ Felt252, }; -use super::syscall::syscall_handler::SyscallHandlerWrapper; - pub const DICT_MANAGER: &str = "dict_manager"; pub const SYSCALL_HANDLER: &str = "syscall_handler"; pub const CONTRACT_CLASS: &str = "syscall_handler"; diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/syscall/mod.rs b/cairo_vm_hints/src/hints/lib/contract_bootloader/syscall/mod.rs deleted file mode 100644 index 2cedb78c..00000000 --- a/cairo_vm_hints/src/hints/lib/contract_bootloader/syscall/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod syscall_handler; -pub mod utils; diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/syscall_handler.rs b/cairo_vm_hints/src/hints/lib/contract_bootloader/syscall_handler.rs new file mode 100644 index 00000000..e69de29b diff --git a/cairo_vm_hints/src/lib.rs b/cairo_vm_hints/src/lib.rs index a4217c13..f7bf3e9c 100644 --- a/cairo_vm_hints/src/lib.rs +++ b/cairo_vm_hints/src/lib.rs @@ -1,6 +1,8 @@ #![forbid(unsafe_code)] +pub mod cairo_types; pub mod hint_processor; pub mod hints; +pub mod syscall_handler; pub use hint_processor::CustomHintProcessor; diff --git a/cairo_vm_hints/src/main.rs b/cairo_vm_hints/src/main.rs index ea16f763..dec5b287 100644 --- a/cairo_vm_hints/src/main.rs +++ b/cairo_vm_hints/src/main.rs @@ -1,6 +1,8 @@ #![forbid(unsafe_code)] +pub mod cairo_types; pub mod hint_processor; pub mod hints; +pub mod syscall_handler; use bincode::enc::write::Writer; use cairo_vm::air_public_input::PublicInputError; diff --git a/cairo_vm_hints/src/syscall_handler/call_contract.rs b/cairo_vm_hints/src/syscall_handler/call_contract.rs new file mode 100644 index 00000000..7faee70a --- /dev/null +++ b/cairo_vm_hints/src/syscall_handler/call_contract.rs @@ -0,0 +1,29 @@ +use super::utils::{SyscallHandler, SyscallResult, WriteResponseResult}; +use crate::cairo_types::new_syscalls::{CallContractRequest, CallContractResponse}; +use cairo_vm::{types::relocatable::Relocatable, vm::vm_core::VirtualMachine}; + +pub struct CallContractHandler; + +impl SyscallHandler for CallContractHandler { + type Request = CallContractRequest; + type Response = CallContractResponse; + + fn read_request(_vm: &VirtualMachine, ptr: &mut Relocatable) -> SyscallResult { + todo!() + } + + async fn execute( + request: Self::Request, + vm: &mut VirtualMachine, + ) -> SyscallResult { + todo!() + } + + fn write_response( + response: Self::Response, + vm: &mut VirtualMachine, + ptr: &mut Relocatable, + ) -> WriteResponseResult { + todo!() + } +} diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/syscall/syscall_handler.rs b/cairo_vm_hints/src/syscall_handler/mod.rs similarity index 71% rename from cairo_vm_hints/src/hints/lib/contract_bootloader/syscall/syscall_handler.rs rename to cairo_vm_hints/src/syscall_handler/mod.rs index 731cad64..873de4d2 100644 --- a/cairo_vm_hints/src/hints/lib/contract_bootloader/syscall/syscall_handler.rs +++ b/cairo_vm_hints/src/syscall_handler/mod.rs @@ -1,16 +1,13 @@ -use super::utils::{ReadOnlySegment, SyscallResult, WriteResponseResult}; -use crate::hints::lib::contract_bootloader::syscall::utils::{ - felt_from_ptr, run_handler, SyscallSelector, -}; -use crate::hints::lib::contract_bootloader::{ - cairo_types::new_syscalls::{CallContractRequest, CallContractResponse}, - syscall::utils::SyscallHandler, -}; +pub mod call_contract; +pub mod utils; + use cairo_vm::{ types::relocatable::Relocatable, vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}, }; +use call_contract::CallContractHandler; use std::{rc::Rc, sync::RwLock}; +use utils::{felt_from_ptr, run_handler, ReadOnlySegment, SyscallSelector}; /// Represents read-only segments dynamically allocated during execution. #[derive(Debug, Default)] @@ -83,29 +80,3 @@ impl SyscallHandlerWrapper { Ok(()) } } - -struct CallContractHandler; - -impl SyscallHandler for CallContractHandler { - type Request = CallContractRequest; - type Response = CallContractResponse; - - fn read_request(_vm: &VirtualMachine, ptr: &mut Relocatable) -> SyscallResult { - todo!() - } - - async fn execute( - request: Self::Request, - vm: &mut VirtualMachine, - ) -> SyscallResult { - todo!() - } - - fn write_response( - response: Self::Response, - vm: &mut VirtualMachine, - ptr: &mut Relocatable, - ) -> WriteResponseResult { - todo!() - } -} diff --git a/cairo_vm_hints/src/hints/lib/contract_bootloader/syscall/utils.rs b/cairo_vm_hints/src/syscall_handler/utils.rs similarity index 100% rename from cairo_vm_hints/src/hints/lib/contract_bootloader/syscall/utils.rs rename to cairo_vm_hints/src/syscall_handler/utils.rs