-
Notifications
You must be signed in to change notification settings - Fork 164
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 air_public_input
flag to cairo1-run
#1539
Conversation
air_public_input
flag to cairo1-runair_public_input
flag to cairo1-run
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1539 +/- ##
=======================================
Coverage 97.21% 97.22%
=======================================
Files 91 91
Lines 36990 37048 +58
=======================================
+ Hits 35961 36020 +59
+ Misses 1029 1028 -1 ☔ View full report in Codecov by Sentry. |
Benchmark Results for unmodified programs 🚀
|
cairo1-run/src/main.rs
Outdated
for builtin in vm.builtin_runners.iter_mut() { | ||
builtin.final_stack( | ||
&vm.segments, | ||
builtin_name_to_stack_pointer | ||
.get(builtin.name()) | ||
.cloned() | ||
.unwrap_or_default(), | ||
)?; | ||
} |
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.
Can't finalize_segments
do this so we avoid exposing VirtualMachine::builtin_runners
and VirtualMachine::segments
?
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.
In cairo 0, the builtin's stop pointers can be found contiguously at the end of the execution segment. Therefore we can take the current value of ap as stack_pointer and then iterate over the builtin runners calling final_stack
(which will fetch the builtin's stop_ptr from memory[stack_ptr - 1]) on each of them, while advancing the stack_ptr by one each iteration to set all builtin's stop_ptr to the correct value.
In cairo 1 this doesn't happen, the builtin's stop_ptr are mixed up with the other return values so we can't iterate contiguously over a memory range to fetch the stop pointers. The logic above this code calculates an individual stack_ptr for each builtin, therefore we need to call each builtin's final_stack
method independently, without being able to rely on read_return_values
or get_builtins_final_stack
like we do with cairo 0 execution.
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.
Maybe a new method in the runner can do it?
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 is kind of an specific behaviour to have as part of the public api, but I think we could add it to the vm as a docs_hidden
method
let end = runner.initialize(&mut vm)?; | ||
|
||
additional_initialization(&mut vm, data_len)?; | ||
|
||
// Run it until the end/ infinite loop in proof_mode | ||
runner.run_until_pc(end, &mut vm, &mut hint_processor)?; | ||
|
||
if args.proof_mode { |
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.
why did you remove this?
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.
The previous code called runner.run_until_next_power_of_2(&mut vm, &mut hint_processor)
if proof_mode was activated. This same function is called in the end_run
method if proof_mode is activated
Air Public Input can now be obtained from cairo 1 proof_mode runs