Skip to content

Commit dca637c

Browse files
feat(starknet_os): remove the program from the OS runner inputs
1 parent 8558852 commit dca637c

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
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 & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::fs;
21
use std::path::Path;
32

43
use apollo_starknet_os_program::test_programs::ALIASES_TEST_BYTES;
@@ -26,9 +25,6 @@ use crate::shared_utils::read::{load_input, write_to_file};
2625
#[derive(Deserialize, Debug)]
2726
/// Input to the os runner.
2827
pub(crate) struct Input {
29-
// A path to a compiled program that its hint set should be a subset of those defined in
30-
// starknet-os.
31-
pub compiled_os_path: String,
3228
pub layout: LayoutName,
3329
pub os_hints: OsHints,
3430
pub cairo_pie_zip_path: String,
@@ -77,15 +73,11 @@ pub fn validate_input(os_input: &StarknetOsInput) {
7773
}
7874

7975
pub fn parse_and_run_os(input_path: String, output_path: String) {
80-
let Input { compiled_os_path, layout, os_hints, cairo_pie_zip_path } = load_input(input_path);
76+
let Input { layout, os_hints, cairo_pie_zip_path } = load_input(input_path);
8177
validate_input(&os_hints.os_input);
8278

83-
// Load the compiled_os from the compiled_os_path.
84-
let compiled_os =
85-
fs::read(Path::new(&compiled_os_path)).expect("Failed to read compiled_os file");
86-
8779
let StarknetOsRunnerOutput { os_output, cairo_pie, unused_hints } =
88-
run_os_stateless(&compiled_os, layout, os_hints)
80+
run_os_stateless(layout, os_hints)
8981
.unwrap_or_else(|err| panic!("OS run failed. Error: {}", err));
9082
serialize_os_runner_output(
9183
&OsCliOutput { os_output, unused_hints },

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", "starknet_patricia/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/hints/enum_definition.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,7 @@ segments.write_arg(ids.sha256_ptr_end, padding)"#}
10811081
indoc! {r#"
10821082
if execution_helper.debug_mode:
10831083
# Validate the predicted gas cost.
1084+
# TODO(Yoni, 1/1/2025): remove this check once Cairo 0 is not supported.
10841085
actual = ids.remaining_gas - ids.entry_point_return_values.gas_builtin
10851086
predicted = execution_helper.call_info.gas_consumed
10861087
if execution_helper.call_info.tracked_resource.is_sierra_gas():
@@ -1408,6 +1409,7 @@ segments.write_arg(ids.sha256_ptr_end, padding)"#}
14081409
onchain_data_start = ids.da_start
14091410
onchain_data_size = ids.output_ptr - onchain_data_start
14101411
1412+
# TODO(Yoni,20/07/2023): Take from input.
14111413
max_page_size = 3800
14121414
n_pages = div_ceil(onchain_data_size, max_page_size)
14131415
for i in range(n_pages):

crates/starknet_os/src/runner.rs

Lines changed: 4 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

@@ -17,7 +17,6 @@ use crate::io::os_output::{get_run_output, StarknetOsRunnerOutput};
1717

1818
#[allow(clippy::result_large_err)]
1919
pub fn run_os<S: StateReader>(
20-
compiled_os: &[u8],
2120
layout: LayoutName,
2221
OsHints {
2322
os_hints_config,
@@ -36,12 +35,9 @@ pub fn run_os<S: StateReader>(
3635
CairoRunConfig { layout, relocate_mem: true, trace_enabled: true, ..Default::default() };
3736
let allow_missing_builtins = cairo_run_config.allow_missing_builtins.unwrap_or(false);
3837

39-
// Load the Starknet OS Program.
40-
let os_program = Program::from_bytes(compiled_os, Some(cairo_run_config.entrypoint))?;
41-
4238
// Init cairo runner.
4339
let mut cairo_runner = CairoRunner::new(
44-
&os_program,
40+
&OS_PROGRAM,
4541
cairo_run_config.layout,
4642
cairo_run_config.dynamic_layout_params,
4743
cairo_run_config.proof_mode,
@@ -58,7 +54,7 @@ pub fn run_os<S: StateReader>(
5854

5955
// Create the hint processor.
6056
let mut snos_hint_processor = SnosHintProcessor::new(
61-
&os_program,
57+
&OS_PROGRAM,
6258
os_hints_config,
6359
os_block_inputs.iter().collect(),
6460
cached_state_inputs,
@@ -112,10 +108,9 @@ pub fn run_os<S: StateReader>(
112108
/// not pre-loaded as part of the input.
113109
#[allow(clippy::result_large_err)]
114110
pub fn run_os_stateless(
115-
compiled_os: &[u8],
116111
layout: LayoutName,
117112
os_hints: OsHints,
118113
) -> Result<StarknetOsRunnerOutput, StarknetOsError> {
119114
let n_blocks = os_hints.os_input.os_block_inputs.len();
120-
run_os(compiled_os, layout, os_hints, vec![PanickingStateReader; n_blocks])
115+
run_os(layout, os_hints, vec![PanickingStateReader; n_blocks])
121116
}

0 commit comments

Comments
 (0)