|
| 1 | +use crate::execution::deprecated::syscalls::CheatableSyscallHandler; |
| 2 | +use crate::execution::entry_point::execute_call_entry_point; |
| 3 | +use blockifier::abi::constants; |
| 4 | +use blockifier::execution::deprecated_syscalls::DeprecatedSyscallResult; |
| 5 | +use blockifier::execution::entry_point::{CallEntryPoint, CallType}; |
| 6 | +use blockifier::execution::execution_utils::ReadOnlySegment; |
| 7 | +use cairo_vm::types::relocatable::MaybeRelocatable; |
| 8 | +use cairo_vm::vm::vm_core::VirtualMachine; |
| 9 | +use conversions::StarknetConversions; |
| 10 | +use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; |
| 11 | +use starknet_api::deprecated_contract_class::EntryPointType; |
| 12 | +use starknet_api::transaction::Calldata; |
| 13 | + |
| 14 | +// blockifier/src/execution/deprecated_syscalls/hint_processor.rs:393 (execute_inner_call) |
| 15 | +pub fn execute_inner_call( |
| 16 | + call: &mut CallEntryPoint, |
| 17 | + vm: &mut VirtualMachine, |
| 18 | + syscall_handler: &mut CheatableSyscallHandler<'_>, |
| 19 | +) -> DeprecatedSyscallResult<ReadOnlySegment> { |
| 20 | + // region: Modified blockifier code |
| 21 | + let call_info = execute_call_entry_point( |
| 22 | + call, |
| 23 | + syscall_handler.syscall_handler.state, |
| 24 | + syscall_handler.cheatnet_state, |
| 25 | + syscall_handler.syscall_handler.resources, |
| 26 | + syscall_handler.syscall_handler.context, |
| 27 | + )?; |
| 28 | + // endregion |
| 29 | + |
| 30 | + let retdata = &call_info.execution.retdata.0; |
| 31 | + let retdata: Vec<MaybeRelocatable> = retdata |
| 32 | + .iter() |
| 33 | + .map(|&x| MaybeRelocatable::from(x.to_felt252())) |
| 34 | + .collect(); |
| 35 | + let retdata_segment_start_ptr = syscall_handler |
| 36 | + .syscall_handler |
| 37 | + .read_only_segments |
| 38 | + .allocate(vm, &retdata)?; |
| 39 | + |
| 40 | + syscall_handler.syscall_handler.inner_calls.push(call_info); |
| 41 | + Ok(ReadOnlySegment { |
| 42 | + start_ptr: retdata_segment_start_ptr, |
| 43 | + length: retdata.len(), |
| 44 | + }) |
| 45 | +} |
| 46 | + |
| 47 | +// blockifier/src/execution/deprecated_syscalls/hint_processor.rs:409 (execute_library_call) |
| 48 | +pub fn execute_library_call( |
| 49 | + syscall_handler: &mut CheatableSyscallHandler<'_>, |
| 50 | + vm: &mut VirtualMachine, |
| 51 | + class_hash: ClassHash, |
| 52 | + code_address: Option<ContractAddress>, |
| 53 | + call_to_external: bool, |
| 54 | + entry_point_selector: EntryPointSelector, |
| 55 | + calldata: Calldata, |
| 56 | +) -> DeprecatedSyscallResult<ReadOnlySegment> { |
| 57 | + let entry_point_type = if call_to_external { |
| 58 | + EntryPointType::External |
| 59 | + } else { |
| 60 | + EntryPointType::L1Handler |
| 61 | + }; |
| 62 | + let mut entry_point = CallEntryPoint { |
| 63 | + class_hash: Some(class_hash), |
| 64 | + code_address, |
| 65 | + entry_point_type, |
| 66 | + entry_point_selector, |
| 67 | + calldata, |
| 68 | + // The call context remains the same in a library call. |
| 69 | + storage_address: syscall_handler.syscall_handler.storage_address, |
| 70 | + caller_address: syscall_handler.syscall_handler.caller_address, |
| 71 | + call_type: CallType::Delegate, |
| 72 | + initial_gas: constants::INITIAL_GAS_COST, |
| 73 | + }; |
| 74 | + |
| 75 | + execute_inner_call(&mut entry_point, vm, syscall_handler) |
| 76 | +} |
0 commit comments