From 60252573255bdf77cf980d689db5b8539dde5e52 Mon Sep 17 00:00:00 2001 From: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:37:46 +0100 Subject: [PATCH] serde: add `size` field to `Identifier` (#1861) * serde: add size field to Identifier * fix changelog --------- Co-authored-by: Pedro Fontana --- CHANGELOG.md | 2 ++ vm/src/serde/deserialize_program.rs | 24 ++++++++++++++++-------- vm/src/serde/serialize_program.rs | 3 +++ vm/src/types/program.rs | 20 ++++++++++++++++++++ vm/src/vm/runners/cairo_runner.rs | 4 ++++ 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f81b7f66e8..d4f8d6d455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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): diff --git a/vm/src/serde/deserialize_program.rs b/vm/src/serde/deserialize_program.rs index 3fbd848932..052d9ae09c 100644 --- a/vm/src/serde/deserialize_program.rs +++ b/vm/src/serde/deserialize_program.rs @@ -102,6 +102,7 @@ pub struct Identifier { pub full_name: Option, pub members: Option>, pub cairo_type: Option, + pub size: Option, } #[cfg_attr(feature = "test_utils", derive(Arbitrary))] @@ -566,7 +567,7 @@ mod tests { "attributes": [], "debug_info": { "instruction_locations": {} - }, + }, "builtins": [], "data": [ "0x480680017fff8000", @@ -1012,6 +1013,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); identifiers.insert( @@ -1025,6 +1027,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); identifiers.insert( @@ -1036,6 +1039,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); identifiers.insert( @@ -1049,6 +1053,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); identifiers.insert( @@ -1060,6 +1065,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); identifiers.insert( @@ -1071,6 +1077,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); identifiers.insert( @@ -1082,6 +1089,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -1097,7 +1105,7 @@ mod tests { "attributes": [], "debug_info": { "instruction_locations": {} - }, + }, "builtins": [], "data": [ ], @@ -1178,10 +1186,10 @@ mod tests { "start_pc": 402, "value": "SafeUint256: subtraction overflow" } - ], + ], "debug_info": { "instruction_locations": {} - }, + }, "builtins": [], "data": [ ], @@ -1235,7 +1243,7 @@ mod tests { let valid_json = r#" { "prime": "0x800000000000011000000000000000000000000000000000000000000000001", - "attributes": [], + "attributes": [], "debug_info": { "file_contents": {}, "instruction_locations": { @@ -1286,7 +1294,7 @@ mod tests { } } } - }, + }, "builtins": [], "data": [ ], @@ -1344,7 +1352,7 @@ mod tests { let valid_json = r#" { "prime": "0x800000000000011000000000000000000000000000000000000000000000001", - "attributes": [], + "attributes": [], "debug_info": { "file_contents": {}, "instruction_locations": { @@ -1391,7 +1399,7 @@ mod tests { } } } - }, + }, "builtins": [], "data": [ ], diff --git a/vm/src/serde/serialize_program.rs b/vm/src/serde/serialize_program.rs index f8bd0d076a..1e9f83e8d1 100644 --- a/vm/src/serde/serialize_program.rs +++ b/vm/src/serde/serialize_program.rs @@ -127,6 +127,7 @@ pub(crate) struct IdentifierSerializer { pub full_name: Option, pub members: Option>, pub cairo_type: Option, + pub size: Option, } impl From for Identifier { @@ -138,6 +139,7 @@ impl From for Identifier { full_name: identifier_serialer.full_name, members: identifier_serialer.members, cairo_type: identifier_serialer.cairo_type, + size: identifier_serialer.size, } } } @@ -151,6 +153,7 @@ impl From for IdentifierSerializer { full_name: identifier_serialer.full_name, members: identifier_serialer.members, cairo_type: identifier_serialer.cairo_type, + size: identifier_serialer.size, } } } diff --git a/vm/src/types/program.rs b/vm/src/types/program.rs index 0fc8c6dc83..477f996577 100644 --- a/vm/src/types/program.rs +++ b/vm/src/types/program.rs @@ -720,6 +720,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -732,6 +733,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -773,6 +775,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -785,6 +788,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -934,6 +938,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -946,6 +951,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -1059,6 +1065,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -1071,6 +1078,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -1123,6 +1131,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -1135,6 +1144,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -1182,6 +1192,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); identifiers.insert( @@ -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( @@ -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( @@ -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( @@ -1226,6 +1240,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); @@ -1281,6 +1296,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); identifiers.insert( @@ -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( @@ -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( @@ -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( @@ -1325,6 +1344,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ); diff --git a/vm/src/vm/runners/cairo_runner.rs b/vm/src/vm/runners/cairo_runner.rs index 239515458d..65209c35de 100644 --- a/vm/src/vm/runners/cairo_runner.rs +++ b/vm/src/vm/runners/cairo_runner.rs @@ -4489,6 +4489,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, )] .into_iter() @@ -4517,6 +4518,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ), ( @@ -4528,6 +4530,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, ), ] @@ -4557,6 +4560,7 @@ mod tests { full_name: None, members: None, cairo_type: None, + size: None, }, )] .into_iter()