-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use the starknet-sierra-compile downloaded binary to compile #598
feat: use the starknet-sierra-compile downloaded binary to compile #598
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @ArniStarkware and the rest of your teammates on Graphite |
f4b5edf
to
63b3876
Compare
4bc38ea
to
610aec6
Compare
Benchmark movements: |
Benchmark movements: |
63b3876
to
5d4c96b
Compare
610aec6
to
d14d3de
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #598 +/- ##
=======================================
Coverage 76.62% 76.63%
=======================================
Files 351 353 +2
Lines 37223 37273 +50
Branches 37223 37273 +50
=======================================
+ Hits 28522 28564 +42
- Misses 6388 6390 +2
- Partials 2313 2319 +6 ☔ View full report in Codecov by Sentry. |
5d4c96b
to
4b34427
Compare
d14d3de
to
17e0fd5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @ArniStarkware)
crates/starknet_sierra_compile/src/command_line_compiler.rs
line 37 at r1 (raw file):
let mut temp_file = NamedTempFile::new()?; temp_file.write_all(serialized_contract_class.as_bytes())?; let temp_file_path = temp_file.path().to_str().ok_or(
Shouldn't it be before write_all
?
Code quote:
let temp_file_path = temp_file.path()
crates/starknet_sierra_compile/src/command_line_compiler.rs
line 38 at r1 (raw file):
temp_file.write_all(serialized_contract_class.as_bytes())?; let temp_file_path = temp_file.path().to_str().ok_or( CompilationUtilError::CompilationError("Failed to get temporary file path".to_owned()),
UnexpectedError?
Code quote:
CompilationUtilError::CompilationError
crates/starknet_sierra_compile/src/command_line_compiler.rs
line 74 at r1 (raw file):
.nth(3) .expect("Failed to navigate up three levels from OUT_DIR") .join("cairo");
Consider moving to a common location, as it is used in the build.rs as well.
Code quote:
let out_dir = env::var("OUT_DIR").expect("Failed to get the OUT_DIR environment variable");
let out_dir = Path::new(&out_dir);
// Navigate up the directory tree until reaching the 'target' directory
let target_dir = out_dir
.ancestors()
.nth(3)
.expect("Failed to navigate up three levels from OUT_DIR")
.join("cairo");
crates/starknet_sierra_compile/src/compile_test.rs
line 26 at r1 (raw file):
COMMAND_LINE_COMPILER .get_or_init(|| CommandLineCompiler::new(SIERRA_TO_CASM_COMPILATION_CONFIG)) }
Please make these a simple functions.
Seems to me like an overkill to use OneLock in the test.
Code quote:
const CAIRO_LANG_COMPILER: CairoLangSierraToCasmCompiler =
CairoLangSierraToCasmCompiler { config: SIERRA_TO_CASM_COMPILATION_CONFIG };
static COMMAND_LINE_COMPILER: OnceLock<CommandLineCompiler> = OnceLock::new();
fn commnad_line_compiler() -> &'static CommandLineCompiler {
COMMAND_LINE_COMPILER
.get_or_init(|| CommandLineCompiler::new(SIERRA_TO_CASM_COMPILATION_CONFIG))
}
4b34427
to
3635605
Compare
d98265e
to
e3e4d61
Compare
Benchmark movements: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 3 of 8 files reviewed, 4 unresolved discussions (waiting on @dafnamatsry)
crates/starknet_sierra_compile/src/command_line_compiler.rs
line 37 at r1 (raw file):
Previously, dafnamatsry wrote…
Shouldn't it be before
write_all
?
Tried replacing the line: got:
error[E0502]: cannot borrow `temp_file` as mutable because it is also borrowed as immutable
Does not seem critical IIUC.
crates/starknet_sierra_compile/src/command_line_compiler.rs
line 38 at r1 (raw file):
Previously, dafnamatsry wrote…
UnexpectedError?
Done.
crates/starknet_sierra_compile/src/command_line_compiler.rs
line 74 at r1 (raw file):
Previously, dafnamatsry wrote…
Consider moving to a common location, as it is used in the build.rs as well.
Done.
crates/starknet_sierra_compile/src/compile_test.rs
line 26 at r1 (raw file):
Previously, dafnamatsry wrote…
Please make these a simple functions.
Seems to me like an overkill to use OneLock in the test.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ArniStarkware)
crates/starknet_sierra_compile/src/build_utils.rs
line 3 at r2 (raw file):
/// Get the crate's `OUT_DIR` and navigates up to reach the `target/BUILD_FLAVOR` directory. /// This directory is shared accross all crates in this project. pub fn get_traget_build_flavor_dir() -> &'static std::path::Path {
Why static?
I think the caller should be responsible of the lifetime of this.
Is it possible to return std::path::Path, and remove the Box::leak?
Code quote:
&'static std::path::Path {
crates/starknet_sierra_compile/src/compile_test.rs
line 19 at r2 (raw file):
const CAIRO_LANG_COMPILER: CairoLangSierraToCasmCompiler = CairoLangSierraToCasmCompiler { config: SIERRA_TO_CASM_COMPILATION_CONFIG };
Just for consistency, consider changing this to a function as well (like the command_line_compiler
)
Code quote:
const CAIRO_LANG_COMPILER: CairoLangSierraToCasmCompiler =
CairoLangSierraToCasmCompiler { config: SIERRA_TO_CASM_COMPILATION_CONFIG };
07e3032
to
0b658d5
Compare
add todo - add Ulimits. Code quote: // Set the parameters for the compile process.
let mut command = Command::new(self.path_to_starknet_sierra_compile_binary);
command.args([
temp_file_path,
"--add-pythonic-hints",
"--max-bytecode-size",
&self.config.max_bytecode_size.to_string(),
]); |
e3e4d61
to
b0708b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 8 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry)
crates/starknet_sierra_compile/src/build_utils.rs
line 3 at r2 (raw file):
Previously, dafnamatsry wrote…
Why static?
I think the caller should be responsible of the lifetime of this.Is it possible to return std::path::Path, and remove the Box::leak?
Done.
crates/starknet_sierra_compile/src/compile_test.rs
line 19 at r2 (raw file):
Previously, dafnamatsry wrote…
Just for consistency, consider changing this to a function as well (like the
command_line_compiler
)
Done.
Benchmark movements: |
0b658d5
to
55812ae
Compare
b0708b1
to
052c771
Compare
Benchmark movements: |
55812ae
to
0911243
Compare
052c771
to
6eb922f
Compare
Benchmark movements: |
0911243
to
68b8010
Compare
6eb922f
to
4621f8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r3, 4 of 4 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ArniStarkware)
68b8010
to
ee1cb43
Compare
4621f8f
to
1ee6ade
Compare
Benchmark movements: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r5, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ArniStarkware)
Merge activity
|
1ee6ade
to
f3ecaa2
Compare
Benchmark movements: |
This pr stack is for taking the sierra binary instead of compiling it, right? |
If this library gets compiled into a binary won't this always fail since OUT_DIR is only set in the context of a cargo command? Is this an issue? |
Why both of these errors are wrapped into the same error? Code quote: impl From<serde_json::Error> for CompilationUtilError { |
Previously, shaharsamocha7 wrote…
This PR stack uses the Why do we want that:
Did that answer the question? Because I am afraid we do not use the same terminology (What does "sierra binary" mean?
|
Previously, shaharsamocha7 wrote…
I am not sure. |
Previously, shaharsamocha7 wrote…
These errors should never happen (Thus, they are converted into UnexpectedError). I do not intend to handle these errors differently than other My motivation was "each error type should be mapped to some handle of this error". |
This change is