Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serde: add size field to Identifier #1861

Merged
merged 4 commits into from
Nov 6, 2024
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* fix: [#1855](https://github.com/lambdaclass/cairo-vm/pull/1855):
* Adds logic to skip pedersen additional data comparison when checking pie compatibility.

* serde: add `size` field to `Identifier` [#1861]https://github.com/lambdaclass/cairo-vm/pull/1861

#### [2.0.0-rc0] - 2024-10-22

* fix: [#1864](https://github.com/lambdaclass/cairo-vm/pull/1864):
Expand Down
24 changes: 16 additions & 8 deletions vm/src/serde/deserialize_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub struct Identifier {
pub full_name: Option<String>,
pub members: Option<HashMap<String, Member>>,
pub cairo_type: Option<String>,
pub size: Option<usize>,
}

#[cfg_attr(feature = "test_utils", derive(Arbitrary))]
Expand Down Expand Up @@ -566,7 +567,7 @@ mod tests {
"attributes": [],
"debug_info": {
"instruction_locations": {}
},
},
"builtins": [],
"data": [
"0x480680017fff8000",
Expand Down Expand Up @@ -1012,6 +1013,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);
identifiers.insert(
Expand All @@ -1025,6 +1027,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);
identifiers.insert(
Expand All @@ -1036,6 +1039,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);
identifiers.insert(
Expand All @@ -1049,6 +1053,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);
identifiers.insert(
Expand All @@ -1060,6 +1065,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);
identifiers.insert(
Expand All @@ -1071,6 +1077,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);
identifiers.insert(
Expand All @@ -1082,6 +1089,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand All @@ -1097,7 +1105,7 @@ mod tests {
"attributes": [],
"debug_info": {
"instruction_locations": {}
},
},
"builtins": [],
"data": [
],
Expand Down Expand Up @@ -1178,10 +1186,10 @@ mod tests {
"start_pc": 402,
"value": "SafeUint256: subtraction overflow"
}
],
],
"debug_info": {
"instruction_locations": {}
},
},
"builtins": [],
"data": [
],
Expand Down Expand Up @@ -1235,7 +1243,7 @@ mod tests {
let valid_json = r#"
{
"prime": "0x800000000000011000000000000000000000000000000000000000000000001",
"attributes": [],
"attributes": [],
"debug_info": {
"file_contents": {},
"instruction_locations": {
Expand Down Expand Up @@ -1286,7 +1294,7 @@ mod tests {
}
}
}
},
},
"builtins": [],
"data": [
],
Expand Down Expand Up @@ -1344,7 +1352,7 @@ mod tests {
let valid_json = r#"
{
"prime": "0x800000000000011000000000000000000000000000000000000000000000001",
"attributes": [],
"attributes": [],
"debug_info": {
"file_contents": {},
"instruction_locations": {
Expand Down Expand Up @@ -1391,7 +1399,7 @@ mod tests {
}
}
}
},
},
"builtins": [],
"data": [
],
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 @@ -127,6 +127,7 @@ pub(crate) struct IdentifierSerializer {
pub full_name: Option<String>,
pub members: Option<HashMap<String, Member>>,
pub cairo_type: Option<String>,
pub size: Option<usize>,
}

impl From<IdentifierSerializer> for Identifier {
Expand All @@ -138,6 +139,7 @@ impl From<IdentifierSerializer> for Identifier {
full_name: identifier_serialer.full_name,
members: identifier_serialer.members,
cairo_type: identifier_serialer.cairo_type,
size: identifier_serialer.size,
}
}
}
Expand All @@ -151,6 +153,7 @@ impl From<Identifier> for IdentifierSerializer {
full_name: identifier_serialer.full_name,
members: identifier_serialer.members,
cairo_type: identifier_serialer.cairo_type,
size: identifier_serialer.size,
}
}
}
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 @@ -720,6 +720,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand All @@ -732,6 +733,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand Down Expand Up @@ -773,6 +775,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand All @@ -785,6 +788,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand Down Expand Up @@ -934,6 +938,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand All @@ -946,6 +951,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand Down Expand Up @@ -1059,6 +1065,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand All @@ -1071,6 +1078,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand Down Expand Up @@ -1123,6 +1131,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand All @@ -1135,6 +1144,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand Down Expand Up @@ -1182,6 +1192,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);
identifiers.insert(
Expand All @@ -1193,6 +1204,7 @@ mod tests {
full_name: Some("__main__.main.Args".to_string()),
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
},
);
identifiers.insert(
Expand All @@ -1204,6 +1216,7 @@ mod tests {
full_name: Some("__main__.main.ImplicitArgs".to_string()),
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
},
);
identifiers.insert(
Expand All @@ -1215,6 +1228,7 @@ mod tests {
full_name: Some("__main__.main.Return".to_string()),
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
},
);
identifiers.insert(
Expand All @@ -1226,6 +1240,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);

Expand Down Expand Up @@ -1281,6 +1296,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
);
identifiers.insert(
Expand All @@ -1292,6 +1308,7 @@ mod tests {
full_name: Some("__main__.main.Args".to_string()),
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
},
);
identifiers.insert(
Expand All @@ -1303,6 +1320,7 @@ mod tests {
full_name: Some("__main__.main.ImplicitArgs".to_string()),
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
},
);
identifiers.insert(
Expand All @@ -1314,6 +1332,7 @@ mod tests {
full_name: Some("__main__.main.Return".to_string()),
members: Some(HashMap::new()),
cairo_type: None,
size: Some(0),
},
);
identifiers.insert(
Expand All @@ -1325,6 +1344,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: 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 @@ -4489,6 +4489,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
)]
.into_iter()
Expand Down Expand Up @@ -4517,6 +4518,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
),
(
Expand All @@ -4528,6 +4530,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
),
]
Expand Down Expand Up @@ -4557,6 +4560,7 @@ mod tests {
full_name: None,
members: None,
cairo_type: None,
size: None,
},
)]
.into_iter()
Expand Down
Loading