Skip to content
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: add missing call to initialize in cairo_run_parsed_program #1330

Merged
merged 6 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#### Upcoming Changes

* feat: add `arbitrary` feature to enable arbitrary derive in `Program` and `CairoRunConfig`
* feat(fuzzing): add `arbitrary` feature to enable arbitrary derive in `Program` and `CairoRunConfig` [#1306](https://github.com/lambdaclass/cairo-vm/pull/1306) [#1330](https://github.com/lambdaclass/cairo-vm/pull/1330)

* perf: remove pointless iterator from rc limits tracking [#1316](https://github.com/lambdaclass/cairo-vm/pull/1316)

* feat: add `from_bytes_le` and `from_bytes_ne` methods [#1326](https://github.com/lambdaclass/cairo-vm/pull/1326)
* feat(felt): add `from_bytes_le` and `from_bytes_ne` methods to `Felt252` [#1326](https://github.com/lambdaclass/cairo-vm/pull/1326)

#### [0.8.2] - 2023-7-10

Expand All @@ -16,7 +16,6 @@

* feat: add dependency installation script `install.sh` [#1298](https://github.com/lambdaclass/cairo-vm/pull/1298)


* fix: specify resolver version 2 in the virtual workspace's manifest [#1311](https://github.com/lambdaclass/cairo-vm/pull/1311)

* feat: add `lambdaworks-felt` feature to `cairo-vm-cli` [#1308](https://github.com/lambdaclass/cairo-vm/pull/1308)
Expand Down
14 changes: 11 additions & 3 deletions vm/src/cairo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ pub fn cairo_run_parsed_program(
hint_executor: &mut dyn HintProcessor,
steps_limit: usize,
) -> Result<(CairoRunner, VirtualMachine), CairoRunError> {
use crate::vm::errors::vm_errors::VirtualMachineError;

let secure_run = cairo_run_config
.secure_run
.unwrap_or(!cairo_run_config.proof_mode);
Expand All @@ -98,9 +100,15 @@ pub fn cairo_run_parsed_program(

let mut vm = VirtualMachine::new(cairo_run_config.trace_enabled);

cairo_runner
.run_until_steps(steps_limit, &mut vm, hint_executor)
.map_err(|err| VmException::from_vm_error(&cairo_runner, &vm, err))?;
let _end = cairo_runner.initialize(&mut vm)?;

let res = match cairo_runner.run_until_steps(steps_limit, &mut vm, hint_executor) {
Err(VirtualMachineError::EndOfProgram(_remaining)) => Ok(()), // program ran OK but ended before steps limit
res => res,
};

res.map_err(|err| VmException::from_vm_error(&cairo_runner, &vm, err))?;

cairo_runner.end_run(false, false, &mut vm, hint_executor)?;

vm.verify_auto_deductions()?;
Expand Down
12 changes: 12 additions & 0 deletions vm/src/vm/runners/cairo_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,18 @@ mod tests {
);
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn run_empty() {
let program = program!();
let mut cairo_runner = cairo_runner!(&program);
let mut vm = vm!(true);
assert_matches!(
cairo_runner.initialize(&mut vm),
Err(RunnerError::MissingMain)
);
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
/*Program used:
Expand Down