Skip to content

Commit fb367ac

Browse files
fix(starknet_os): fix macro docstring
1 parent 603d031 commit fb367ac

File tree

1 file changed

+32
-10
lines changed
  • crates/starknet_os/src/hints/hint_implementation

1 file changed

+32
-10
lines changed

crates/starknet_os/src/hints/hint_implementation/syscalls.rs

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
use blockifier::execution::deprecated_syscalls::deprecated_syscall_executor::execute_next_deprecated_syscall;
22
use blockifier::execution::deprecated_syscalls::hint_processor::DeprecatedSyscallExecutionError;
33
use blockifier::execution::deprecated_syscalls::DeprecatedSyscallSelector;
4-
use blockifier::execution::execution_utils::felt_from_ptr;
54
use blockifier::state::state_api::StateReader;
65
use cairo_vm::hint_processor::builtin_hint_processor::hint_utils::get_ptr_from_var_name;
76
use paste::paste;
87

9-
use crate::hints::error::OsHintError::DeprecatedSyscallExecution;
108
use crate::hints::error::OsHintResult;
119
use crate::hints::types::HintArgs;
1210
use crate::hints::vars::{Ids, Scope};
@@ -22,11 +20,37 @@ use crate::syscall_handler_utils::SyscallHandlerType;
2220
/// Expands to:
2321
///
2422
/// pub(crate) fn get_block_number<S: StateReader>(
25-
/// HintArgs { hint_processor, vm, ids_data, ap_tracking, .. }: HintArgs<'_, '_, S>,
23+
/// HintArgs { hint_processor, vm, ids_data, ap_tracking, exec_scopes, .. }: HintArgs<'_, '_, S>,
2624
/// ) -> OsHintResult
2725
/// {
26+
/// assert_eq!(
27+
/// exec_scopes.get(Scope::SyscallHandlerType.into())?,
28+
/// SyscallHandlerType::DeprecatedSyscallHandler
29+
/// );
2830
/// let syscall_hint_processor = &mut hint_processor.deprecated_syscall_hint_processor;
29-
/// Ok(execute_next_deprecated_syscall(syscall_hint_processor, vm, ids_data, ap_tracking)?)
31+
/// let syscall_ptr = get_ptr_from_var_name(
32+
/// Ids::SyscallPtr.into(), vm, ids_data, ap_tracking)?;
33+
/// let syscall_selector = DeprecatedSyscallSelector::try_from(
34+
/// vm.get_integer(syscall_ptr)?.into_owned()
35+
/// )?;
36+
/// let expected_selector = paste! { DeprecatedSyscallSelector::[$name:camel] };
37+
/// if syscall_selector != expected_selector {
38+
/// return Err(
39+
/// DeprecatedSyscallExecutionError::BadSyscallSelector {
40+
/// expected_selector,
41+
/// actual_selector: syscall_selector,
42+
/// }.into()
43+
/// );
44+
/// }
45+
/// syscall_hint_processor.set_syscall_ptr(syscall_ptr);
46+
/// Ok(
47+
/// execute_next_deprecated_syscall(
48+
/// syscall_hint_processor,
49+
/// vm,
50+
/// ids_data,
51+
/// ap_tracking
52+
/// )?
53+
/// )
3054
/// }
3155
macro_rules! create_syscall_func {
3256
($($name:ident),+) => {
@@ -55,12 +79,10 @@ macro_rules! create_syscall_func {
5579
let expected_selector = paste! { DeprecatedSyscallSelector::[<$name:camel>] };
5680
if syscall_selector != expected_selector {
5781
return Err(
58-
DeprecatedSyscallExecution(
59-
DeprecatedSyscallExecutionError::BadSyscallSelector {
60-
expected_selector,
61-
actual_selector: syscall_selector,
62-
}
63-
)
82+
DeprecatedSyscallExecutionError::BadSyscallSelector {
83+
expected_selector,
84+
actual_selector: syscall_selector,
85+
}.into()
6486
);
6587
}
6688
syscall_hint_processor.set_syscall_ptr(syscall_ptr);

0 commit comments

Comments
 (0)