Skip to content
Open
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 @@ -36,6 +36,8 @@ Both branches support Stwo prover opcodes (Blake2s, QM31) since v2.0.0.

* refactor: Make HintReference dereference count explicit in `get_maybe_relocatable_from_reference` [#2296](https://github.com/lambdaclass/cairo-vm/pull/2296)

* chore: Add logs to `cairo_run_program_with_initial_scope` [#2319](https://github.com/lambdaclass/cairo-vm/pull/2319)

#### [3.1.0] - 2026-01-19

**Summary**: Introduces stateful VM hooks via the `StepHooks` trait, enabling debuggers and instrumentation tools.
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ starknet-crypto = { version = "0.8.0", default-features = false, features = [
"alloc",
] }
sha3 = { version = "0.10.8", default-features = false }
tracing = { version = "0.1.40", default-features = false }
indoc = { version = "2.0.5", default-features = false }
lazy_static = { version = "1.4.0", default-features = false, features = [
"spin_no_std",
Expand Down
1 change: 1 addition & 0 deletions vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ serde = { workspace = true }
serde_json = { workspace = true }
starknet-crypto = { workspace = true }
sha3 = { workspace = true }
tracing = { workspace = true }
indoc = { workspace = true }
lazy_static = { workspace = true }
nom = { workspace = true }
Expand Down
12 changes: 12 additions & 0 deletions vm/src/cairo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::types::exec_scope::ExecutionScopes;
#[cfg(feature = "test_utils")]
use arbitrary::{self, Arbitrary};
use core::fmt;
use tracing::{info, span, Level};

#[cfg_attr(feature = "test_utils", derive(Arbitrary))]
pub struct CairoRunConfig<'a> {
Expand Down Expand Up @@ -74,6 +75,7 @@ pub fn cairo_run_program_with_initial_scope(
hint_processor: &mut dyn HintProcessor,
exec_scopes: ExecutionScopes,
) -> Result<CairoRunner, CairoRunError> {
let _span = span!(Level::INFO, "cairo run").entered();
let secure_run = cairo_run_config
.secure_run
.unwrap_or(!cairo_run_config.proof_mode);
Expand All @@ -93,9 +95,11 @@ pub fn cairo_run_program_with_initial_scope(

cairo_runner.exec_scopes = exec_scopes;

info!(layout = ?cairo_run_config.layout, proof_mode = ?cairo_run_config.proof_mode, trace_enabled = ?cairo_run_config.trace_enabled, disable_trace_padding = ?cairo_run_config.disable_trace_padding, allow_missing_builtins = ?allow_missing_builtins, "Initializing Cairo runner.");
let end = cairo_runner.initialize(allow_missing_builtins)?;
// check step calculation

info!("Running until PC.");
cairo_runner
.run_until_pc(end, hint_processor)
.map_err(|err| VmException::from_vm_error(&cairo_runner, err))?;
Expand All @@ -105,20 +109,28 @@ pub fn cairo_run_program_with_initial_scope(
// rather than the one after it.
cairo_runner.run_for_steps(1, hint_processor)?;
}

info!(disable_trace_padding = ?cairo_run_config.disable_trace_padding, fill_holes = ?cairo_run_config.fill_holes, "Ending run.");
cairo_runner.end_run(
cairo_run_config.disable_trace_padding,
false,
hint_processor,
cairo_run_config.fill_holes,
)?;

info!("Reading return values.");
cairo_runner.read_return_values(allow_missing_builtins)?;
if cairo_run_config.proof_mode {
info!("In proof mode, finalizing segments.");
cairo_runner.finalize_segments()?;
}

if secure_run {
info!("In secure run, verifying secure runner.");
verify_secure_runner(&cairo_runner, true, None)?;
}

info!(relocate_mem = ?cairo_run_config.relocate_mem, relocate_trace = ?cairo_run_config.relocate_trace, "Relocating.");
cairo_runner.relocate(
cairo_run_config.relocate_mem,
cairo_run_config.relocate_trace,
Expand Down
9 changes: 9 additions & 0 deletions vm/src/vm/runners/cairo_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use super::{
cairo_pie::{self, CairoPie, CairoPieMetadata, CairoPieVersion},
};
use crate::types::instance_definitions::mod_instance_def::ModInstanceDef;
use tracing::info;

pub const ORDERED_BUILTIN_LIST: &[BuiltinName] = &[
BuiltinName::output,
Expand Down Expand Up @@ -275,14 +276,19 @@ impl CairoRunner {
}

pub fn initialize(&mut self, allow_missing_builtins: bool) -> Result<Relocatable, RunnerError> {
info!("Initializing builtins.");
self.initialize_builtins(allow_missing_builtins)?;
info!("Initializing segments.");
self.initialize_segments(None);
info!("Initializing main entrypoint.");
let end = self.initialize_main_entrypoint()?;
info!("Initializing zero segments.");
for builtin_runner in self.vm.builtin_runners.iter_mut() {
if let BuiltinRunner::Mod(runner) = builtin_runner {
runner.initialize_zero_segment(&mut self.vm.segments);
}
}
info!("Initializing VM.");
self.initialize_vm()?;
Ok(end)
}
Expand Down Expand Up @@ -903,15 +909,18 @@ impl CairoRunner {
return Err(RunnerError::EndRunCalledTwice.into());
}

info!("Relocating memory.");
self.vm.segments.memory.relocate_memory()?;
self.vm.end_run(&self.exec_scopes, fill_holes)?;

if disable_finalize_all {
return Ok(());
}

info!("Computing effective sizes of segments.");
self.vm.segments.compute_effective_sizes();
if self.is_proof_mode() && !disable_trace_padding {
info!("in proof mode and enabling trace padding, running until next power of 2.");
self.run_until_next_power_of_2(hint_processor)?;
loop {
match self.check_used_cells() {
Expand Down
Loading