Skip to content

Commit 63fa1b7

Browse files
authored
Remove dependancy in cairo pie when collectiog builtin segments info (#2022)
1 parent 7c4ecdf commit 63fa1b7

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Cairo-VM Changelog
22

33
#### Upcoming Changes
4+
* fix: Updated the logic for collecting builtin segment data for prover input info, removing dependency on the existence of stop pointers. [#2022](https://github.com/lambdaclass/cairo-vm/pull/2022)
45

56
* fix: Keep None values in memory segments for the prover input info [#2021](https://github.com/lambdaclass/cairo-vm/pull/2021)
67

vm/src/vm/runners/cairo_runner.rs

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,10 +1516,21 @@ impl CairoRunner {
15161516
})
15171517
.collect();
15181518

1519-
let builtins_segments = self
1520-
.get_builtin_segment_info_for_pie()?
1521-
.into_iter()
1522-
.map(|(name, info)| (info.index as usize, name))
1519+
let builtins_segments: HashMap<usize, BuiltinName> = self
1520+
.vm
1521+
.builtin_runners
1522+
.iter()
1523+
.filter(|builtin| {
1524+
// Those segments are not treated as builtins by the prover.
1525+
!matches!(
1526+
builtin,
1527+
BuiltinRunner::SegmentArena(_) | BuiltinRunner::Output(_)
1528+
)
1529+
})
1530+
.map(|builtin| {
1531+
let (index, _) = builtin.get_memory_segment_addresses();
1532+
(index, builtin.name())
1533+
})
15231534
.collect();
15241535

15251536
Ok(ProverInputInfo {
@@ -5595,4 +5606,26 @@ mod tests {
55955606
HashMap::from([(2, BuiltinName::ecdsa)])
55965607
);
55975608
}
5609+
5610+
#[test]
5611+
fn test_output_not_builtin_segment() {
5612+
let program_content =
5613+
include_bytes!("../../../../cairo_programs/proof_programs/split_felt.json");
5614+
let runner = crate::cairo_run::cairo_run(
5615+
program_content,
5616+
&CairoRunConfig {
5617+
trace_enabled: true,
5618+
layout: LayoutName::all_cairo,
5619+
..Default::default()
5620+
},
5621+
&mut BuiltinHintProcessor::new_empty(),
5622+
)
5623+
.unwrap();
5624+
let prover_info = runner.get_prover_input_info().unwrap();
5625+
5626+
assert!(!prover_info
5627+
.builtins_segments
5628+
.values()
5629+
.any(|v| *v == BuiltinName::output));
5630+
}
55985631
}

0 commit comments

Comments
 (0)