Skip to content

Commit b92d256

Browse files
Enforce_disable_trace_padding_used_only_in_proof_mode
1 parent 3de653d commit b92d256

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#### Upcoming Changes
44

5+
* fix: Enforce `disable_trace_padding` used only in `proof_mode` [#1984](https://github.com/lambdaclass/cairo-vm/pull/1984)
6+
57
#### [2.0.0] - 2025-02-26
68

79
* fix: Check overflow in cairo pie address calculation [#1945](https://github.com/lambdaclass/cairo-vm/pull/1945)

vm/src/vm/errors/runner_errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ pub enum RunnerError {
136136
MissingDynamicLayoutParams,
137137
#[error("dynamic layout {0} ratio should be 0 when disabled")]
138138
BadDynamicLayoutBuiltinRatio(BuiltinName),
139+
#[error("Initialization failure: Cannot run with trace padding disabled without proof mode")]
140+
DisableTracePaddingWithoutProofMode,
139141
}
140142

141143
#[cfg(test)]

vm/src/vm/runners/cairo_runner.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ impl CairoRunner {
229229
trace_enabled: bool,
230230
disable_trace_padding: bool,
231231
) -> Result<CairoRunner, RunnerError> {
232+
// `disable_trace_padding` can only be used in `proof_mode`, so we enforce this here to
233+
// avoid unintended behavior.
234+
if disable_trace_padding && !proof_mode {
235+
return Err(RunnerError::DisableTracePaddingWithoutProofMode);
236+
}
232237
if proof_mode {
233238
Self::new_v2(
234239
program,
@@ -5399,4 +5404,15 @@ mod tests {
53995404
})]
54005405
);
54015406
}
5407+
5408+
#[test]
5409+
fn test_disable_trace_padding_without_proof_mode() {
5410+
let program = program!();
5411+
// Attempt to create a runner in non-proof mode with trace padding disabled.
5412+
let result = CairoRunner::new(&program, LayoutName::plain, None, false, true, true);
5413+
match result {
5414+
Err(RunnerError::DisableTracePaddingWithoutProofMode) => { /* test passed */ }
5415+
_ => panic!("Expected DisableTracePaddingWithoutProofMode error"),
5416+
}
5417+
}
54025418
}

0 commit comments

Comments
 (0)