diff --git a/zk_toolbox/Cargo.lock b/zk_toolbox/Cargo.lock index 279afaaf1b9b..77316756c26f 100644 --- a/zk_toolbox/Cargo.lock +++ b/zk_toolbox/Cargo.lock @@ -3278,7 +3278,7 @@ dependencies = [ "bytes", "http 1.1.0", "opentelemetry", - "reqwest 0.12.7", + "reqwest 0.12.8", ] [[package]] @@ -3295,7 +3295,7 @@ dependencies = [ "opentelemetry-proto", "opentelemetry_sdk", "prost 0.13.3", - "reqwest 0.12.7", + "reqwest 0.12.8", "thiserror", "tokio", "tonic", @@ -4078,9 +4078,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64 0.22.1", "bytes", @@ -6700,6 +6700,7 @@ dependencies = [ "lazy_static", "prost 0.12.6", "rand", + "reqwest 0.12.8", "secrecy", "serde", "serde_json", @@ -7024,7 +7025,7 @@ dependencies = [ "hex", "num", "once_cell", - "reqwest 0.12.7", + "reqwest 0.12.8", "serde", "serde_json", "thiserror", diff --git a/zk_toolbox/crates/common/src/lib.rs b/zk_toolbox/crates/common/src/lib.rs index c23ef9202261..b0fbdab0d1b0 100644 --- a/zk_toolbox/crates/common/src/lib.rs +++ b/zk_toolbox/crates/common/src/lib.rs @@ -18,7 +18,7 @@ pub mod yaml; pub use prerequisites::{ check_general_prerequisites, check_prerequisites, GCLOUD_PREREQUISITE, GPU_PREREQUISITES, - PROVER_CLI_PREREQUISITE, WGET_PREREQUISITE, + PROVER_CLI_PREREQUISITE, }; pub use prompt::{init_prompt_theme, Prompt, PromptConfirm, PromptSelect}; pub use term::{error, logger, spinner}; diff --git a/zk_toolbox/crates/common/src/prerequisites.rs b/zk_toolbox/crates/common/src/prerequisites.rs index 665096d8486e..7845249a1ed3 100644 --- a/zk_toolbox/crates/common/src/prerequisites.rs +++ b/zk_toolbox/crates/common/src/prerequisites.rs @@ -45,11 +45,6 @@ pub const GPU_PREREQUISITES: [Prerequisite; 3] = [ }, // CUDA GPU driver ]; -pub const WGET_PREREQUISITE: [Prerequisite; 1] = [Prerequisite { - name: "wget", - download_link: "https://www.gnu.org/software/wget/", -}]; - pub const GCLOUD_PREREQUISITE: [Prerequisite; 1] = [Prerequisite { name: "gcloud", download_link: "https://cloud.google.com/sdk/docs/install", diff --git a/zk_toolbox/crates/zk_inception/Cargo.toml b/zk_toolbox/crates/zk_inception/Cargo.toml index 5d42dadaed13..e6687bdd9815 100644 --- a/zk_toolbox/crates/zk_inception/Cargo.toml +++ b/zk_toolbox/crates/zk_inception/Cargo.toml @@ -39,6 +39,7 @@ zksync_protobuf.workspace = true zksync_protobuf_config.workspace = true prost.workspace = true secrecy.workspace = true +reqwest = "0.12.8" [dev-dependencies] rand.workspace = true diff --git a/zk_toolbox/crates/zk_inception/src/commands/contract_verifier/args/releases.rs b/zk_toolbox/crates/zk_inception/src/commands/contract_verifier/args/releases.rs index 2b2b4cf97b1b..ab169220f299 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/contract_verifier/args/releases.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/contract_verifier/args/releases.rs @@ -1,8 +1,8 @@ use std::str::FromStr; -use common::{cmd::Cmd, spinner::Spinner}; +use common::spinner::Spinner; use serde::Deserialize; -use xshell::{cmd, Shell}; +use xshell::Shell; use crate::messages::{MSG_INVALID_ARCH_ERR, MSG_NO_RELEASES_FOUND_ERR}; @@ -76,22 +76,19 @@ fn get_compatible_archs(asset_name: &str) -> anyhow::Result> { fn get_releases(shell: &Shell, repo: &str, arch: Arch) -> anyhow::Result> { if repo == "ethereum/solc-bin" { - return get_solc_releases(shell, arch); + return get_solc_releases(arch); } - let mut cmd = cmd!( - shell, - "curl -f https://api.github.com/repos/{repo}/releases" - ); + let client = reqwest::blocking::Client::new(); + let mut request = client + .get(format!("https://api.github.com/repos/{repo}/releases")) + .header("User-Agent", "zkstack"); if let Ok(token) = shell.var("GITHUB_TOKEN") { - cmd = cmd.args(vec![ - "-H".to_string(), - format!("Authorization: Bearer {}", token), - ]); + request = request.header("Authorization", format!("Bearer {}", token)); } - let response = String::from_utf8(Cmd::new(cmd).run_with_output()?.stdout)?; + let response = request.send()?.text()?; let releases: Vec = serde_json::from_str(&response)?; let mut versions = vec![]; @@ -115,7 +112,7 @@ fn get_releases(shell: &Shell, repo: &str, arch: Arch) -> anyhow::Result anyhow::Result> { +fn get_solc_releases(arch: Arch) -> anyhow::Result> { let (arch_str, compatible_archs) = match arch { Arch::LinuxAmd => ("linux-amd64", vec![Arch::LinuxAmd, Arch::LinuxArm]), Arch::LinuxArm => ("linux-amd64", vec![Arch::LinuxAmd, Arch::LinuxArm]), @@ -123,13 +120,15 @@ fn get_solc_releases(shell: &Shell, arch: Arch) -> anyhow::Result> Arch::MacosArm => ("macosx-amd64", vec![Arch::MacosAmd, Arch::MacosArm]), }; - let response: std::process::Output = Cmd::new(cmd!( - shell, - "curl https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/{arch_str}/list.json" - )) - .run_with_output()?; + let client = reqwest::blocking::Client::new(); + let response = client + .get(format!( + "https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/{arch_str}/list.json" + )) + .header("User-Agent", "zkstack") + .send()? + .text()?; - let response = String::from_utf8(response.stdout)?; let solc_list: SolcList = serde_json::from_str(&response)?; let mut versions = vec![]; diff --git a/zk_toolbox/crates/zk_inception/src/commands/contract_verifier/init.rs b/zk_toolbox/crates/zk_inception/src/commands/contract_verifier/init.rs index f376a0d36eca..b173ad9bbb7f 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/contract_verifier/init.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/contract_verifier/init.rs @@ -89,7 +89,8 @@ fn download_binary( let spinner = Spinner::new(&msg_downloading_binary_spinner(name, version)); Cmd::new(cmd!(shell, "mkdir -p {path}")).run()?; - Cmd::new(cmd!(shell, "wget {url} -O {binary_path}")).run()?; + let response = reqwest::blocking::get(url)?.bytes()?; + shell.write_file(binary_path.clone(), &response)?; Cmd::new(cmd!(shell, "chmod +x {binary_path}")).run()?; spinner.finish(); diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/compressor_keys.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/compressor_keys.rs index 703ecc18c4cb..a3d40c957281 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/compressor_keys.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/compressor_keys.rs @@ -1,7 +1,7 @@ use anyhow::Context; -use common::{check_prerequisites, cmd::Cmd, spinner::Spinner, WGET_PREREQUISITE}; +use common::spinner::Spinner; use config::{get_link_to_prover, EcosystemConfig, GeneralConfig}; -use xshell::{cmd, Shell}; +use xshell::Shell; use super::args::compressor_keys::CompressorKeysArgs; use crate::messages::{ @@ -35,7 +35,6 @@ pub(crate) fn download_compressor_key( general_config: &mut GeneralConfig, path: &str, ) -> anyhow::Result<()> { - check_prerequisites(shell, &WGET_PREREQUISITE, false); let spinner = Spinner::new(MSG_DOWNLOADING_SETUP_COMPRESSOR_KEY_SPINNER); let mut compressor_config: zksync_config::configs::FriProofCompressorConfig = general_config .proof_compressor_config @@ -47,14 +46,13 @@ pub(crate) fn download_compressor_key( let url = compressor_config.universal_setup_download_url; let path = std::path::Path::new(path); - let parent = path.parent().expect(MSG_SETUP_KEY_PATH_ERROR); - let file_name = path.file_name().expect(MSG_SETUP_KEY_PATH_ERROR); - Cmd::new(cmd!(shell, "wget {url} -P {parent}")).run()?; + let client = reqwest::blocking::Client::builder() + .timeout(std::time::Duration::from_secs(600)) + .build()?; - if file_name != "setup_2^24.key" { - Cmd::new(cmd!(shell, "mv {parent}/setup_2^24.key {path}")).run()?; - } + let response = client.get(url).send()?.bytes()?; + shell.write_file(path, &response)?; spinner.finish(); Ok(())