Skip to content

[DNM] starkware-development synced with 2.x.y #2148

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

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
43b85a1
Improve documentation (#2006)
JulianGCalderon Mar 17, 2025
f1909dd
Replace thiserror-no-std with thiserror 2 (#1919)
DaniPopes Mar 17, 2025
9690634
fix: handle unfilled values in mul mod runner (#1976)
enitrat Mar 17, 2025
c87b23d
stav: extract information for the prover from the runner (#2001)
Stavbe Mar 18, 2025
7dde1c6
Replace security anyhow errors with enum variants (#1946)
JulianGCalderon Mar 18, 2025
2723e6f
Fix comment in `initialize_builtins()` (#2005)
FrancoGiachetta Mar 19, 2025
04e5e8d
Removed CODEOWNERS file (#2018)
igaray Mar 19, 2025
5307101
Fix CantWriteReturnFp and other issues related to the initial gas loa…
FrancoGiachetta Mar 19, 2025
3aed532
Refactor: Clap attribute macros from #[clap(...)] to #[arg(...)] and …
Himess Mar 19, 2025
957f7f1
Add starkware-development to CI (like another main) (#2025)
JulianGCalderon Mar 25, 2025
f8e3a82
Keep None memory cells for the prover input info (#2021)
Stavbe Mar 25, 2025
7c4ecdf
CI: Fix cache not found error (#2026)
JulianGCalderon Mar 25, 2025
63fa1b7
Remove dependancy in cairo pie when collectiog builtin segments info …
Stavbe Mar 26, 2025
75752a4
Add Commit Signing section (#2019)
gabrielbosio Mar 26, 2025
60e6f24
use btreemap instead of hashmap for deterministic iteration order. (#…
Stavbe Mar 27, 2025
106e5f8
Add starkware-development to CI (like another main) (#2025)
JulianGCalderon Mar 25, 2025
ce73503
Keep None memory cells for the prover input info (#2021)
Stavbe Mar 25, 2025
05fb44f
CI: Fix cache not found error (#2026)
JulianGCalderon Mar 25, 2025
bdd75dd
Remove dependancy in cairo pie when collectiog builtin segments info …
Stavbe Mar 26, 2025
7d7c460
Add Commit Signing section (#2019)
gabrielbosio Mar 26, 2025
92e3188
use btreemap instead of hashmap for deterministic iteration order. (#…
Stavbe Mar 27, 2025
7b9e1c5
feat: implement VirtualMachine::is_accessed (#2033)
dorimedini-starkware Mar 27, 2025
4e473eb
feat: add get_current_step getter (#2034)
dorimedini-starkware Mar 27, 2025
10154c6
Stav/sync starkware dev (#2035)
yuvalsw Mar 27, 2025
82e465b
Update changelog.yml (#2037)
igaray Mar 28, 2025
2137db8
fill holes is builtins segments
Stavbe Apr 2, 2025
1d70783
fill holes is builtins segments (#2036)
Stavbe Apr 3, 2025
368e3fb
Bump Cairo to v2.12.0-dev.0 (#2040)
JulianGCalderon Apr 3, 2025
0038711
fix: Always use a normal segment in first SegmentArena segment (#1845)
notlesh Apr 4, 2025
6dfd853
fill holes is builtins segments
Stavbe Apr 2, 2025
2b5ceaf
Rebase starkware-development on top of current main (#2052)
YairVaknin-starkware Apr 7, 2025
895be71
Added hints felt unpacking for blake (#2032)
yuvalsw Apr 7, 2025
d729b9f
add prover input info flag to vm-cli
Stavbe Apr 3, 2025
b9330cd
Stav/add prover input info flag (#2047)
Stavbe Apr 7, 2025
3179708
set disable trace padding for prover input info
Stavbe Apr 10, 2025
ba51705
Stav/disable trace padding for prover input info (#2066)
Stavbe Apr 14, 2025
28f4004
Add_perp_and_dex_w_bitwise_layouts (#2067)
YairVaknin-starkware Apr 14, 2025
9c44e1c
Fix_zero_offset_output_base_assumption (#2068)
YairVaknin-starkware Apr 14, 2025
58174f3
add flag to serialize prover input info into binary files
Stavbe Apr 27, 2025
33d75ca
use bincode for faster writing prover input info (#2074)
Stavbe Apr 29, 2025
dc1c49b
Use_btreemap_for_deterministic_order_of_pie_keys (#2085)
YairVaknin-starkware May 5, 2025
b1a91f9
[BREAKING] Compute_missing_builtin_cells_only_in_proof_mode (#2088)
YairVaknin-starkware May 7, 2025
a5b3c9d
move prover input info to a new seperate file (#2079)
Stavbe May 14, 2025
547dca1
add trace not enabled error
Stavbe Apr 29, 2025
da5dffd
add trace not enabled error (#2080)
Stavbe May 22, 2025
627c1ac
add test to filling holes (#2087)
Stavbe May 22, 2025
41486b5
memory comparision test only for non proof mode cases
Stavbe May 15, 2025
b818326
Stav/remove test compare to python vm (#2086)
Stavbe May 22, 2025
7269a8f
Sync with main (#2116)
gabrielbosio Jun 4, 2025
870fd60
Revert "Sync with main (#2116)" (#2117)
gabrielbosio Jun 4, 2025
bdf604f
Bump cairo-lang to 0.13.5 (#1959) (#2118)
gabrielbosio Jun 5, 2025
15de4b2
Enable_using_secure_run_in_proof_mode (#2113)
YairVaknin-starkware Jun 16, 2025
9277002
take ownershop instad of clone
Stavbe Jun 23, 2025
b85e5c6
Stav/remove clone trace (#2127)
Stavbe Jun 26, 2025
4226352
Fixed bad submodule (#2131)
yuvalsw Jul 3, 2025
b6c2f5a
Added support for large files in PIE (#2136)
yuvalsw Jul 20, 2025
df70ca8
[starkware-development] Pin types-rs version to the one set in lockfi…
gabrielbosio Jul 24, 2025
00406f0
Include_output_builtin_in_prover_input_info (#2138)
YairVaknin-starkware Jul 28, 2025
9d2256f
add relocate trace flag to the runner
Stavbe Jul 31, 2025
1a224f8
Stav/disable relocate trace with flag (#2133)
Stavbe Jul 31, 2025
7f124f7
Merge branch '2.x.y' into starkware-development-sync-2.x.y
gabrielbosio Aug 1, 2025
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

#### Upcoming Changes

* chore: Pin types-rs version to the one set in lockfile [#2140](https://github.com/lambdaclass/cairo-vm/pull/2140)

* BREAKING CHANGE: `get_prover_input_info()` now requires `&mut self` and takes ownershop on the trace instead of cloning it. [#2127](https://github.com/lambdaclass/cairo-vm/pull/2127)

* Refactor: Replaced HashMap with BTreeMap to guarantee deterministic ordering of the data [#2023] (https://github.com/lambdaclass/cairo-vm/pull/2023)

* fix: Updated the logic for collecting builtin segment data for prover input info, removing dependency on the existence of stop pointers. [#2022](https://github.com/lambdaclass/cairo-vm/pull/2022)

* fix: Keep None values in memory segments for the prover input info [#2021](https://github.com/lambdaclass/cairo-vm/pull/2021)

#### [2.3.1] - 2025-07-29

* chore: Pin types-rs version to 0.1.8 [#2146](https://github.com/lambdaclass/cairo-vm/pull/2146)
Expand Down Expand Up @@ -58,6 +68,8 @@

* feat: Add `ProverInfo` and extract the relevant information for it from the runner [#2001](https://github.com/lambdaclass/cairo-vm/pull/2001)

* feat: Support hints for new blake felt serialization library code [#1994](https://github.com/lambdaclass/cairo-vm/pull/1994)

#### [2.0.1] - 2025-03-17

* feat: Limited padding of builtin segments to >=16 [#1981](https://github.com/lambdaclass/cairo-vm/pull/1981)
Expand Down
33 changes: 20 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 31 additions & 2 deletions cairo-vm-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use bincode::enc::write::Writer;
use cairo_vm::air_public_input::PublicInputError;
use cairo_vm::cairo_run::{self, EncodeTraceError};
use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor;
use cairo_vm::prover_input_info::ProverInputInfoError;
#[cfg(feature = "with_tracer")]
use cairo_vm::serde::deserialize_program::DebugInfo;
use cairo_vm::types::layout::CairoLayoutParams;
Expand Down Expand Up @@ -69,6 +70,10 @@ struct Args {
conflicts_with_all = ["proof_mode", "air_private_input", "air_public_input"]
)]
cairo_pie_output: Option<String>,
#[arg(long = "prover_input_info", requires_all = ["proof_mode"])]
prover_input_info: Option<String>,
#[arg(long = "prover_input_info_json", requires_all = ["proof_mode"])]
prover_input_info_json: Option<String>,
#[arg(long = "merge_extra_segments")]
merge_extra_segments: bool,
#[arg(long = "allow_missing_builtins")]
Expand Down Expand Up @@ -102,6 +107,8 @@ enum Error {
#[error(transparent)]
PublicInput(#[from] PublicInputError),
#[error(transparent)]
ProveInputInfo(#[from] ProverInputInfoError),
#[error(transparent)]
#[cfg(feature = "with_tracer")]
TraceData(#[from] TraceDataError),
}
Expand Down Expand Up @@ -169,7 +176,10 @@ fn start_tracer(cairo_runner: &CairoRunner) -> Result<(), TraceDataError> {
fn run(args: impl Iterator<Item = String>) -> Result<(), Error> {
let args = Args::try_parse_from(args)?;

let trace_enabled = args.trace_file.is_some() || args.air_public_input.is_some();
let trace_enabled = args.trace_file.is_some()
|| args.air_public_input.is_some()
|| args.prover_input_info.is_some()
|| args.prover_input_info_json.is_some();

let cairo_layout_params = match args.cairo_layout_params_file {
Some(file) => Some(CairoLayoutParams::from_file(&file)?),
Expand All @@ -180,12 +190,14 @@ fn run(args: impl Iterator<Item = String>) -> Result<(), Error> {
entrypoint: &args.entrypoint,
trace_enabled,
relocate_mem: args.memory_file.is_some() || args.air_public_input.is_some(),
relocate_trace: trace_enabled,
layout: args.layout,
proof_mode: args.proof_mode,
secure_run: args.secure_run,
allow_missing_builtins: args.allow_missing_builtins,
dynamic_layout_params: cairo_layout_params,
..Default::default()
disable_trace_padding: args.prover_input_info.is_some()
|| args.prover_input_info_json.is_some(),
};

let mut cairo_runner = match if args.run_from_cairo_pie {
Expand Down Expand Up @@ -236,6 +248,18 @@ fn run(args: impl Iterator<Item = String>) -> Result<(), Error> {
memory_writer.flush()?;
}

if let Some(path) = args.prover_input_info {
let prover_input_info = cairo_runner.get_prover_input_info()?;
let bytes = prover_input_info.serialize()?;
std::fs::write(path, bytes)?;
}

if let Some(path) = args.prover_input_info_json {
let prover_input_info = cairo_runner.get_prover_input_info()?;
let json = prover_input_info.serialize_json()?;
std::fs::write(path, json)?;
}

if let Some(file_path) = args.air_public_input {
let json = cairo_runner.get_air_public_input()?.serialize_json()?;
std::fs::write(file_path, json)?;
Expand Down Expand Up @@ -360,6 +384,7 @@ mod tests {
#[values(false, true)] air_public_input: bool,
#[values(false, true)] air_private_input: bool,
#[values(false, true)] cairo_pie_output: bool,
#[values(false, true)] prover_input_info: bool,
) {
let mut args = vec!["cairo-vm-cli".to_string()];
if let Some(layout) = layout {
Expand Down Expand Up @@ -390,11 +415,15 @@ mod tests {
if print_output {
args.extend_from_slice(&["--print_output".to_string()]);
}
if prover_input_info {
args.extend_from_slice(&["--prover_input_info".to_string(), "/dev/null".to_string()]);
}

args.push("../cairo_programs/proof_programs/fibonacci.json".to_string());
if air_public_input && !proof_mode
|| (air_private_input && (!proof_mode || !trace_file || !memory_file))
|| cairo_pie_output && proof_mode
|| prover_input_info && !proof_mode
{
assert_matches!(run(args.into_iter()), Err(_));
} else {
Expand Down
9 changes: 7 additions & 2 deletions cairo1-run/src/cairo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,12 @@ pub fn cairo_run_program(
runner.run_for_steps(1, &mut hint_processor)?;
}

runner.end_run(false, false, &mut hint_processor)?;
runner.end_run(
false,
false,
&mut hint_processor,
cairo_run_config.proof_mode,
)?;

let result_inner_type_size =
result_inner_type_size(return_type_id, &sierra_program_registry, &type_sizes);
Expand Down Expand Up @@ -336,7 +341,7 @@ pub fn cairo_run_program(
}
}

runner.relocate(true)?;
runner.relocate(true, true)?;

Ok((runner, return_values, serialized_output))
}
Expand Down
12 changes: 12 additions & 0 deletions cairo_programs/poseidon_builtin_hole.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%builtins poseidon
from starkware.cairo.common.cairo_builtins import PoseidonBuiltin
from starkware.cairo.common.poseidon_state import PoseidonBuiltinState

func main{poseidon_ptr: PoseidonBuiltin*}() {
assert poseidon_ptr[0].input = PoseidonBuiltinState(1, 2, 3);
let result = poseidon_ptr[0].output;
let poseidon_ptr = poseidon_ptr + PoseidonBuiltin.SIZE;
assert result.s0 = 442682200349489646213731521593476982257703159825582578145778919623645026501;
assert result.s2 = 2512222140811166287287541003826449032093371832913959128171347018667852712082;
return ();
}
2 changes: 1 addition & 1 deletion vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ num-integer = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
hex = { workspace = true }
bincode = { workspace = true }
bincode = { workspace = true , features = ["alloc"]}
starknet-crypto = { workspace = true }
sha3 = { workspace = true }
indoc = { workspace = true }
Expand Down
35 changes: 24 additions & 11 deletions vm/src/cairo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ pub struct CairoRunConfig<'a> {
#[cfg_attr(feature = "test_utils", arbitrary(value = "main"))]
pub entrypoint: &'a str,
pub trace_enabled: bool,
/// Relocate memory if `true`, otherwise memory is not relocated.
pub relocate_mem: bool,
// When `relocate_trace` is set to `false`, the trace will not be relocated even if `trace_enabled` is `true`.
pub relocate_trace: bool,
pub layout: LayoutName,
/// The `dynamic_layout_params` argument should only be used with dynamic layout.
/// It is ignored otherwise.
Expand All @@ -51,6 +54,8 @@ impl Default for CairoRunConfig<'_> {
entrypoint: "main",
trace_enabled: false,
relocate_mem: false,
// Set to true to match expected behavior: trace is relocated only if trace_enabled is true.
relocate_trace: true,
layout: LayoutName::plain,
proof_mode: false,
secure_run: None,
Expand Down Expand Up @@ -104,17 +109,20 @@ pub fn cairo_run_program_with_initial_scope(
cairo_run_config.disable_trace_padding,
false,
hint_processor,
cairo_run_config.proof_mode,
)?;

cairo_runner.vm.verify_auto_deductions()?;
cairo_runner.read_return_values(allow_missing_builtins)?;
if cairo_run_config.proof_mode {
cairo_runner.finalize_segments()?;
}
if secure_run {
verify_secure_runner(&cairo_runner, true, None)?;
}
cairo_runner.relocate(cairo_run_config.relocate_mem)?;
cairo_runner.relocate(
cairo_run_config.relocate_mem,
cairo_run_config.relocate_trace,
)?;

Ok(cairo_runner)
}
Expand Down Expand Up @@ -213,17 +221,20 @@ pub fn cairo_run_pie(
cairo_run_config.disable_trace_padding,
false,
hint_processor,
cairo_run_config.proof_mode,
)?;

cairo_runner.vm.verify_auto_deductions()?;
cairo_runner.read_return_values(allow_missing_builtins)?;

if secure_run {
verify_secure_runner(&cairo_runner, true, None)?;
// Check that the Cairo PIE produced by this run is compatible with the Cairo PIE received
cairo_runner.get_cairo_pie()?.check_pie_compatibility(pie)?;
}
cairo_runner.relocate(cairo_run_config.relocate_mem)?;
cairo_runner.relocate(
cairo_run_config.relocate_mem,
cairo_run_config.relocate_trace,
)?;

Ok(cairo_runner)
}
Expand Down Expand Up @@ -264,17 +275,19 @@ pub fn cairo_run_fuzzed_program(

res.map_err(|err| VmException::from_vm_error(&cairo_runner, err))?;

cairo_runner.end_run(false, false, hint_processor)?;
cairo_runner.end_run(false, false, hint_processor, cairo_run_config.proof_mode)?;

cairo_runner.vm.verify_auto_deductions()?;
cairo_runner.read_return_values(allow_missing_builtins)?;
if cairo_run_config.proof_mode {
cairo_runner.finalize_segments()?;
}
if secure_run {
verify_secure_runner(&cairo_runner, true, None)?;
}
cairo_runner.relocate(cairo_run_config.relocate_mem)?;
cairo_runner.relocate(
cairo_run_config.relocate_mem,
cairo_run_config.relocate_trace,
)?;

Ok(cairo_runner)
}
Expand Down Expand Up @@ -375,7 +388,7 @@ mod tests {

let end = cairo_runner.initialize(false).unwrap();
assert!(cairo_runner.run_until_pc(end, &mut hint_processor).is_ok());
assert!(cairo_runner.relocate(true).is_ok());
assert!(cairo_runner.relocate(true, true).is_ok());
// `main` returns without doing nothing, but `not_main` sets `[ap]` to `1`
// Memory location was found empirically and simply hardcoded
assert_eq!(cairo_runner.relocated_memory[2], Some(Felt252::from(123)));
Expand Down Expand Up @@ -441,7 +454,7 @@ mod tests {
let mut hint_processor = BuiltinHintProcessor::new_empty();
let mut cairo_runner = run_test_program(program_content, &mut hint_processor).unwrap();

assert!(cairo_runner.relocate(false).is_ok());
assert!(cairo_runner.relocate(false, true).is_ok());

let trace_entries = cairo_runner.relocated_trace.unwrap();
let mut buffer = [0; 24];
Expand All @@ -465,7 +478,7 @@ mod tests {
let mut cairo_runner = run_test_program(program_content, &mut hint_processor).unwrap();

// relocate memory so we can dump it to file
assert!(cairo_runner.relocate(true).is_ok());
assert!(cairo_runner.relocate(true, true).is_ok());

let mut buffer = [0; 120];
let mut buff_writer = SliceWriter::new(&mut buffer);
Expand All @@ -489,7 +502,7 @@ mod tests {
let mut cairo_runner = cairo_runner!(program);
let end = cairo_runner.initialize(false).unwrap();
assert!(cairo_runner.run_until_pc(end, &mut hint_processor).is_ok());
assert!(cairo_runner.relocate(false).is_ok());
assert!(cairo_runner.relocate(false, false).is_ok());
assert!(cairo_runner.relocated_trace.is_none());
}

Expand Down
Loading
Loading