|
1 | 1 | use bincode::enc::write::Writer; |
| 2 | +use cairo1_run::error::Error; |
| 3 | +use cairo1_run::{cairo_run_program, Cairo1RunConfig, FuncArg}; |
2 | 4 | use cairo_lang_compiler::{compile_cairo_project_at_path, CompilerConfig}; |
3 | | -use cairo_lang_sierra::{ids::ConcreteTypeId, program_registry::ProgramRegistryError}; |
4 | | -use cairo_lang_sierra_to_casm::{compiler::CompilationError, metadata::MetadataError}; |
5 | | -use cairo_run::Cairo1RunConfig; |
6 | 5 | use cairo_vm::{ |
7 | | - air_public_input::PublicInputError, |
8 | | - cairo_run::EncodeTraceError, |
9 | | - types::{errors::program_errors::ProgramError, layout_name::LayoutName}, |
10 | | - vm::errors::{ |
11 | | - memory_errors::MemoryError, runner_errors::RunnerError, trace_errors::TraceError, |
12 | | - vm_errors::VirtualMachineError, |
13 | | - }, |
14 | | - Felt252, |
| 6 | + air_public_input::PublicInputError, types::layout_name::LayoutName, |
| 7 | + vm::errors::trace_errors::TraceError, Felt252, |
15 | 8 | }; |
16 | 9 | use clap::{Parser, ValueHint}; |
17 | 10 | use itertools::Itertools; |
18 | 11 | use std::{ |
19 | 12 | io::{self, Write}, |
20 | 13 | path::PathBuf, |
21 | 14 | }; |
22 | | -use thiserror::Error; |
23 | | - |
24 | | -pub mod cairo_run; |
25 | 15 |
|
26 | 16 | #[derive(Parser, Debug)] |
27 | 17 | #[clap(author, version, about, long_about = None)] |
@@ -65,12 +55,6 @@ struct Args { |
65 | 55 | append_return_values: bool, |
66 | 56 | } |
67 | 57 |
|
68 | | -#[derive(Debug, Clone)] |
69 | | -pub enum FuncArg { |
70 | | - Array(Vec<Felt252>), |
71 | | - Single(Felt252), |
72 | | -} |
73 | | - |
74 | 58 | #[derive(Debug, Clone, Default)] |
75 | 59 | struct FuncArgs(Vec<FuncArg>); |
76 | 60 |
|
@@ -109,55 +93,6 @@ fn process_args(value: &str) -> Result<FuncArgs, String> { |
109 | 93 | Ok(FuncArgs(args)) |
110 | 94 | } |
111 | 95 |
|
112 | | -#[derive(Debug, Error)] |
113 | | -pub enum Error { |
114 | | - #[error("Invalid arguments")] |
115 | | - Cli(#[from] clap::Error), |
116 | | - #[error("Failed to interact with the file system")] |
117 | | - IO(#[from] std::io::Error), |
118 | | - #[error(transparent)] |
119 | | - EncodeTrace(#[from] EncodeTraceError), |
120 | | - #[error(transparent)] |
121 | | - VirtualMachine(#[from] VirtualMachineError), |
122 | | - #[error(transparent)] |
123 | | - Trace(#[from] TraceError), |
124 | | - #[error(transparent)] |
125 | | - PublicInput(#[from] PublicInputError), |
126 | | - #[error(transparent)] |
127 | | - Runner(#[from] RunnerError), |
128 | | - #[error(transparent)] |
129 | | - ProgramRegistry(#[from] Box<ProgramRegistryError>), |
130 | | - #[error(transparent)] |
131 | | - Compilation(#[from] Box<CompilationError>), |
132 | | - #[error("Failed to compile to sierra:\n {0}")] |
133 | | - SierraCompilation(String), |
134 | | - #[error(transparent)] |
135 | | - Metadata(#[from] MetadataError), |
136 | | - #[error(transparent)] |
137 | | - Program(#[from] ProgramError), |
138 | | - #[error(transparent)] |
139 | | - Memory(#[from] MemoryError), |
140 | | - #[error("Program panicked with {0:?}")] |
141 | | - RunPanic(Vec<Felt252>), |
142 | | - #[error("Function signature has no return types")] |
143 | | - NoRetTypesInSignature, |
144 | | - #[error("No size for concrete type id: {0}")] |
145 | | - NoTypeSizeForId(ConcreteTypeId), |
146 | | - #[error("Concrete type id has no debug name: {0}")] |
147 | | - TypeIdNoDebugName(ConcreteTypeId), |
148 | | - #[error("No info in sierra program registry for concrete type id: {0}")] |
149 | | - NoInfoForType(ConcreteTypeId), |
150 | | - #[error("Failed to extract return values from VM")] |
151 | | - FailedToExtractReturnValues, |
152 | | - #[error("Function expects arguments of size {expected} and received {actual} instead.")] |
153 | | - ArgumentsSizeMismatch { expected: i16, actual: i16 }, |
154 | | - #[error("Function param {param_index} only partially contains argument {arg_index}.")] |
155 | | - ArgumentUnaligned { |
156 | | - param_index: usize, |
157 | | - arg_index: usize, |
158 | | - }, |
159 | | -} |
160 | | - |
161 | 96 | pub struct FileWriter { |
162 | 97 | buf_writer: io::BufWriter<std::fs::File>, |
163 | 98 | bytes_written: usize, |
@@ -220,8 +155,7 @@ fn run(args: impl Iterator<Item = String>) -> Result<Option<String>, Error> { |
220 | 155 | } |
221 | 156 | }; |
222 | 157 |
|
223 | | - let (runner, vm, _, serialized_output) = |
224 | | - cairo_run::cairo_run_program(&sierra_program, cairo_run_config)?; |
| 158 | + let (runner, vm, _, serialized_output) = cairo_run_program(&sierra_program, cairo_run_config)?; |
225 | 159 |
|
226 | 160 | if let Some(file_path) = args.air_public_input { |
227 | 161 | let json = runner.get_air_public_input(&vm)?.serialize_json()?; |
|
0 commit comments