Skip to content

Commit

Permalink
Merge branch 'replay' into replay-w-trace-dump
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGCalderon committed Jan 17, 2025
2 parents d46d2f4 + 9d8c01e commit c01254e
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 198 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ byteorder = "1.4.3"
bytes = "1"
cached = "0.44.0"
cairo-felt = "0.9.1"
cairo-lang-casm = "2.9.2"
cairo-lang-runner = "2.9.2"
cairo-lang-sierra = "=2.9.2"
cairo-lang-sierra-to-casm = "2.9.2"
cairo-lang-starknet-classes = "2.9.2"
cairo-lang-utils = "2.9.2"
cairo-lang-casm = "2.10.0-rc.0"
cairo-lang-runner = "2.10.0-rc.0"
cairo-lang-sierra = "=2.10.0-rc.0"
cairo-lang-sierra-to-casm = "2.10.0-rc.0"
cairo-lang-starknet-classes = "2.10.0-rc.0"
cairo-lang-utils = "2.10.0-rc.0"
# Important: when updated, make sure to update the cairo-native submodule as well.
cairo-native = { path = "../cairo_native" }
sierra-emu = { path = "../sierra-emu" }
Expand Down
1 change: 1 addition & 0 deletions crates/blockifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ native_blockifier = []
reexecution = ["transaction_serde"]
testing = ["rand", "rstest", "starknet_api/testing"]
transaction_serde = []
profiling = []

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
69 changes: 0 additions & 69 deletions crates/blockifier/build.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/blockifier/cairo_native

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn execute_entry_point_call(
// adjusting the stack size.
// This also limits multi-threading, since each thread has its own stack.
// TODO(Aviv/Yonatan): add these numbers to overridable VC.
let stack_size_red_zone = 160 * 1024 * 1024;
let stack_size_red_zone = if !cfg!(feature = "profiling") { 160 * 1024 * 1024 } else { 0 };
let target_stack_size = stack_size_red_zone + 10 * 1024 * 1024;
// Use `maybe_grow` and not `grow` for performance, since in happy flows, only the main call
// should trigger the growth.
Expand Down
118 changes: 0 additions & 118 deletions crates/starknet_sierra_compile/build.rs
Original file line number Diff line number Diff line change
@@ -1,119 +1,8 @@
use std::process::Command;

use tempfile::TempDir;

include!("src/constants.rs");
include!("src/paths.rs");

fn main() {
println!("cargo:rerun-if-changed=../../Cargo.lock");
println!("cargo:rerun-if-changed=build.rs");

set_run_time_out_dir_env_var();
install_starknet_sierra_compile();
#[cfg(feature = "cairo_native")]
install_starknet_native_compile();
}

const REQUIRED_CAIRO_LANG_VERSION: &str = "2.7.1";
#[cfg(feature = "cairo_native")]
const REQUIRED_CAIRO_NATIVE_VERSION: &str = "0.2.4";

/// Downloads the Cairo crate from StarkWare's release page and extracts its contents into the
/// `target` directory. This crate includes the `starknet-sierra-compile` binary, which is used to
/// compile Sierra to Casm. The binary is executed as a subprocess whenever Sierra compilation is
/// required.
fn install_starknet_sierra_compile() {
let binary_name = CAIRO_LANG_BINARY_NAME;
let required_version = REQUIRED_CAIRO_LANG_VERSION;

let cargo_install_args = &[binary_name, "--version", required_version];
install_compiler_binary(binary_name, required_version, cargo_install_args);
}

/// Installs the `starknet-native-compile` crate from the current repository and moves the binary
/// to the shared executables folder. This crate includes the `starknet-native-compile` binary,
/// which is used to compile Sierra to 0x86. The binary is executed as a subprocess whenever Sierra
/// compilation is required.
#[cfg(feature = "cairo_native")]
fn install_starknet_native_compile() {
let binary_name = CAIRO_NATIVE_BINARY_NAME;
let required_version = REQUIRED_CAIRO_NATIVE_VERSION;

let repo_root_dir =
infra_utils::path::project_path().expect("Should be able to get the project path");

// Set the runtime library path. This is required for Cairo native compilation.
let runtime_library_path = repo_root_dir
.join("crates/blockifier/cairo_native/target/release/libcairo_native_runtime.a");
println!("cargo:rustc-env=CAIRO_NATIVE_RUNTIME_LIBRARY={}", runtime_library_path.display());
println!("cargo:rerun-if-env-changed=CAIRO_NATIVE_RUNTIME_LIBRARY");

let starknet_native_compile_crate_path = repo_root_dir.join("crates/bin").join(binary_name);
let starknet_native_compile_crate_path_str = starknet_native_compile_crate_path
.to_str()
.expect("Failed to convert the crate path to str");
println!("cargo:rerun-if-changed={}", starknet_native_compile_crate_path_str);

let cargo_install_args = &["--path", starknet_native_compile_crate_path_str];
install_compiler_binary(binary_name, required_version, cargo_install_args);
}

fn install_compiler_binary(binary_name: &str, required_version: &str, cargo_install_args: &[&str]) {
let binary_path = binary_path(out_dir(), binary_name);
println!("cargo:rerun-if-changed={}", binary_path.to_str().unwrap());

match Command::new(&binary_path).args(["--version"]).output() {
Ok(binary_version) => {
let binary_version = String::from_utf8(binary_version.stdout)
.expect("Failed to convert the binary version to a string.");
if binary_version.contains(required_version) {
println!("The {binary_name} binary is up to date.");
return;
} else {
println!(
"The {binary_name} binary is not up to date. Installing the required version."
);
std::fs::remove_file(&binary_path).expect("Failed to remove the old binary.");
}
}
Err(_) => {
println!("The {binary_name} binary is not installed. Installing the required version.");
}
}

let temp_cargo_path = TempDir::new().expect("Failed to create a temporary directory.");
let post_install_file_path = temp_cargo_path.path().join("bin").join(binary_name);

let install_command_status = Command::new("cargo")
.args([
"install",
"--root",
temp_cargo_path.path().to_str().expect("Failed to convert cargo_path to str"),
])
.args(cargo_install_args)
.status()
.unwrap_or_else(|_| panic!("Failed to install {binary_name}"));

if !install_command_status.success() {
panic!("Failed to install {}", binary_name);
}

// Move the '{binary_name}' executable to a shared location.
std::fs::create_dir_all(shared_folder_dir(out_dir()))
.expect("Failed to create shared executables folder");
let move_command_status = Command::new("mv")
.args([post_install_file_path.as_os_str(), binary_path.as_os_str()])
.status()
.expect("Failed to perform mv command.");

if !move_command_status.success() {
panic!("Failed to move the {} binary to the shared folder.", binary_name);
}

std::fs::remove_dir_all(temp_cargo_path).expect("Failed to remove the cargo directory.");

println!("Successfully set executable file: {:?}", binary_path.display());
}

// Sets the `RUNTIME_ACCESSIBLE_OUT_DIR` environment variable to the `OUT_DIR` value, which will be
Expand All @@ -122,10 +11,3 @@ fn set_run_time_out_dir_env_var() {
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR is not set");
println!("cargo:rustc-env=RUNTIME_ACCESSIBLE_OUT_DIR={}", out_dir);
}

// Returns the OUT_DIR. This function is only operable at build time.
fn out_dir() -> std::path::PathBuf {
std::env::var("OUT_DIR")
.expect("Failed to get the build time OUT_DIR environment variable")
.into()
}

0 comments on commit c01254e

Please sign in to comment.