Skip to content

Commit

Permalink
Merge branch 'main' into notlesh/allow-ints-in-relocation-table
Browse files Browse the repository at this point in the history
  • Loading branch information
notlesh committed Nov 19, 2024
2 parents cf36b4a + 0d86936 commit 6e5ea89
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 16 deletions.
19 changes: 17 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
## Cairo-VM Changelog

#### Upcoming Changes
* fix: [#1862](https://github.com/lambdaclass/cairo-vm/pull/1862):
* Use MaybeRelocatable for relocation table

* fix: [#1873](https://github.com/lambdaclass/cairo-vm/pull/1873)
* Fix broken num-prime `is_prime` call
* fix: [#1868](https://github.com/lambdaclass/cairo-vm/pull/1855):
* Adds logic to include the 3 new builtins in `builtin_segments` when serializing the output cairo pie's metadata.

* 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: [#1862](https://github.com/lambdaclass/cairo-vm/pull/1862):
* Use MaybeRelocatable for relocation table
* fix: [#1864](https://github.com/lambdaclass/cairo-vm/pull/1864):
* Runner: include data from constants segment to the bytecode when assembling program

* chore: bump `cairo-lang-` dependencies to 2.9.0-dev.0 [#1858](https://github.com/lambdaclass/cairo-vm/pull/1858/files)

* chore: update Rust required version to 1.81.0 [#1857](https://github.com/lambdaclass/cairo-vm/pull/1857)

* fix: [#1851](https://github.com/lambdaclass/cairo-vm/pull/1851):
* Fix unsorted signature and mod builtin outputs in air_private_input.

* feat(BREAKING): [#1824](https://github.com/lambdaclass/cairo-vm/pull/1824)[#1838](https://github.com/lambdaclass/cairo-vm/pull/1838):
* Add support for dynamic layout
* CLI change(BREAKING): The flag `cairo_layout_params_file` must be specified when using dynamic layout.
Expand Down
12 changes: 8 additions & 4 deletions cairo1-run/src/cairo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,14 @@ pub fn cairo_run_program(
cairo_run_config.copy_to_output(),
);

let data: Vec<MaybeRelocatable> = instructions
.flat_map(|inst| inst.assemble().encode())
.map(|x| Felt252::from(&x))
.map(MaybeRelocatable::from)
// The bytecode includes all program instructions plus entry/footer,
// plus data from the constants segments.
let data: Vec<MaybeRelocatable> = casm_program
.assemble_ex(&entry_code.instructions, &libfunc_footer)
.bytecode
.into_iter()
.map(Into::<Felt252>::into)
.map(Into::<MaybeRelocatable>::into)
.collect();

let program = if cairo_run_config.proof_mode {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/math_utils/is_prime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod with_std {
use num_bigint::BigUint;

pub fn is_prime(n: &BigUint) -> bool {
num_prime::nt_funcs::is_prime(n, None).probably()
num_prime::nt_funcs::is_prime::<BigUint>(n, None).probably()
}
}

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
2 changes: 2 additions & 0 deletions vm/src/vm/runners/builtin_runner/modulo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ impl ModBuiltinRunner {
});
}

instances.sort_by_key(|input| input.index);

vec![PrivateInput::Mod(ModInput {
instances,
zero_value_address: relocation_table
Expand Down
Loading

0 comments on commit 6e5ea89

Please sign in to comment.