Skip to content

Commit

Permalink
Ignore memory order in CairoPie validation. (#1780)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alon-Ti authored Jun 4, 2024
1 parent c65591e commit 7159ed9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#### Upcoming Changes

* fix: Ignore memory order when comparing instances of `CairoPieMemory` [#1780](https://github.com/lambdaclass/cairo-vm/pull/1780)

* feat: Add `EXCESS_BALANCE` hint [#1777](https://github.com/lambdaclass/cairo-vm/pull/1777)

* feat(BREAKING): Use a cheatcode to relocate all dicts + Make temporary segment usage configurable [#1776](https://github.com/lambdaclass/cairo-vm/pull/1776)
Expand Down
17 changes: 16 additions & 1 deletion vm/src/vm/runners/cairo_pie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,27 @@ impl From<(isize, usize)> for SegmentInfo {
// A simplified version of Memory, without any additional data besides its elements
// Contains all addr-value pairs, ordered by index and offset
// Allows practical serialization + conversion between CairoPieMemory & Memory
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Clone, Debug, Eq)]
pub struct CairoPieMemory(
#[serde(serialize_with = "serde_impl::serialize_memory")]
pub Vec<((usize, usize), MaybeRelocatable)>,
);

impl PartialEq for CairoPieMemory {
fn eq(&self, other: &Self) -> bool {
fn as_hashmap(
cairo_pie_memory: &CairoPieMemory,
) -> HashMap<&(usize, usize), &MaybeRelocatable> {
cairo_pie_memory
.0
.iter()
.map(|tuple| (&tuple.0, &tuple.1))
.collect::<HashMap<&(usize, usize), &MaybeRelocatable>>()
}
as_hashmap(self) == as_hashmap(other)
}
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct PublicMemoryPage {
pub start: usize,
Expand Down

0 comments on commit 7159ed9

Please sign in to comment.