Skip to content

Commit c2f648a

Browse files
committed
use btreemap instead of hashmap for deterministic iteration order.
1 parent fb8fa9b commit c2f648a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG.md

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

33
#### Upcoming Changes
4+
* Refactor: Replaced HashMap with BTreeMap to guarantee deterministic ordering of the data [#2023] (https://github.com/lambdaclass/cairo-vm/pull/2023)
5+
46
* 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)
57

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

vm/src/vm/runners/cairo_runner.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::{
1414
trace::trace_entry::{relocate_trace_register, RelocatedTraceEntry, TraceEntry},
1515
},
1616
Felt252,
17+
with_std::collections::BTreeMap,
1718
};
1819

1920
use crate::{
@@ -1549,9 +1550,9 @@ pub struct ProverInputInfo {
15491550
/// A vector of segments, where each segment is a vector of maybe relocatable values or holes (`None`).
15501551
pub relocatable_memory: Vec<Vec<Option<MaybeRelocatable>>>,
15511552
/// A map from segment index to a vector of offsets within the segment, representing the public memory addresses.
1552-
pub public_memory_offsets: HashMap<usize, Vec<usize>>,
1553+
pub public_memory_offsets: BTreeMap<usize, Vec<usize>>,
15531554
/// A map from the builtin segment index into its name.
1554-
pub builtins_segments: HashMap<usize, BuiltinName>,
1555+
pub builtins_segments: BTreeMap<usize, BuiltinName>,
15551556
}
15561557

15571558
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -5598,7 +5599,7 @@ mod tests {
55985599
assert!(prover_info.public_memory_offsets.is_empty());
55995600
assert_eq!(
56005601
prover_info.builtins_segments,
5601-
HashMap::from([(2, BuiltinName::ecdsa)])
5602+
BTreeMap::from([(2, BuiltinName::ecdsa)])
56025603
);
56035604
}
56045605
}

0 commit comments

Comments
 (0)