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

feat: add cairo_run_program function that takes a Program as an arg #1496

Merged
merged 2 commits into from
Nov 27, 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

* feat: add debugging capabilities behind `print` feature flag. [#1476](https://github.com/lambdaclass/cairo-vm/pull/1476)

* feat: add `cairo_run_program` function that takes a `Program` as an arg. [#1496](https://github.com/lambdaclass/cairo-vm/pull/1496)

#### [0.9.1] - 2023-11-16

* chore: bump `cairo-lang-` dependencies to 2.3.1 [#1482](https://github.com/lambdaclass/cairo-vm/pull/1482), [#1483](https://github.com/lambdaclass/cairo-vm/pull/1483)
Expand Down
18 changes: 13 additions & 5 deletions vm/src/cairo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,17 @@ impl<'a> Default for CairoRunConfig<'a> {
}
}

pub fn cairo_run(
program_content: &[u8],
pub fn cairo_run_program(
program: &Program,
cairo_run_config: &CairoRunConfig,
hint_executor: &mut dyn HintProcessor,
) -> Result<(CairoRunner, VirtualMachine), CairoRunError> {
let program = Program::from_bytes(program_content, Some(cairo_run_config.entrypoint))?;

let secure_run = cairo_run_config
.secure_run
.unwrap_or(!cairo_run_config.proof_mode);

let mut cairo_runner = CairoRunner::new(
&program,
program,
cairo_run_config.layout,
cairo_run_config.proof_mode,
)?;
Expand Down Expand Up @@ -104,6 +102,16 @@ pub fn cairo_run(
Ok((cairo_runner, vm))
}

pub fn cairo_run(
program_content: &[u8],
cairo_run_config: &CairoRunConfig,
hint_executor: &mut dyn HintProcessor,
) -> Result<(CairoRunner, VirtualMachine), CairoRunError> {
let program = Program::from_bytes(program_content, Some(cairo_run_config.entrypoint))?;

cairo_run_program(&program, cairo_run_config, hint_executor)
}

#[cfg(feature = "arbitrary")]
pub fn cairo_run_fuzzed_program(
program: Program,
Expand Down
Loading