-
Notifications
You must be signed in to change notification settings - Fork 48
WIP: feat(starknet_os): verify syscall_ptr #6327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Artifacts upload workflows: |
Benchmark movements: |
5786289
to
b114059
Compare
Benchmark movements: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 9 files at r1.
Reviewable status: 3 of 9 files reviewed, 3 unresolved discussions (waiting on @aner-starkware)
a discussion (no related file):
I'd like to avoid (a) adding a new crate dependency just for pascal-casing and (b) avoid adding an extra field to the syscall processor.
instead, how about using the From<Felt>
logic defined on the SyscallSelector?
see comments in your macro module on how I think this can work
crates/starknet_os/src/hints/hint_implementation/syscalls.rs
line 43 at r1 (raw file):
syscall_hint_processor.set_syscall_ptr( get_ptr_from_var_name(Ids::SyscallPtr.into(), vm, ids_data, ap_tracking)? );
here, you can just fetch the integer at the current syscall pointer and verify it's the correct selector, no?
or is the pointer not pointing to the correct value at this point in time?
(see below, I'm assuming you have a $selector
) macro ident available)
let syscall_ptr = get_ptr_from_var_name(Ids::SyscallPtr.into(), vm, ids_data, ap_tracking)?;
let selector = SyscallSelector::from(vm.get_integer(syscall_ptr)?)?;
if selector != SyscallSelector::$selector {
return Err(..);
}
syscall_hint_processor.set_syscall_ptr(syscall_ptr);
Code quote:
let syscall_hint_processor = &mut hint_processor.deprecated_syscall_hint_processor;
syscall_hint_processor.set_syscall_name(
stringify!($name).to_string().to_case(Case::Pascal)
);
syscall_hint_processor.set_syscall_ptr(
get_ptr_from_var_name(Ids::SyscallPtr.into(), vm, ids_data, ap_tracking)?
);
crates/starknet_os/src/hints/hint_implementation/syscalls.rs
line 59 at r1 (raw file):
create_syscall_func!( call_contract, delegate_call,
... etc.
If paste
has a pascal-case functionality you can use it, but if not, I wouldn't use an extra crate just to reduce the boilerplate here...
Suggestion:
create_syscall_func!(
(call_contract, CallContract),
(delegate_call, DelegateCall),
Previously, dorimedini-starkware wrote…
I don't understand the suggestion - you're not using the |
Previously, aner-starkware wrote…
Ahhh, OK, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 3 of 9 files reviewed, 3 unresolved discussions (waiting on @aner-starkware)
crates/starknet_os/src/hints/hint_implementation/syscalls.rs
line 43 at r1 (raw file):
Previously, aner-starkware wrote…
Ahhh, OK,
$selector
you meant$name
, right?
in the verification area, I'm not. see below, instead of just the function name I'm passing the selector name (function name in pascal case).
alternatively, you can pass CallContract
instead of call_contract
, and then you can get the function name by using paste
:
paste::paste! {
fn [< $selector:snake >]( .. ) { .. }
}
Previously, dorimedini-starkware wrote…
OK, but in any case this solution checks it here, and not in |
3d7683f
to
d86158c
Compare
Previously, aner-starkware wrote…
Additionally, the |
d86158c
to
bb5b22e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 9 files reviewed, 3 unresolved discussions (waiting on @aner-starkware, @ilyalesokhin-starkware, and @Yoni-Starkware)
crates/starknet_os/src/hints/hint_implementation/syscalls.rs
line 43 at r1 (raw file):
OK, but in any case this solution checks it here, and not in
verify_syscall_ptr
- is this important?
this is a good question; can you check that it is equivalent? if the pointer doesn't change between this call and the verify
call I think it's fine, but @Yoni-Starkware 's or @ilyalesokhin-starkware 's input may help
should I create a new
Error
type?
I am in favor, yes
No description provided.