From 022878edbd8cf51cc97176d5a8b452bdc6ff87b3 Mon Sep 17 00:00:00 2001 From: Manuel Mauro Date: Wed, 23 Oct 2024 14:46:58 +0200 Subject: [PATCH 1/3] feat: build dependencies at zkstack build time --- zkstack_cli/crates/zkstack/Cargo.toml | 1 + zkstack_cli/crates/zkstack/build.rs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/zkstack_cli/crates/zkstack/Cargo.toml b/zkstack_cli/crates/zkstack/Cargo.toml index 93a78c751b14..85ab8081eaa4 100644 --- a/zkstack_cli/crates/zkstack/Cargo.toml +++ b/zkstack_cli/crates/zkstack/Cargo.toml @@ -55,4 +55,5 @@ anyhow.workspace = true clap_complete.workspace = true dirs.workspace = true ethers.workspace = true +xshell.workspace = true zksync_protobuf_build.workspace = true diff --git a/zkstack_cli/crates/zkstack/build.rs b/zkstack_cli/crates/zkstack/build.rs index bccf5bae89f9..4f9aabe28902 100644 --- a/zkstack_cli/crates/zkstack/build.rs +++ b/zkstack_cli/crates/zkstack/build.rs @@ -2,6 +2,7 @@ use std::path::{Path, PathBuf}; use anyhow::{anyhow, Context}; use ethers::contract::Abigen; +use xshell::{cmd, Shell}; const COMPLETION_DIR: &str = "completion"; @@ -14,6 +15,11 @@ fn main() -> anyhow::Result<()> { .write_to_file(outdir.join("consensus_registry_abi.rs")) .context("Failed to write ABI to file")?; + if let Err(e) = build_dependencies() { + println!("cargo:error=It was not possible to install projects dependencies"); + println!("cargo:error={}", e); + } + if let Err(e) = configure_shell_autocompletion() { println!("cargo:warning=It was not possible to install autocomplete scripts. Please generate them manually with `zkstack autocomplete`"); println!("cargo:error={}", e); @@ -130,3 +136,18 @@ impl ShellAutocomplete for clap_complete::Shell { Ok(()) } } + +fn build_dependencies() -> anyhow::Result<()> { + let shell = Shell::new()?; + let code_dir = Path::new("../"); + + // install yarn dependencies + let _dir_guard = shell.push_dir(code_dir); + cmd!(shell, "yarn install").run()?; + + // nuild contracts + let _dir_guard = shell.push_dir(code_dir.join("contracts")); + cmd!(shell, "yarn sc build").run()?; + + Ok(()) +} From 0142e2238120735cc5a8551b5c6774681ccbcf18 Mon Sep 17 00:00:00 2001 From: Manuel Mauro Date: Wed, 23 Oct 2024 15:43:20 +0200 Subject: [PATCH 2/3] fix: do not build contracts at build time --- zkstack_cli/crates/zkstack/build.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/zkstack_cli/crates/zkstack/build.rs b/zkstack_cli/crates/zkstack/build.rs index 4f9aabe28902..e52e952bf730 100644 --- a/zkstack_cli/crates/zkstack/build.rs +++ b/zkstack_cli/crates/zkstack/build.rs @@ -141,13 +141,9 @@ fn build_dependencies() -> anyhow::Result<()> { let shell = Shell::new()?; let code_dir = Path::new("../"); - // install yarn dependencies let _dir_guard = shell.push_dir(code_dir); - cmd!(shell, "yarn install").run()?; - // nuild contracts - let _dir_guard = shell.push_dir(code_dir.join("contracts")); - cmd!(shell, "yarn sc build").run()?; - - Ok(()) + cmd!(shell, "yarn install") + .run() + .context("Failed to install dependencies") } From 1ee279a0e33b4ecf02842d23cc7b16033dae473a Mon Sep 17 00:00:00 2001 From: Manuel Mauro Date: Wed, 23 Oct 2024 16:10:22 +0200 Subject: [PATCH 3/3] style: format code --- prover/crates/bin/prover_autoscaler/src/global/watcher.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/prover/crates/bin/prover_autoscaler/src/global/watcher.rs b/prover/crates/bin/prover_autoscaler/src/global/watcher.rs index 1b54d332ebb1..6e02c0fe2fdc 100644 --- a/prover/crates/bin/prover_autoscaler/src/global/watcher.rs +++ b/prover/crates/bin/prover_autoscaler/src/global/watcher.rs @@ -6,7 +6,6 @@ use reqwest::{ header::{HeaderMap, HeaderValue, CONTENT_TYPE}, Method, }; - use tokio::sync::Mutex; use url::Url; use zksync_utils::http_with_retries::send_request_with_retries;