1
1
use blockifier:: execution:: deprecated_syscalls:: deprecated_syscall_executor:: execute_next_deprecated_syscall;
2
+ use blockifier:: execution:: deprecated_syscalls:: DeprecatedSyscallSelector ;
3
+ use blockifier:: execution:: execution_utils:: felt_from_ptr;
2
4
use blockifier:: state:: state_api:: StateReader ;
3
5
use cairo_vm:: hint_processor:: builtin_hint_processor:: hint_utils:: get_ptr_from_var_name;
6
+ use paste:: paste;
4
7
5
8
use crate :: hints:: error:: OsHintResult ;
6
9
use crate :: hints:: types:: HintArgs ;
@@ -27,17 +30,32 @@ macro_rules! create_syscall_func {
27
30
( $( $name: ident) ,+) => {
28
31
$(
29
32
pub ( crate ) fn $name<S : StateReader >(
30
- HintArgs { hint_processor, vm, ids_data, ap_tracking, exec_scopes, .. } : HintArgs <' _, ' _, S >
33
+ HintArgs {
34
+ hint_processor,
35
+ vm,
36
+ ids_data,
37
+ ap_tracking,
38
+ exec_scopes,
39
+ ..
40
+ } : HintArgs <' _, ' _, S >
31
41
) -> OsHintResult {
32
42
assert_eq!(
33
43
exec_scopes. get:: <SyscallHandlerType >( Scope :: SyscallHandlerType . into( ) ) ?,
34
44
SyscallHandlerType :: DeprecatedSyscallHandler
35
45
) ;
36
46
let syscall_hint_processor = & mut hint_processor. deprecated_syscall_hint_processor;
37
- // TODO(Aner): need to verify that the correct syscall is being called (i.e.,
38
- // syscall_ptr matches the fn name). E.g., set syscall_ptr from fn name.
47
+ let mut syscall_ptr = get_ptr_from_var_name(
48
+ Ids :: SyscallPtr . into( ) , vm, ids_data, ap_tracking
49
+ ) ?;
50
+ let syscall_selector = DeprecatedSyscallSelector :: try_from(
51
+ felt_from_ptr( vm, & mut syscall_ptr) ?
52
+ ) . unwrap( ) ;
53
+ // TODO(Aner): should return an error instead of panic.
54
+ paste!{
55
+ assert_eq!( syscall_selector, DeprecatedSyscallSelector :: [ <$name: camel>] ) ;
56
+ }
39
57
syscall_hint_processor. set_syscall_ptr(
40
- get_ptr_from_var_name ( Ids :: SyscallPtr . into ( ) , vm , ids_data , ap_tracking ) ?
58
+ syscall_ptr ,
41
59
) ;
42
60
Ok (
43
61
execute_next_deprecated_syscall(
0 commit comments