diff --git a/CHANGELOG.md b/CHANGELOG.md index 13ce78d179..e7fc218aaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * Checks that only `Array` 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) diff --git a/vm/src/cairo_run.rs b/vm/src/cairo_run.rs index d48f7c5552..b940295354 100644 --- a/vm/src/cairo_run.rs +++ b/vm/src/cairo_run.rs @@ -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}; @@ -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 { let secure_run = cairo_run_config .secure_run @@ -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 @@ -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 { + 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,