-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add VM hooks as rust conditional feature #761
Conversation
28e7225
to
b398a15
Compare
This looks nice. We will check it tomorrow! |
Clearly something we will use for https://github.com/FuzzingLabs/cairo-fuzzer ;) |
I love it. This will also be useful to migrate the debugging/tracing functionality to Rust. Can't wait to see the final version :) |
BTW, the description says this is to spark conversation, so it would be nice to convert it to draft and add something like |
88e2890
to
2417b96
Compare
2417b96
to
683dfae
Compare
/// Prevent the execution of the next instruction | ||
/// | ||
/// This hint doesn't belong to the Cairo common library | ||
/// It's only added for testing proposes |
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.
/// It's only added for testing proposes | |
/// It's only added for testing purposes |
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.
done
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.
Overall this seems really good. There are some minor notes tho. I'm also unsure why the run_until_*
functions' interfaces need to change. Can't the field in VirtualMachine
be used directly inside those?
hint_data_dictionary: &HashMap<usize, Vec<Box<dyn Any>>>, | ||
constants: &HashMap<String, Felt>, | ||
) -> Result<(), VirtualMachineError> { | ||
if let Some(hook_func) = self.hooks.clone().pre_step_instruction { |
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.
Same.
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.
same
683dfae
to
6f3e840
Compare
Yeah totally it was some flags from a previous version of the code that I forgot to remove! |
6f3e840
to
637fbe3
Compare
doc: improve doc support for optional features
637fbe3
to
0d00eb9
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.
Excellent work!
Thanks @Oppen, can you find us a second reviewer so we can merge ;) |
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.
Hey @tdelabro! Amazing work, just some small typos suggestions
@@ -165,8 +165,9 @@ compare_trace_proof: $(CAIRO_RS_TRACE_PROOF) $(CAIRO_TRACE_PROOF) | |||
compare_memory_proof: $(CAIRO_RS_MEM_PROOF) $(CAIRO_MEM_PROOF) | |||
cd tests; ./compare_vm_state.sh memory proof_mode | |||
|
|||
# Run with nightly enable the `doc_cfg` feature wich let us provide clear explaination about which parts of the code are behind a feature flag |
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.
# Run with nightly enable the `doc_cfg` feature wich let us provide clear explaination about which parts of the code are behind a feature flag | |
# Run with nightly enable the `doc_cfg` feature which let us provide clear explanation about which parts of the code are behind a feature flag |
Introduce VM hooks
Description
Cairo-rs based testing tools such as cairo-foundry or those built by FuzzingLabs, need access to the state of the VM at specific points during the execution.
This PR adds the possibility for users of the cairo-rs lib to execute their custom additional code during the program execution.
I used the Rust "feature" mechanism in order to guarantee that this ability is only available when the lib user needs it, and is not compiled when it's not required.
In this PR I created tree hooks:
More hooks could easily be added in the future, as new needs arise.
This PR does not contain any tests, nor documentation, as its immediate goal is not to be merged but to spark a discussion with the LambdaClass team and validate that: