-
Notifications
You must be signed in to change notification settings - Fork 160
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
Implement run resources funcs #1175
Conversation
@@ -516,20 +517,26 @@ impl CairoRunner { | |||
pub fn run_until_pc( | |||
&mut self, | |||
address: Relocatable, | |||
run_resources: &mut Option<RunResources>, |
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 this could be Option<&mut RunResources>
instead?
As to avoid having to call it with &mut None
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.
i was unsure which one would be a better option but the suggestion is fair enough, besides it matches the behavior it has in the function.
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.
i was trying to apply the suggestion but it doesn't like that i mutated the Option value without setting &mut Option in the parameters, maybe there is a work around.
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 will be ugly but I think mut Option<&mut RunResources>
is likely to work.
Benchmark Results for unmodified programs 🚀
|
Codecov Report
@@ Coverage Diff @@
## main #1175 +/- ##
==========================================
- Coverage 97.60% 97.60% -0.01%
==========================================
Files 89 89
Lines 36066 36198 +132
==========================================
+ Hits 35202 35330 +128
- Misses 864 868 +4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
LGTM but see comment.
src/vm/runners/cairo_runner.rs
Outdated
while vm.run_context.pc != address | ||
&& !if let Some(r) = run_resources.as_ref() { | ||
r.consumed() | ||
} else { | ||
false | ||
} | ||
{ |
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.
This looks confusing. Can you find a way to make it more straightforward?
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.
i think i can pull out a solution by calling a function that engulfs that behavior.
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.
I think that this PR #1181 will add this feature without making changes to the CairoRunner.run_from_entrypoint
API
For now, let's leave this PR on stand by
* Add RunResources structure * Modify changelog * change data type of n_steps from u64 to usize * Implement run resources functions * Fix tests * set comment about calculation in cairo_run * Change CHangelog and remove option from RunResources * Fix clippy * Add clone trait to run resources * Add debug and default traits to RunResources * Fix error in while loop inside run_until_pc * Add helper function for clarity in run_until_pc loop * Add test for cairo 0 contracts * Add tests with Cairo 1 contracts * Move RunResources struct to vm::runners::cairo_runner::RunResources * Update CHANGELOG.md * Fix wasm and no-std compilation --------- Co-authored-by: Pedro Fontana <fontana.pedro93@gmail.com>
TITLE
Description
Description of the pull request changes and motivation.
Checklist