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
7 changes: 2 additions & 5 deletions openvm/src/empirical_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ pub fn detect_empirical_constraints(
fn collect_trace(program: &CompiledProgram, inputs: StdIn) -> (Trace, DebugInfo) {
let mut trace = Trace::default();
let mut debug_info = DebugInfo::default();
let mut seg_idx = 0;

do_with_trace(program, inputs, |vm, _pk, ctx| {
do_with_trace(program, inputs, |seg_idx, vm, _pk, ctx| {
let global_airs = vm
.config()
.create_airs()
Expand Down Expand Up @@ -130,7 +129,7 @@ fn collect_trace(program: &CompiledProgram, inputs: StdIn) -> (Trace, DebugInfo)
let row = Row {
cells: row,
pc: pc_value,
timestamp: (seg_idx, ts_value),
timestamp: (seg_idx as u32, ts_value),
};
trace.rows.push(row);

Expand All @@ -149,8 +148,6 @@ fn collect_trace(program: &CompiledProgram, inputs: StdIn) -> (Trace, DebugInfo)
}
}
}

seg_idx += 1;
})
.unwrap();
(trace, debug_info)
Expand Down
2 changes: 1 addition & 1 deletion openvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ pub fn prove(
segment_height: Option<usize>, // uses the default height if None
) -> Result<(), Box<dyn std::error::Error>> {
if mock {
do_with_trace(program, inputs, |vm, pk, ctx| {
do_with_trace(program, inputs, |_segment_idx, vm, pk, ctx| {
debug_proving_ctx(vm, pk, &ctx);
})?;
} else {
Expand Down
5 changes: 3 additions & 2 deletions openvm/src/trace_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ use crate::SpecializedConfigCpuBuilder as SpecializedConfigBuilder;
use openvm_stark_sdk::config::baby_bear_poseidon2::BabyBearPoseidon2Engine;

/// Given a program and input, generates the trace segment by segment and calls the provided
/// callback with the VM, proving key, and proving context (containing the trace) for each segment.
/// callback with the segment id, VM, proving key, and proving context (containing the trace) for each segment.
pub fn do_with_trace(
program: &CompiledProgram,
inputs: StdIn,
mut callback: impl FnMut(
usize,
&VirtualMachine<BabyBearPoseidon2Engine, SpecializedConfigBuilder>,
&MultiStarkProvingKey<BabyBearSC>,
ProvingContext<<BabyBearPoseidon2Engine as StarkEngine>::PB>,
Expand Down Expand Up @@ -85,7 +86,7 @@ pub fn do_with_trace(

let ctx = vm.generate_proving_ctx(system_records, record_arenas)?;

callback(&vm, &pk, ctx);
callback(seg_idx, &vm, &pk, ctx);
}
Ok(())
}
Loading