Skip to content

Commit

Permalink
feat(blockifier): auto-install toolchain for recompilation (#2594)
Browse files Browse the repository at this point in the history
Signed-off-by: Dori Medini <[email protected]>
  • Loading branch information
dorimedini-starkware authored Dec 10, 2024
1 parent 2eeae46 commit 16127eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions crates/blockifier/src/test_utils/cairo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use infra_utils::compile_time_cargo_manifest_dir;
use serde::{Deserialize, Serialize};
use tempfile::NamedTempFile;

use crate::test_utils::contracts::TagAndToolchain;

const CAIRO0_PIP_REQUIREMENTS_FILE: &str = "tests/requirements.txt";
const CAIRO1_REPO_RELATIVE_PATH_OVERRIDE_ENV_VAR: &str = "CAIRO1_REPO_RELATIVE_PATH";
const DEFAULT_CAIRO1_REPO_RELATIVE_PATH: &str = "../../../cairo";
Expand Down Expand Up @@ -228,15 +230,24 @@ fn get_tag_and_repo_file_path(git_tag_override: Option<String>) -> (String, Path
(tag, cairo_repo_path)
}

pub fn prepare_group_tag_compiler_deps(git_tag_override: Option<String>) {
let (tag, cairo_repo_path) = get_tag_and_repo_file_path(git_tag_override);
pub fn prepare_group_tag_compiler_deps(tag_and_toolchain: &TagAndToolchain) {
let (optional_tag, optional_toolchain) = tag_and_toolchain;

// Checkout the required version in the compiler repo.
let (tag, cairo_repo_path) = get_tag_and_repo_file_path(optional_tag.clone());
run_and_verify_output(Command::new("git").args([
"-C",
cairo_repo_path.to_str().unwrap(),
"checkout",
&tag,
]));

// Install the toolchain, if specified.
if let Some(toolchain) = optional_toolchain {
run_and_verify_output(
Command::new("rustup").args(["install", &format!("nightly-{toolchain}")]),
);
}
}

fn verify_cairo1_compiler_deps(git_tag_override: Option<String>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn verify_feature_contracts_compatibility(fix: bool, cairo_version: CairoVersion
for (tag_and_tool_chain, feature_contracts) in
FeatureContract::cairo1_feature_contracts_by_tag()
{
prepare_group_tag_compiler_deps(tag_and_tool_chain.0.clone());
prepare_group_tag_compiler_deps(&tag_and_tool_chain);
// TODO(Meshi 01/01/2025) Make this loop concurrent
for contract in feature_contracts
.into_iter()
Expand Down

0 comments on commit 16127eb

Please sign in to comment.