Skip to content

Commit af6a8b7

Browse files
feat(starknet_os): remove the program from the OS runner inputs
1 parent 97825d7 commit af6a8b7

File tree

4 files changed

+10
-21
lines changed

4 files changed

+10
-21
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/starknet_committer_and_os_cli/src/os_cli/commands.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use std::fs;
2-
use std::path::Path;
3-
41
use apollo_starknet_os_program::OS_PROGRAM_BYTES;
52
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
63
use cairo_vm::types::layout_name::LayoutName;
@@ -17,9 +14,6 @@ use crate::shared_utils::read::{load_input, write_to_file};
1714
#[derive(Deserialize, Debug)]
1815
/// Input to the os runner.
1916
pub(crate) struct Input {
20-
// A path to a compiled program that its hint set should be a subset of those defined in
21-
// starknet-os.
22-
pub compiled_os_path: String,
2317
pub layout: LayoutName,
2418
pub os_hints: OsHints,
2519
}
@@ -62,14 +56,10 @@ pub fn validate_input(os_block_input: &[(OsBlockInput, CachedStateInput)]) {
6256
}
6357

6458
pub fn parse_and_run_os(input_path: String, output_path: String) {
65-
let Input { compiled_os_path, layout, os_hints } = load_input(input_path);
59+
let Input { layout, os_hints } = load_input(input_path);
6660
validate_input(&os_hints.os_input.os_block_and_state_input);
6761

68-
// Load the compiled_os from the compiled_os_path.
69-
let compiled_os =
70-
fs::read(Path::new(&compiled_os_path)).expect("Failed to read compiled_os file");
71-
72-
let output = run_os_stateless(&compiled_os, layout, os_hints)
62+
let output = run_os_stateless(layout, os_hints)
7363
.unwrap_or_else(|err| panic!("OS run failed. Error: {}", err));
7464
write_to_file(&output_path, &output);
7565
info!("OS program ran successfully.");

crates/starknet_os/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ testing = ["blockifier/testing"]
1717

1818
[dependencies]
1919
apollo_infra_utils.workspace = true
20+
apollo_starknet_os_program.workspace = true
2021
ark-bls12-381.workspace = true
2122
ark-ff.workspace = true
2223
ark-poly.workspace = true

crates/starknet_os/src/runner.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
use apollo_starknet_os_program::OS_PROGRAM;
12
use blockifier::state::state_api::StateReader;
23
use cairo_vm::cairo_run::CairoRunConfig;
34
use cairo_vm::types::layout_name::LayoutName;
4-
use cairo_vm::types::program::Program;
55
use cairo_vm::vm::errors::vm_exception::VmException;
66
use cairo_vm::vm::runners::cairo_runner::CairoRunner;
77

@@ -16,7 +16,6 @@ use crate::io::os_input::OsHints;
1616
use crate::io::os_output::{get_run_output, StarknetOsRunnerOutput};
1717

1818
pub fn run_os<S: StateReader>(
19-
compiled_os: &[u8],
2019
layout: LayoutName,
2120
os_hints: OsHints,
2221
state_readers: Vec<S>,
@@ -26,12 +25,9 @@ pub fn run_os<S: StateReader>(
2625
CairoRunConfig { layout, relocate_mem: true, trace_enabled: true, ..Default::default() };
2726
let allow_missing_builtins = cairo_run_config.allow_missing_builtins.unwrap_or(false);
2827

29-
// Load the Starknet OS Program.
30-
let os_program = Program::from_bytes(compiled_os, Some(cairo_run_config.entrypoint))?;
31-
3228
// Init cairo runner.
3329
let mut cairo_runner = CairoRunner::new(
34-
&os_program,
30+
&*OS_PROGRAM,
3531
cairo_run_config.layout,
3632
cairo_run_config.proof_mode,
3733
cairo_run_config.trace_enabled,
@@ -46,7 +42,9 @@ pub fn run_os<S: StateReader>(
4642

4743
// Create the hint processor.
4844
let mut snos_hint_processor = SnosHintProcessor::new(
49-
os_program,
45+
// TODO(Dori): remove the clone, the hint processor shouldn't need ownership of the
46+
// program.
47+
OS_PROGRAM.clone(),
5048
os_hints,
5149
state_readers,
5250
syscall_handler,
@@ -90,10 +88,9 @@ pub fn run_os<S: StateReader>(
9088
/// Run the OS with a "stateless" state reader - panics if the state is accessed for data that was
9189
/// not pre-loaded as part of the input.
9290
pub fn run_os_stateless(
93-
compiled_os: &[u8],
9491
layout: LayoutName,
9592
os_hints: OsHints,
9693
) -> Result<StarknetOsRunnerOutput, StarknetOsError> {
9794
let n_blocks = os_hints.os_input.os_block_and_state_input.len();
98-
run_os(compiled_os, layout, os_hints, vec![PanickingStateReader; n_blocks])
95+
run_os(layout, os_hints, vec![PanickingStateReader; n_blocks])
9996
}

0 commit comments

Comments
 (0)