diff --git a/README.md b/README.md index 65e5a7967..9bc56ac88 100644 --- a/README.md +++ b/README.md @@ -645,3 +645,12 @@ Make sure that: If you get errors like `(code: -32601, message: Method not found, data: None)` - you are probably using a `send` method instead of `zksend`. +### 'Could not get solc: Unknown version provided', 'checksum not found' + +These errors might show up on the Mac with ARM chip (M1, M2) - due to the fact that most recent solc compilers are not auto-downloaded there. + +There are 2 workarounds: + - use the older compiler - by adding `--use 0.8.17` flag to your zk-build command + - download the compiler manually - and then use `--offline` mode (you can download the compiler into ~/.svm/VERSION/solc-VERSION -- for example ~/.svm/0.8.20/solc-0.8.20 ) + +You can get the lastest compiler version for MacOs AARCH here: https://github.com/ethers-rs/solc-builds/tree/master/macosx/aarch64 diff --git a/cli/src/cmd/forge/zk_build.rs b/cli/src/cmd/forge/zk_build.rs index cb718d583..9a26e845a 100644 --- a/cli/src/cmd/forge/zk_build.rs +++ b/cli/src/cmd/forge/zk_build.rs @@ -160,7 +160,7 @@ impl ZkBuildArgs { } if !zksolc_manager.exists() { - println!("Downloading zksolc compiler"); + println!("Downloading zksolc compiler from {:?}", zksolc_manager.get_full_download_url().unwrap().to_string()); zksolc_manager .download() .map_err(|err| eyre::eyre!("Failed to download the file: {}", err))?; diff --git a/cli/src/cmd/forge/zksolc_manager.rs b/cli/src/cmd/forge/zksolc_manager.rs index f8b237c81..b8070f5bb 100644 --- a/cli/src/cmd/forge/zksolc_manager.rs +++ b/cli/src/cmd/forge/zksolc_manager.rs @@ -21,7 +21,7 @@ /// This module abstracts the details of managing the zksolc compiler, making it easier for developers to use /// different versions of the compiler without dealing with the details of downloading, setting up, and switching /// between versions. It is part of a larger framework for managing and interacting with zkSync contracts. -use anyhow::{anyhow, Error, Result}; +use anyhow::{anyhow, Error, Result, Context}; use dirs; use reqwest::blocking::Client; use serde::Serialize; @@ -94,7 +94,8 @@ impl ZkSolcVersion { #[derive(Debug, Clone, Serialize)] enum ZkSolcOS { Linux, - Mac, + MacAMD, + MacARM } /// `get_operating_system` identifies the current operating system and returns the corresponding `ZkSolcOS` variant. @@ -109,8 +110,11 @@ enum ZkSolcOS { fn get_operating_system() -> Result { match std::env::consts::OS { "linux" => Ok(ZkSolcOS::Linux), - "macos" | "darwin" => Ok(ZkSolcOS::Mac), - _ => Err(Error::msg("Unsupported operating system")), + "macos" | "darwin" => match std::env::consts::ARCH { + "aarch64" => Ok(ZkSolcOS::MacARM), + _ => Ok(ZkSolcOS::MacAMD), + }, + _ => Err(Error::msg(format!("Unsupported operating system {}", std::env::consts::OS))), } } @@ -127,7 +131,8 @@ impl ZkSolcOS { fn get_compiler(&self) -> &str { match self { ZkSolcOS::Linux => "zksolc-linux-amd64-musl-", - ZkSolcOS::Mac => "zksolc-macosx-amd64-", + ZkSolcOS::MacAMD => "zksolc-macosx-amd64-", + ZkSolcOS::MacARM => "zksolc-macosx-arm64-", } } @@ -143,7 +148,8 @@ impl ZkSolcOS { fn get_download_uri(&self) -> &str { match self { ZkSolcOS::Linux => "linux-amd64", - ZkSolcOS::Mac => "macosx-amd64", + ZkSolcOS::MacAMD => "macosx-amd64", + ZkSolcOS::MacARM => "macosx-arm64", } } } @@ -233,12 +239,7 @@ impl ZkSolcManagerBuilder { /// /// This function can return an `Err` if the operating system cannot be determined using `get_operating_system`. fn get_compiler(self) -> Result { - if let Ok(zk_solc_os) = get_operating_system() { - let compiler = zk_solc_os.get_compiler().to_string(); - Ok(compiler) - } else { - Err(Error::msg("Could not determine compiler")) - } + get_operating_system().with_context(|| "Failed to determine OS for compiler").map(|it| it.get_compiler().to_string()) } /// `build` constructs and returns a `ZkSolcManager` instance based on the provided configuration options. @@ -406,7 +407,6 @@ impl ZkSolcManager { /// /// This function can return an `Err` if the full download URL cannot be parsed into a valid `Url`. pub fn get_full_download_url(&self) -> Result { - // TODO: this is an example, of how you can 'propagate' the error from below, and add some local context information. let zk_solc_os = get_operating_system() .map_err(|err| anyhow!("Failed to determine OS to select the binary: {}", err))?;