Skip to content

Commit

Permalink
Enforce_disable_trace_padding_used_only_in_proof_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
YairVaknin-starkware committed Mar 5, 2025
1 parent 3de653d commit b96ae47
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions vm/src/vm/errors/runner_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ pub enum RunnerError {
MissingDynamicLayoutParams,
#[error("dynamic layout {0} ratio should be 0 when disabled")]
BadDynamicLayoutBuiltinRatio(BuiltinName),
#[error("Initialization failure: Cannot run with trace padding disabled without proof mode")]
DisableTracePaddingWithoutProofMode,
}

#[cfg(test)]
Expand Down
16 changes: 16 additions & 0 deletions vm/src/vm/runners/cairo_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ impl CairoRunner {
trace_enabled: bool,
disable_trace_padding: bool,
) -> Result<CairoRunner, RunnerError> {
// `disable_trace_padding` can only be used in `proof_mode`, so we enforce this here to
// avoid unintended behavior.
if disable_trace_padding && !proof_mode {
return Err(RunnerError::DisableTracePaddingWithoutProofMode);
}
if proof_mode {
Self::new_v2(
program,
Expand Down Expand Up @@ -5399,4 +5404,15 @@ mod tests {
})]
);
}

#[test]
fn test_disable_trace_padding_without_proof_mode() {
let program = program!();
// Attempt to create a runner in non-proof mode with trace padding disabled.
let result = CairoRunner::new(&program, LayoutName::plain, None, false, true, true);
match result {
Err(RunnerError::DisableTracePaddingWithoutProofMode) => { /* test passed */ }
_ => panic!("Expected DisableTracePaddingWithoutProofMode error"),
}
}
}

0 comments on commit b96ae47

Please sign in to comment.