Skip to content

Commit 9f40002

Browse files
Bump stwo-cairo, cairo-vm, cairo-lang
1 parent e754360 commit 9f40002

File tree

6 files changed

+43
-118
lines changed

6 files changed

+43
-118
lines changed

Cargo.toml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ resolver = "2"
99

1010
[workspace.dependencies]
1111
anyhow = "1.0.98"
12-
bincode = { version = "2.0.1", features = [
13-
"serde",
14-
] }
15-
cairo-air = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "a8a434b521a588cf80eb3625affb984f9913be6c" }
16-
cairo-lang-executable = "=2.12.4-dev.1"
17-
cairo-lang-runner = "=2.12.4-dev.1"
18-
cairo-lang-casm = "=2.12.4-dev.1"
19-
cairo-lang-execute-utils = "=2.12.4-dev.1"
12+
bincode = { version = "2.0.1", features = ["serde"] }
13+
cairo-air = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "6b45dd698a31d76c43f1e400cdb7ed8c23f97157" }
14+
cairo-lang-executable = "=2.14.1-dev.0"
15+
cairo-lang-runner = "=2.14.1-dev.0"
16+
cairo-lang-casm = "=2.14.1-dev.0"
17+
cairo-lang-execute-utils = "=2.14.1-dev.0"
2018
cairo-program-runner-lib = { path = "crates/cairo-program-runner-lib" }
21-
cairo-vm = { version = "=3.0.0-rc.3", features = ["extensive_hints", "mod_builtin", "clap"] }
19+
cairo-vm = { version = "=3.0.0", features = [
20+
"extensive_hints",
21+
"mod_builtin",
22+
"clap",
23+
] }
2224
clap = { version = "4.3.10", features = ["derive"] }
2325
ctor = "0.2"
2426
env_logger = "0.11.3"
@@ -31,15 +33,14 @@ serde_json = "1.0.142"
3133
sonic-rs = "0.3.17"
3234
starknet-crypto = "=0.8.1"
3335
starknet-ff = "0.3.7"
34-
starknet-types-core = "=0.2.0"
35-
stwo_cairo_utils = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "a8a434b521a588cf80eb3625affb984f9913be6c" }
36-
stwo-cairo-adapter = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "a8a434b521a588cf80eb3625affb984f9913be6c" }
37-
stwo_cairo_prover = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "a8a434b521a588cf80eb3625affb984f9913be6c" }
38-
stwo-cairo-serialize = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "a8a434b521a588cf80eb3625affb984f9913be6c" }
36+
starknet-types-core = "=0.2.4"
37+
stwo_cairo_utils = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "6b45dd698a31d76c43f1e400cdb7ed8c23f97157" }
38+
stwo-cairo-adapter = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "6b45dd698a31d76c43f1e400cdb7ed8c23f97157" }
39+
stwo_cairo_prover = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "6b45dd698a31d76c43f1e400cdb7ed8c23f97157" }
40+
stwo-cairo-serialize = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "6b45dd698a31d76c43f1e400cdb7ed8c23f97157" }
3941
tempfile = "3.10.1"
4042
thiserror = "1.0.61"
4143
thiserror-no-std = "2.0.2"
4244
tracing = "0.1.40"
4345
mockall = "0.13.1"
4446
rstest = "0.21"
45-

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

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,7 @@ mod tests {
919919
HintProcessorData::new_default(String::from(BOOTLOADER_SAVE_OUTPUT_POINTER), ids_data);
920920
let mut hint_processor = MinimalBootloaderHintProcessor::new();
921921
assert!(matches!(
922-
hint_processor.execute_hint(
923-
&mut vm,
924-
&mut exec_scopes,
925-
&any_box!(hint_data),
926-
&HashMap::new(),
927-
),
922+
hint_processor.execute_hint(&mut vm, &mut exec_scopes, &any_box!(hint_data),),
928923
Ok(())
929924
));
930925

@@ -970,12 +965,7 @@ mod tests {
970965
);
971966
let mut hint_processor = MinimalBootloaderHintProcessor::new();
972967
assert!(matches!(
973-
hint_processor.execute_hint(
974-
&mut vm,
975-
&mut exec_scopes,
976-
&any_box!(hint_data),
977-
&HashMap::new(),
978-
),
968+
hint_processor.execute_hint(&mut vm, &mut exec_scopes, &any_box!(hint_data),),
979969
Ok(())
980970
));
981971

@@ -1073,12 +1063,7 @@ mod tests {
10731063
);
10741064
let mut hint_processor = MinimalBootloaderHintProcessor::new();
10751065
assert!(matches!(
1076-
hint_processor.execute_hint(
1077-
&mut vm,
1078-
&mut exec_scopes,
1079-
&any_box!(hint_data),
1080-
&HashMap::new(),
1081-
),
1066+
hint_processor.execute_hint(&mut vm, &mut exec_scopes, &any_box!(hint_data),),
10821067
Ok(())
10831068
));
10841069

@@ -1118,12 +1103,7 @@ mod tests {
11181103
let mut hint_processor = MinimalBootloaderHintProcessor::new();
11191104

11201105
assert!(matches!(
1121-
hint_processor.execute_hint(
1122-
&mut vm,
1123-
&mut exec_scopes,
1124-
&any_box!(hint_data),
1125-
&HashMap::new(),
1126-
),
1106+
hint_processor.execute_hint(&mut vm, &mut exec_scopes, &any_box!(hint_data),),
11271107
Ok(())
11281108
));
11291109

@@ -1201,12 +1181,7 @@ mod tests {
12011181
);
12021182
let mut hint_processor = MinimalBootloaderHintProcessor::new();
12031183

1204-
let result = hint_processor.execute_hint(
1205-
&mut vm,
1206-
&mut exec_scopes,
1207-
&any_box!(hint_data),
1208-
&HashMap::new(),
1209-
);
1184+
let result = hint_processor.execute_hint(&mut vm, &mut exec_scopes, &any_box!(hint_data));
12101185

12111186
match result {
12121187
Ok(_) => assert!(!expect_fail),

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ fn process_program_common_logic(
371371
&hint.flow_tracking_data.reference_ids,
372372
references,
373373
&hint.accessible_scopes,
374+
program.constants.clone(),
374375
)
375376
.map_err(|err| {
376377
HintError::CustomHint(format!("{err} for hint: {}", hint.code).into())
@@ -406,7 +407,6 @@ pub fn setup_subtask_for_execution(
406407

407408
let mut hint_extension = HintExtension::default();
408409

409-
let subtask_cairo0_constants: Option<HashMap<String, Felt252>>;
410410
let subtask_cairo1_hint_processor: Option<CairoHintProcessor>;
411411
match &task {
412412
Task::Cairo0Program(cairo0_executable) => {
@@ -421,8 +421,6 @@ pub fn setup_subtask_for_execution(
421421
hint_processor,
422422
&mut hint_extension,
423423
)?;
424-
425-
subtask_cairo0_constants = Some(cairo0_executable.program.constants.clone());
426424
// This task doesn’t require a cairo1 hint processor.
427425
subtask_cairo1_hint_processor = None;
428426
}
@@ -450,8 +448,7 @@ pub fn setup_subtask_for_execution(
450448
ret_pc,
451449
)
452450
.map_err(Into::<HintError>::into)?;
453-
// No subtask constants and cairo1 hint processor are used.
454-
subtask_cairo0_constants = None;
451+
// No cairo1 hint processor is used.
455452
subtask_cairo1_hint_processor = None;
456453
}
457454
Task::Cairo1Program(cairo1_executable) => {
@@ -473,11 +470,9 @@ pub fn setup_subtask_for_execution(
473470
subtask_cairo1_hint_processor.as_ref().unwrap(),
474471
&mut hint_extension,
475472
)?;
476-
// Push None since no subtask constants are used.
477-
subtask_cairo0_constants = None;
478473
}
479474
}
480-
hint_processor.spawn_subtask(subtask_cairo0_constants, subtask_cairo1_hint_processor);
475+
hint_processor.spawn_subtask(subtask_cairo1_hint_processor);
481476

482477
// output_runner_data = prepare_output_runner(
483478
// task=task,
@@ -775,12 +770,7 @@ mod tests {
775770
let mut hint_processor = BootloaderHintProcessor::new();
776771

777772
let hint_extension = hint_processor
778-
.execute_hint_extensive(
779-
&mut vm,
780-
&mut exec_scopes,
781-
&any_box!(hint_data),
782-
&HashMap::new(),
783-
)
773+
.execute_hint_extensive(&mut vm, &mut exec_scopes, &any_box!(hint_data))
784774
.expect("Hint failed unexpectedly");
785775

786776
// Fibonnacci code should be loaded after the header whose size is 5 as checked in

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -614,11 +614,8 @@ mod tests {
614614
offset: 10,
615615
};
616616

617-
let result =
618-
configure_fact_topologies(&fact_topologies, &mut output_start, &mut output_builtin)
619-
.expect("Configuring fact topologies failed unexpectedly");
620-
621-
assert_eq!(result, ());
617+
configure_fact_topologies(&fact_topologies, &mut output_start, &mut output_builtin)
618+
.expect("Configuring fact topologies failed unexpectedly");
622619

623620
// We expect the offset to 2 + sum(page_sizes) for each fact topology
624621
let expected_offset: usize = fact_topologies.iter().flat_map(|ft| &ft.page_sizes).sum();

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

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::any::Any;
2-
use std::collections::HashMap;
32
use std::rc::Rc;
43

54
use cairo_lang_runner::CairoHintProcessor;
@@ -11,8 +10,6 @@ use cairo_vm::types::exec_scope::ExecutionScopes;
1110
use cairo_vm::vm::errors::hint_errors::HintError;
1211
use cairo_vm::vm::runners::cairo_runner::ResourceTracker;
1312
use cairo_vm::vm::vm_core::VirtualMachine;
14-
use cairo_vm::Felt252;
15-
use starknet_types_core::felt::Felt;
1613

1714
use crate::hints::bootloader_hints::{
1815
assert_is_composite_packed_output, assert_program_address,
@@ -92,14 +89,14 @@ impl HintProcessorLogic for MinimalBootloaderHintProcessor {
9289
vm: &mut VirtualMachine,
9390
exec_scopes: &mut ExecutionScopes,
9491
hint_data: &Box<dyn Any>,
95-
constants: &HashMap<String, Felt252>,
9692
) -> Result<(), HintError> {
9793
let hint_data = hint_data
9894
.downcast_ref::<HintProcessorData>()
9995
.ok_or(HintError::WrongHintData)?;
10096

10197
let ids_data = &hint_data.ids_data;
10298
let ap_tracking = &hint_data.ap_tracking;
99+
let constants = &hint_data.constants;
103100

104101
match hint_data.code.as_str() {
105102
BOOTLOADER_RESTORE_BOOTLOADER_OUTPUT => restore_bootloader_output(vm, exec_scopes),
@@ -274,7 +271,6 @@ impl HintProcessorLogic for MinimalTestProgramsHintProcessor {
274271
vm: &mut VirtualMachine,
275272
exec_scopes: &mut ExecutionScopes,
276273
hint_data: &Box<dyn Any>,
277-
_constants: &HashMap<String, Felt252>,
278274
) -> Result<(), HintError> {
279275
let hint_data = hint_data
280276
.downcast_ref::<HintProcessorData>()
@@ -363,7 +359,6 @@ pub struct BootloaderHintProcessor<'a> {
363359
builtin_hint_processor: BuiltinHintProcessor,
364360
test_programs_hint_processor: MinimalTestProgramsHintProcessor,
365361
pub subtask_cairo1_hint_processor_stack: Vec<Option<CairoHintProcessor<'a>>>,
366-
pub subtask_cairo0_constants_stack: Vec<Option<HashMap<String, Felt252>>>,
367362
}
368363

369364
impl Default for BootloaderHintProcessor<'_> {
@@ -379,7 +374,6 @@ impl<'a> BootloaderHintProcessor<'a> {
379374
builtin_hint_processor: BuiltinHintProcessor::new_empty(),
380375
subtask_cairo1_hint_processor_stack: Vec::new(),
381376
test_programs_hint_processor: MinimalTestProgramsHintProcessor::new(),
382-
subtask_cairo0_constants_stack: Vec::new(),
383377
}
384378
}
385379

@@ -390,20 +384,14 @@ impl<'a> BootloaderHintProcessor<'a> {
390384
}
391385

392386
/// Push new subtask state onto the stacks.
393-
/// Pass an optional constants map and an optional Cairo hint processor.
394-
pub fn spawn_subtask(
395-
&mut self,
396-
constants: Option<HashMap<String, Felt252>>,
397-
cairo_hint_processor: Option<CairoHintProcessor<'a>>,
398-
) {
399-
self.subtask_cairo0_constants_stack.push(constants);
387+
/// Pass an an optional Cairo hint processor.
388+
pub fn spawn_subtask(&mut self, cairo_hint_processor: Option<CairoHintProcessor<'a>>) {
400389
self.subtask_cairo1_hint_processor_stack
401390
.push(cairo_hint_processor);
402391
}
403392

404393
/// Pop the current subtask state off the stacks.
405394
pub fn despawn_subtask(&mut self) {
406-
self.subtask_cairo0_constants_stack.pop();
407395
self.subtask_cairo1_hint_processor_stack.pop();
408396
}
409397
}
@@ -414,7 +402,6 @@ impl HintProcessorLogic for BootloaderHintProcessor<'_> {
414402
_vm: &mut VirtualMachine,
415403
_exec_scopes: &mut ExecutionScopes,
416404
hint_data: &Box<dyn Any>,
417-
_constants: &HashMap<String, Felt>,
418405
) -> Result<(), HintError> {
419406
// This method will never be called, but must be defined for `HintProcessorLogic`.
420407

@@ -428,43 +415,25 @@ impl HintProcessorLogic for BootloaderHintProcessor<'_> {
428415
vm: &mut VirtualMachine,
429416
exec_scopes: &mut ExecutionScopes,
430417
hint_data: &Box<dyn Any>,
431-
constants: &HashMap<String, Felt>,
432418
) -> Result<HintExtension, HintError> {
433-
// Cascade through the internal hint processors until we find the hint implementation.
434-
let curr_consts = if self.subtask_cairo0_constants_stack.is_empty() {
435-
constants
436-
} else {
437-
self.subtask_cairo0_constants_stack
438-
.last()
439-
.and_then(|opt| opt.as_ref())
440-
.unwrap_or(constants)
441-
};
442-
443419
// In case the subtask_cairo_hint_processor is a Some variant, we try matching the hint
444420
// using it first, for efficiency, since it is assumed to only be Some if we're inside
445421
// an execution of a cairo1 program subtask.
446422
if let Some(Some(subtask_cairo_hint_processor)) =
447423
self.subtask_cairo1_hint_processor_stack.last_mut()
448424
{
449-
match subtask_cairo_hint_processor.execute_hint_extensive(
450-
vm,
451-
exec_scopes,
452-
hint_data,
453-
curr_consts,
454-
) {
425+
match subtask_cairo_hint_processor.execute_hint_extensive(vm, exec_scopes, hint_data) {
455426
Err(HintError::UnknownHint(_)) | Err(HintError::WrongHintData) => {}
456427
result => {
457428
return result;
458429
}
459430
}
460431
}
461432

462-
match self.bootloader_hint_processor.execute_hint_extensive(
463-
vm,
464-
exec_scopes,
465-
hint_data,
466-
curr_consts,
467-
) {
433+
match self
434+
.bootloader_hint_processor
435+
.execute_hint_extensive(vm, exec_scopes, hint_data)
436+
{
468437
Err(HintError::UnknownHint(_)) => {}
469438
result => {
470439
return result;
@@ -488,24 +457,18 @@ impl HintProcessorLogic for BootloaderHintProcessor<'_> {
488457
_ => {}
489458
}
490459

491-
match self.builtin_hint_processor.execute_hint_extensive(
492-
vm,
493-
exec_scopes,
494-
hint_data,
495-
curr_consts,
496-
) {
460+
match self
461+
.builtin_hint_processor
462+
.execute_hint_extensive(vm, exec_scopes, hint_data)
463+
{
497464
Err(HintError::UnknownHint(_)) => {}
498465
result => {
499466
return result;
500467
}
501468
}
502469

503-
self.test_programs_hint_processor.execute_hint_extensive(
504-
vm,
505-
exec_scopes,
506-
hint_data,
507-
curr_consts,
508-
)
470+
self.test_programs_hint_processor
471+
.execute_hint_extensive(vm, exec_scopes, hint_data)
509472
}
510473
}
511474

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub fn create_cairo1_program_task(
7777
.map(|n| BigInt::from_str(&n.to_string()).unwrap())
7878
.collect();
7979

80-
executable
80+
let entrypoint = executable
8181
.entrypoints
8282
.iter()
8383
.find(|e| matches!(e.kind, EntryPointKind::Bootloader))
@@ -87,8 +87,7 @@ pub fn create_cairo1_program_task(
8787
EntryPointKind::Bootloader
8888
))
8989
})?;
90-
let standalone = false;
91-
let (program, string_to_hint) = program_and_hints_from_executable(&executable, standalone)
90+
let (program, string_to_hint) = program_and_hints_from_executable(&executable, entrypoint)
9291
.map_err(|e| BootloaderTaskError::Cairo1(format!("Failed to parse executable: {e:?}")))?;
9392
let user_args = user_args_from_flags(user_args_file.as_ref(), &user_args_list)
9493
.map_err(|e| BootloaderTaskError::Cairo1(format!("Failed to parse user args: {e:?}")))?;

0 commit comments

Comments
 (0)