Skip to content

Commit 7145986

Browse files
Update to main
1 parent 9adfff3 commit 7145986

File tree

10 files changed

+66
-45
lines changed

10 files changed

+66
-45
lines changed

.github/workflows/check.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: check
33
on:
44
push:
55
branches:
6-
- main
6+
- meidar/update_rev/main/bl_unpacking
77
pull_request:
88

99
jobs:
@@ -24,7 +24,7 @@ jobs:
2424
- run: rustup show
2525
- run: rustup component add clippy
2626
- uses: Swatinem/rust-cache@v2
27-
- run: cargo clippy --all -- -D warnings
27+
- run: cargo +nightly-2025-07-14 clippy --all -- -D warnings
2828

2929
tests:
3030
runs-on: ubuntu-latest
@@ -45,7 +45,7 @@ jobs:
4545
RUSTFLAGS="-D warnings" cargo run --example run_program
4646
- name: "Unit tests in stwo_run_and_prove"
4747
run: |
48-
RUSTFLAGS="-D warnings" cargo test -p stwo_run_and_prove
48+
RUSTFLAGS="-D warnings" cargo +nightly-2025-07-14 test -p stwo_run_and_prove
4949
5050
udeps:
5151
runs-on: ubuntu-latest
@@ -56,4 +56,4 @@ jobs:
5656
cache-on-failure: true
5757
- run: cargo install cargo-udeps --locked
5858
# - run: cargo +nightly udeps --all-targets
59-
- run: cargo +nightly-2025-04-06 udeps
59+
- run: cargo +nightly-2025-07-14 udeps

.github/workflows/upload_artifacts_workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Upload-Artifacts
33
on:
44
push:
55
branches:
6-
- main
7-
6+
- meidar/update_rev/main/bl_unpacking
7+
88
jobs:
99
artifacts-push:
1010
runs-on: ubuntu-24.04

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ resolver = "2"
1111
bincode = { version = "2.0.1", features = [
1212
"serde",
1313
] }
14-
cairo-lang-executable = { git = "https://github.com/starkware-libs/cairo.git", rev = "f6f7c3bf45c9973bf8782d78c84aed6e741c2a2d" }
15-
cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo.git", rev = "f6f7c3bf45c9973bf8782d78c84aed6e741c2a2d" }
16-
cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo.git", rev = "f6f7c3bf45c9973bf8782d78c84aed6e741c2a2d" }
17-
cairo-lang-execute-utils = { git = "https://github.com/starkware-libs/cairo.git", rev = "f6f7c3bf45c9973bf8782d78c84aed6e741c2a2d" }
14+
cairo-lang-executable = { git = "https://github.com/starkware-libs/cairo.git", rev = "86eb25173f9d8700adbd2770406d715fbf1bb9f8" }
15+
cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo.git", rev = "86eb25173f9d8700adbd2770406d715fbf1bb9f8" }
16+
cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo.git", rev = "86eb25173f9d8700adbd2770406d715fbf1bb9f8" }
17+
cairo-lang-execute-utils = { git = "https://github.com/starkware-libs/cairo.git", rev = "86eb25173f9d8700adbd2770406d715fbf1bb9f8" }
1818
cairo-program-runner-lib = { path = "crates/cairo-program-runner-lib" }
19-
cairo-vm = { git = "https://github.com/lambdaclass/cairo-vm", rev = "b1a91f929b5fa29a1a2e9e6990a68a1220c0c673", features = [
19+
cairo-vm = { git = "https://github.com/lambdaclass/cairo-vm", rev = "e2c6c91c73cd0bc351721f302390fcc0965c6224", features = [
2020
"extensive_hints",
2121
"mod_builtin",
2222
"clap",
@@ -26,15 +26,15 @@ log = "0.4.21"
2626
num-bigint = "0.4"
2727
num-traits = "0.2.19"
2828
regex = "1.11.1"
29-
serde = { version = "1.0.202", features = ["derive"] }
30-
serde_json = "1.0.117"
29+
serde = { version = "1.0.219", features = ["derive"] }
30+
serde_json = "1.0.142"
3131
starknet-crypto = "0.6.2"
3232
starknet-types-core = "0.1.2"
33-
stwo_cairo_utils = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "d7b50347905c687a885a3b6818db4e9311683735" }
34-
stwo-cairo-adapter = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "d7b50347905c687a885a3b6818db4e9311683735" }
35-
stwo_cairo_prover = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "d7b50347905c687a885a3b6818db4e9311683735" }
36-
stwo-cairo-serialize = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "d7b50347905c687a885a3b6818db4e9311683735" }
37-
cairo-air = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "d7b50347905c687a885a3b6818db4e9311683735" }
33+
stwo_cairo_utils = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "59bc14aef12bee9fb9519c3da6e90c4a196206b5" }
34+
stwo-cairo-adapter = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "59bc14aef12bee9fb9519c3da6e90c4a196206b5" }
35+
stwo_cairo_prover = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "59bc14aef12bee9fb9519c3da6e90c4a196206b5" }
36+
stwo-cairo-serialize = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "59bc14aef12bee9fb9519c3da6e90c4a196206b5" }
37+
cairo-air = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "59bc14aef12bee9fb9519c3da6e90c4a196206b5" }
3838
tempfile = "3.10.1"
3939
thiserror = "1.0.61"
4040
thiserror-no-std = "2.0.2"

crates/cairo-program-runner-lib/src/hints/fact_topologies.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ pub fn configure_fact_topologies<FT: AsRef<FactTopology>>(
267267
}
268268

269269
fn check_tree_structure(tree_structure: &[usize]) -> Result<(), TreeStructureError> {
270-
if (!tree_structure.len() % 2 == 0) || (tree_structure.len() > 10) {
270+
if (!tree_structure.len()).is_multiple_of(2) || (tree_structure.len() > 10) {
271271
return Err(TreeStructureError::InvalidTreeStructure);
272272
}
273273

crates/cairo-program-runner-lib/src/hints/load_cairo_pie.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::HashMap;
1+
use std::collections::BTreeMap;
22

33
use cairo_vm::types::builtin_name::BuiltinName;
44
use cairo_vm::types::errors::math_errors::MathError;
@@ -77,7 +77,7 @@ impl From<CairoPieLoaderError> for HintError {
7777
/// a pointer in the VM memory, or to an integer in case the segment is uninitialized.
7878
/// Those will be wrapped by the appropriate `MaybeRelocatable` variant.
7979
pub struct RelocationTable {
80-
relocations: HashMap<isize, MaybeRelocatable>,
80+
relocations: BTreeMap<isize, MaybeRelocatable>,
8181
}
8282

8383
impl RelocationTable {
@@ -156,11 +156,11 @@ pub fn extract_segment(maybe_relocatable: MaybeRelocatable) -> Result<isize, Rel
156156
}
157157
}
158158

159-
/// Builds a hashmap of address -> value from the `CairoPieMemory` vector.
159+
/// Builds a BTreeMap of address -> value from the `CairoPieMemory` vector.
160160
///
161161
/// Makes it more convenient to access values in the Cairo PIE memory.
162-
fn build_cairo_pie_memory_map(memory: &CairoPieMemory) -> HashMap<Relocatable, &MaybeRelocatable> {
163-
let mut memory_map: HashMap<Relocatable, &MaybeRelocatable> = HashMap::new();
162+
fn build_cairo_pie_memory_map(memory: &CairoPieMemory) -> BTreeMap<Relocatable, &MaybeRelocatable> {
163+
let mut memory_map: BTreeMap<Relocatable, &MaybeRelocatable> = BTreeMap::new();
164164

165165
for ((segment_index, offset), value) in memory.0.iter() {
166166
let address = Relocatable::from((*segment_index as isize, *offset));
@@ -203,7 +203,7 @@ pub fn build_cairo_pie_relocation_table(
203203
offset: 0,
204204
};
205205

206-
// Create a hashmap of the program memory for easier searching.
206+
// Create a BTreeMap of the program memory for easier searching.
207207
// If this turns out to be too expensive, consider building it directly
208208
// when building the CairoPie object.
209209
let memory_map = build_cairo_pie_memory_map(&cairo_pie.memory);
@@ -231,7 +231,7 @@ pub fn build_cairo_pie_relocation_table(
231231

232232
fn extend_additional_data(
233233
builtin: &mut SignatureBuiltinRunner,
234-
data: &HashMap<Relocatable, (Felt252, Felt252)>,
234+
data: &BTreeMap<Relocatable, (Felt252, Felt252)>,
235235
relocation_table: &RelocationTable,
236236
) -> Result<(), SignatureRelocationError> {
237237
for (addr, signature) in data {

crates/cairo-program-runner-lib/src/hints/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ impl RunMode {
482482
entrypoint: "main",
483483
trace_enabled: true,
484484
relocate_mem,
485+
relocate_trace: relocate_mem,
485486
layout,
486487
proof_mode: true,
487488
secure_run: None,
@@ -496,6 +497,7 @@ impl RunMode {
496497
entrypoint: "main",
497498
trace_enabled: false,
498499
relocate_mem: false,
500+
relocate_trace: false,
499501
layout,
500502
proof_mode: false,
501503
secure_run: None,

crates/cairo-program-runner-lib/src/tasks.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::{
33
str::FromStr,
44
};
55

6+
use cairo_lang_executable::executable::EntryPointKind;
67
use cairo_lang_executable::executable::Executable;
78
use cairo_lang_execute_utils::{program_and_hints_from_executable, user_args_from_flags};
89
use cairo_vm::types::errors::program_errors::ProgramError;
@@ -75,7 +76,19 @@ pub fn create_cairo1_program_task(
7576
.iter()
7677
.map(|n| BigInt::from_str(&n.to_string()).unwrap())
7778
.collect();
78-
let (program, string_to_hint) = program_and_hints_from_executable(&executable, false)
79+
80+
let entrypoint = executable
81+
.entrypoints
82+
.iter()
83+
.find(|e| e.kind == EntryPointKind::Bootloader)
84+
.ok_or_else(|| {
85+
BootloaderTaskError::Cairo1(format!(
86+
"{:?} entrypoint not found",
87+
EntryPointKind::Bootloader
88+
))
89+
})?;
90+
91+
let (program, string_to_hint) = program_and_hints_from_executable(&executable, entrypoint)
7992
.map_err(|e| BootloaderTaskError::Cairo1(format!("Failed to parse executable: {e:?}")))?;
8093
let user_args = user_args_from_flags(user_args_file.as_ref(), &user_args_list)
8194
.map_err(|e| BootloaderTaskError::Cairo1(format!("Failed to parse user args: {e:?}")))?;

crates/stwo_run_and_prove/src/main.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,24 @@ use stwo_cairo_adapter::vm_import::VmImportError;
2020
use stwo_cairo_prover::prover::{
2121
ChannelHash, ProverParameters, default_prod_prover_parameters, prove_cairo,
2222
};
23-
use stwo_cairo_prover::stwo_prover::core::backend::BackendForChannel;
24-
use stwo_cairo_prover::stwo_prover::core::backend::simd::SimdBackend;
25-
use stwo_cairo_prover::stwo_prover::core::channel::MerkleChannel;
26-
use stwo_cairo_prover::stwo_prover::core::pcs::PcsConfig;
27-
use stwo_cairo_prover::stwo_prover::core::prover::ProvingError;
28-
use stwo_cairo_prover::stwo_prover::core::vcs::blake2_merkle::Blake2sMerkleChannel;
29-
use stwo_cairo_prover::stwo_prover::core::vcs::ops::MerkleHasher;
30-
use stwo_cairo_prover::stwo_prover::core::vcs::poseidon252_merkle::Poseidon252MerkleChannel;
23+
24+
use stwo_cairo_prover::stwo::core::channel::MerkleChannel;
25+
use stwo_cairo_prover::stwo::core::pcs::PcsConfig;
26+
use stwo_cairo_prover::stwo::core::vcs::MerkleHasher;
27+
use stwo_cairo_prover::stwo::core::vcs::blake2_merkle::Blake2sMerkleChannel;
28+
use stwo_cairo_prover::stwo::core::vcs::poseidon252_merkle::Poseidon252MerkleChannel;
29+
use stwo_cairo_prover::stwo::prover::ProvingError;
30+
use stwo_cairo_prover::stwo::prover::backend::BackendForChannel;
31+
use stwo_cairo_prover::stwo::prover::backend::simd::SimdBackend;
32+
33+
// use stwo_cairo_prover::stwo_prover::core::backend::BackendForChannel;
34+
// use stwo_cairo_prover::stwo_prover::core::backend::simd::SimdBackend;
35+
// use stwo_cairo_prover::stwo_prover::core::channel::MerkleChannel;
36+
// use stwo_cairo_prover::stwo_prover::core::pcs::PcsConfig;
37+
// use stwo_cairo_prover::stwo_prover::core::prover::ProvingError;
38+
// use stwo_cairo_prover::stwo_prover::core::vcs::blake2_merkle::Blake2sMerkleChannel;
39+
// use stwo_cairo_prover::stwo_prover::core::vcs::ops::MerkleHasher;
40+
// use stwo_cairo_prover::stwo_prover::core::vcs::poseidon252_merkle::Poseidon252MerkleChannel;
3141
use stwo_cairo_serialize::CairoSerialize;
3242
use stwo_cairo_utils::file_utils::{IoErrorWithPath, create_file, read_to_string};
3343
use thiserror::Error;
@@ -183,9 +193,7 @@ fn stwo_run_and_prove(
183193
let program_input = get_program_input(&program_input)?;
184194
info!("Running cairo run program.");
185195
let runner = cairo_run_program(&program, program_input, cairo_run_config)?;
186-
let mut prover_input_info = runner.get_prover_input_info()?;
187-
info!("Adapting prover input.");
188-
let prover_input = adapter(&mut prover_input_info)?;
196+
let prover_input = adapter(&runner);
189197
let output_vec = prove_with_retries(prover_input, prove_config, prover)?;
190198

191199
if let Some(output_path) = program_output {
@@ -229,7 +237,7 @@ fn prove_with_retries(
229237
i + 1,
230238
prove_config.n_proof_attempts
231239
);
232-
let proof_file_path = prove_config.proofs_dir.join(format!("proof_{}", i));
240+
let proof_file_path = prove_config.proofs_dir.join(format!("proof_{i}"));
233241

234242
match prover.choose_channel_and_prove(
235243
&cairo_prover_inputs,
@@ -360,7 +368,7 @@ where
360368
CairoSerialize::serialize(&proof, &mut serialized);
361369
let hex_strings: Vec<String> = serialized
362370
.into_iter()
363-
.map(|felt| format!("0x{:x}", felt))
371+
.map(|felt| format!("0x{felt:x}"))
364372
.collect();
365373
let serialized_hex = sonic_rs::to_string_pretty(&hex_strings)?;
366374
proof_file.write_all(serialized_hex.as_bytes())?;

crates/vm_runner/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ fn run(args: impl Iterator<Item = String>) -> Result<ProverInput, Error> {
6767
// we don't need to relocate memory in the VM because we later call the adapter that does
6868
// relocation.
6969
relocate_mem: false,
70+
relocate_trace: false,
7071
layout: args.layout,
7172
proof_mode: true,
7273
secure_run: None,
@@ -75,10 +76,7 @@ fn run(args: impl Iterator<Item = String>) -> Result<ProverInput, Error> {
7576
dynamic_layout_params: None,
7677
};
7778
let cairo_runner = cairo_run_program(&program, program_input_contents, cairo_run_config)?;
78-
let mut prover_input_info = cairo_runner
79-
.get_prover_input_info()
80-
.expect("Unable to get prover input info");
81-
let prover_input = adapter(&mut prover_input_info)?;
79+
let prover_input = adapter(&cairo_runner);
8280

8381
let execution_resources = ExecutionResources::from_prover_input(&prover_input);
8482
log::info!("Execution resources: {execution_resources:#?}");

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "nightly-2025-04-06"
2+
channel = "nightly-2025-07-14"

0 commit comments

Comments
 (0)