Skip to content
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 @@ -8,6 +8,8 @@
* Checks that only `Array<Felt252>` can be received by the program main function when running with with either `--proof_mode` or `--append_return_values`.
* Copies the input value to the output segment right after the output in the format `[array_len, arr[0], arr[1],.., arr[n]]`.

* feat: specify initial value for `exec_scopes` in `cairo_run_program` [1772](https://github.com/lambdaclass/cairo-vm/pull/1772)

* fix: make MemorySegmentManager.finalize() public [#1771](https://github.com/lambdaclass/cairo-vm/pull/1771)

* feat: load Cairo PIE from bytes [#1773](https://github.com/lambdaclass/cairo-vm/pull/1773)
Expand Down
20 changes: 19 additions & 1 deletion vm/src/cairo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use bincode::enc::write::Writer;

use thiserror_no_std::Error;

use crate::types::exec_scope::ExecutionScopes;
#[cfg(feature = "test_utils")]
use arbitrary::{self, Arbitrary};

Expand Down Expand Up @@ -46,10 +47,12 @@ impl<'a> Default for CairoRunConfig<'a> {
}
}

pub fn cairo_run_program(
/// Runs a program with a customized execution scope.
pub fn cairo_run_program_with_initial_scope(
program: &Program,
cairo_run_config: &CairoRunConfig,
hint_processor: &mut dyn HintProcessor,
exec_scopes: ExecutionScopes,
) -> Result<CairoRunner, CairoRunError> {
let secure_run = cairo_run_config
.secure_run
Expand All @@ -66,6 +69,8 @@ pub fn cairo_run_program(
cairo_run_config.trace_enabled,
)?;

cairo_runner.exec_scopes = exec_scopes;

let end = cairo_runner.initialize(allow_missing_builtins)?;
// check step calculation

Expand Down Expand Up @@ -95,6 +100,19 @@ pub fn cairo_run_program(
Ok(cairo_runner)
}

pub fn cairo_run_program(
program: &Program,
cairo_run_config: &CairoRunConfig,
hint_processor: &mut dyn HintProcessor,
) -> Result<CairoRunner, CairoRunError> {
cairo_run_program_with_initial_scope(
program,
cairo_run_config,
hint_processor,
ExecutionScopes::new(),
)
}

pub fn cairo_run(
program_content: &[u8],
cairo_run_config: &CairoRunConfig,
Expand Down