-
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
Fix error handling in initialize_state
#1657
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1657 +/- ##
==========================================
- Coverage 96.70% 96.70% -0.01%
==========================================
Files 95 95
Lines 38154 38151 -3
==========================================
- Hits 36897 36894 -3
Misses 1257 1257 ☔ View full report in Codecov by Sentry. |
Benchmark Results for unmodified programs 🚀
|
vm/src/vm/runners/cairo_runner.rs
Outdated
} | ||
if let Some(exec_base) = self.execution_base { | ||
vm.segments | ||
.load_data(exec_base, &stack) | ||
.map_err(RunnerError::MemoryInitializationError)?; | ||
} else { | ||
return Err(RunnerError::NoProgBase); | ||
return Err(RunnerError::NoExecBase); |
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.
Given both return errors if None
, another implementation could be:
let prog_base = self.program_base.ok_or(RunnerError::NoProgBase)?;
let exec_base = self.execution_base.ok_or(RunnerError::NoExecBase)?;
// And then the logic without extra indentation or error handling.
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.
That said, do those always error out? Maybe it could make sense to make them not optional and fail earlier if they're missing?
…daclass/cairo-vm into fix-error-handling-initialize-state
initialize_state
now returns the correct errors when eitherprogram_base
orexecution_base
areNone
Also closes #1638