Skip to content

Commit 31464c4

Browse files
feat(starknet_committer_and_os_cli): add command to dump OS source files
1 parent f3d4ae2 commit 31464c4

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

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/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ tempfile.workspace = true
1818

1919
# TODO(Amos): Add `testing` feature and move Python test dependencies under it.
2020
[dependencies]
21+
# The 'dump_source_files' feature should be moved under `testing` feature, when it exists.
22+
apollo_starknet_os_program = { workspace = true, features = ["dump_source_files"] }
2123
cairo-lang-starknet-classes.workspace = true
2224
cairo-vm.workspace = true
2325
# Should be moved under `testing` feature, when it exists.
@@ -34,7 +36,7 @@ serde_repr.workspace = true
3436
starknet-types-core.workspace = true
3537
starknet_api.workspace = true
3638
starknet_committer.workspace = true
37-
# Should be moved under `testing` feature, when it exists.
39+
# The 'testing' feature should be moved under `testing` feature, when it exists.
3840
starknet_os = { workspace = true, features = ["deserialize", "testing"] }
3941
starknet_patricia = { workspace = true, features = ["testing"] }
4042
starknet_patricia_storage.workspace = true

crates/starknet_committer_and_os_cli/src/os_cli/commands.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::fs;
22
use std::path::Path;
33

4+
use apollo_starknet_os_program::CAIRO_FILES_MAP;
45
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
56
use cairo_vm::types::layout_name::LayoutName;
67
use cairo_vm::vm::runners::cairo_pie::CairoPie;
@@ -101,3 +102,7 @@ pub(crate) fn serialize_os_runner_output(
101102
.write_zip_file(Path::new(&cairo_pie_zip_path), merge_extra_segments)
102103
.unwrap_or_else(|err| panic!("Failed to write cairo pie. Error: {}", err));
103104
}
105+
106+
pub(crate) fn dump_source_files(output_path: String) {
107+
write_to_file(&output_path, &*CAIRO_FILES_MAP);
108+
}

crates/starknet_committer_and_os_cli/src/os_cli/run_os_cli.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tracing::level_filters::LevelFilter;
99
use tracing_subscriber::reload::Handle;
1010
use tracing_subscriber::Registry;
1111

12-
use crate::os_cli::commands::parse_and_run_os;
12+
use crate::os_cli::commands::{dump_source_files, parse_and_run_os};
1313
use crate::os_cli::tests::python_tests::OsPythonTestRunner;
1414
use crate::shared_utils::types::{run_python_test, IoArgs, PythonTestArg};
1515

@@ -21,6 +21,11 @@ pub struct OsCliCommand {
2121

2222
#[derive(Debug, Subcommand)]
2323
enum Command {
24+
DumpSourceFiles {
25+
/// File path to output.
26+
#[clap(long, short = 'o')]
27+
output_path: String,
28+
},
2429
PythonTest(PythonTestArg),
2530
RunOsStateless {
2631
#[clap(flatten)]
@@ -34,6 +39,7 @@ pub async fn run_os_cli(
3439
) {
3540
info!("Starting starknet-os-cli with command: \n{:?}", os_command);
3641
match os_command.command {
42+
Command::DumpSourceFiles { output_path } => dump_source_files(output_path),
3743
Command::PythonTest(python_test_arg) => {
3844
run_python_test::<OsPythonTestRunner>(python_test_arg).await;
3945
}

0 commit comments

Comments
 (0)