From 33c8e6f3f62dc902e0f676ee36060ec373cd88b4 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Fri, 5 Apr 2024 19:49:01 +0200 Subject: [PATCH] fix: make ci work (#308) --- Cargo.lock | 1 - crates/zksync/compiler/Cargo.toml | 1 - crates/zksync/compiler/src/zksolc/config.rs | 19 +++++++++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2e4b92ee..3900bc005 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4909,7 +4909,6 @@ dependencies = [ "dirs 5.0.1", "eyre", "foundry-compilers", - "futures 0.3.30", "globset", "reqwest", "semver 1.0.22", diff --git a/crates/zksync/compiler/Cargo.toml b/crates/zksync/compiler/Cargo.toml index 2c95d12a6..6c381fa86 100644 --- a/crates/zksync/compiler/Cargo.toml +++ b/crates/zksync/compiler/Cargo.toml @@ -29,7 +29,6 @@ ansi_term = "0.12.1" globset = "0.4" eyre = "0.6" semver = "1" -futures = "0.3" url = "2" anyhow = { version = "1.0.70" } dirs = { version = "5.0.0" } diff --git a/crates/zksync/compiler/src/zksolc/config.rs b/crates/zksync/compiler/src/zksolc/config.rs index 9bf15f181..fcc663424 100644 --- a/crates/zksync/compiler/src/zksolc/config.rs +++ b/crates/zksync/compiler/src/zksolc/config.rs @@ -338,8 +338,23 @@ impl ZkSolcConfigBuilder { let compiler_path = if let Some(compiler_path) = self.compiler_path { compiler_path } else if let Some(compiler_version) = self.compiler_version { - futures::executor::block_on(setup_zksolc_manager(compiler_version)) - .map_err(|err| format!("failed setting up zksolc: {err:?}"))? + // TODO: we are forcibly converting this method to sync since it can be called either + // within a sync (tests) or async (binary) context. We should fix that and stick to + // a single context + match tokio::runtime::Handle::try_current() { + Ok(handle) => std::thread::spawn(move || { + handle + .block_on(setup_zksolc_manager(compiler_version)) + .map_err(|err| err.to_string()) + }) + .join() + .map_err(|err| format!("{err:?}"))?, + Err(_) => tokio::runtime::Runtime::new() + .expect("failed starting runtime") + .block_on(setup_zksolc_manager(compiler_version)) + .map_err(|err| err.to_string()), + } + .map_err(|err| format!("failed setting up zksolc: {err:?}"))? } else { return Err("must specify either the compiler_version or compiler_path".to_string()); };