Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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

* feat: add support for alias identifiers destination in program serde [#2071](https://github.com/lambdaclass/cairo-vm/pull/2071)

* dev: add Memory::get_maybe_relocatable [#2039](https://github.com/lambdaclass/cairo-vm/pull/2039)

* refactor: remove duplicated get_val function [#2065](https://github.com/lambdaclass/cairo-vm/pull/2065)
Expand Down
9 changes: 9 additions & 0 deletions vm/src/serde/deserialize_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ pub struct Identifier {
pub members: Option<HashMap<String, Member>>,
pub cairo_type: Option<String>,
pub size: Option<usize>,
// In case of an alias - resolves to the original identifier
pub destination: Option<String>,
}

#[cfg_attr(feature = "test_utils", derive(Arbitrary))]
Expand Down Expand Up @@ -1014,6 +1016,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);
identifiers.insert(
Expand All @@ -1028,6 +1031,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);
identifiers.insert(
Expand All @@ -1040,6 +1044,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: Some(String::from("starkware.cairo.common.math.unsigned_div_rem")),
},
);
identifiers.insert(
Expand All @@ -1054,6 +1059,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);
identifiers.insert(
Expand All @@ -1066,6 +1072,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);
identifiers.insert(
Expand All @@ -1078,6 +1085,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);
identifiers.insert(
Expand All @@ -1090,6 +1098,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand Down
3 changes: 3 additions & 0 deletions vm/src/serde/serialize_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub(crate) struct IdentifierSerializer {
pub members: Option<HashMap<String, Member>>,
pub cairo_type: Option<String>,
pub size: Option<usize>,
pub destination: Option<String>, // in case of alias
}

impl From<IdentifierSerializer> for Identifier {
Expand All @@ -140,6 +141,7 @@ impl From<IdentifierSerializer> for Identifier {
members: identifier_serialer.members,
cairo_type: identifier_serialer.cairo_type,
size: identifier_serialer.size,
destination: identifier_serialer.destination,
}
}
}
Expand All @@ -154,6 +156,7 @@ impl From<Identifier> for IdentifierSerializer {
members: identifier_serialer.members,
cairo_type: identifier_serialer.cairo_type,
size: identifier_serialer.size,
destination: identifier_serialer.destination,
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions vm/src/types/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand All @@ -734,6 +735,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand Down Expand Up @@ -776,6 +778,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand All @@ -789,6 +792,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand Down Expand Up @@ -939,6 +943,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand All @@ -952,6 +957,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand Down Expand Up @@ -1066,6 +1072,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand All @@ -1079,6 +1086,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand Down Expand Up @@ -1132,6 +1140,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand All @@ -1145,6 +1154,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand Down Expand Up @@ -1193,6 +1203,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);
identifiers.insert(
Expand All @@ -1205,6 +1216,7 @@ mod tests {
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
destination: None,
},
);
identifiers.insert(
Expand All @@ -1217,6 +1229,7 @@ mod tests {
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
destination: None,
},
);
identifiers.insert(
Expand All @@ -1229,6 +1242,7 @@ mod tests {
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
destination: None,
},
);
identifiers.insert(
Expand All @@ -1241,6 +1255,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand Down Expand Up @@ -1297,6 +1312,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);
identifiers.insert(
Expand All @@ -1309,6 +1325,7 @@ mod tests {
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
destination: None,
},
);
identifiers.insert(
Expand All @@ -1321,6 +1338,7 @@ mod tests {
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
destination: None,
},
);
identifiers.insert(
Expand All @@ -1333,6 +1351,7 @@ mod tests {
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
destination: None,
},
);
identifiers.insert(
Expand All @@ -1345,6 +1364,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
);

Expand Down
4 changes: 4 additions & 0 deletions vm/src/vm/runners/cairo_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4597,6 +4597,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
)]
.into_iter()
Expand Down Expand Up @@ -4626,6 +4627,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
),
(
Expand All @@ -4638,6 +4640,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
),
]
Expand Down Expand Up @@ -4668,6 +4671,7 @@ mod tests {
members: None,
cairo_type: None,
size: None,
destination: None,
},
)]
.into_iter()
Expand Down