Skip to content

Commit

Permalink
fix: updates zksolc_manager to include versions 13,14,15 zksolc (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
dutterbutter authored Oct 27, 2023
1 parent 72c1b03 commit ed8864a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches:
- main
pull_request:
branches:
- main

concurrency:
cancel-in-progress: true
Expand Down
1 change: 0 additions & 1 deletion crates/zkforge/bin/cmd/zk_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ impl ZkBuildArgs {

let zksolc_manager = self.setup_zksolc_manager()?;

println!("Compiling smart contracts...");
self.compile_smart_contracts(zksolc_manager, project)
}
/// Returns whether `ZkBuildArgs` was configured with `--watch`
Expand Down
2 changes: 0 additions & 2 deletions crates/zkforge/bin/cmd/zk_solc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ impl ZkSolc {
for source in version.1 {
// Contract path is an absolute path of the file.
let contract_path = source.0.clone();

// Check if the contract_path is in 'sources' directory or its subdirectories
let is_in_sources_dir = contract_path
.ancestors()
Expand All @@ -254,7 +253,6 @@ impl ZkSolc {
// Step 5: Run Compiler and Handle Output
let mut cmd = Command::new(&self.compiler_path);
let mut child = cmd
.arg(contract_path.clone())
.args(&comp_args)
.stdin(Stdio::piped())
.stderr(Stdio::piped())
Expand Down
29 changes: 23 additions & 6 deletions crates/zkforge/bin/cmd/zksolc_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ use serde::Serialize;
use std::{fmt, fs, fs::File, io::copy, os::unix::prelude::PermissionsExt, path::PathBuf};
use url::Url;

const ZKSOLC_DOWNLOAD_BASE_URL: &str = "https://github.com/matter-labs/zksolc-bin/raw/main";
const ZKSOLC_DOWNLOAD_BASE_URL: &str =
"https://github.com/matter-labs/zksolc-bin/releases/download/";

/// `ZkSolcVersion` is an enumeration of the supported versions of the `zksolc` compiler.
///
Expand All @@ -56,9 +57,12 @@ pub enum ZkSolcVersion {
V139,
V1310,
V1311,
V1313,
V1314,
V1315,
}

pub const DEFAULT_ZKSOLC_VERSION: &str = "v1.3.11";
pub const DEFAULT_ZKSOLC_VERSION: &str = "v1.3.15";

/// `parse_version` parses a string representation of a `zksolc` compiler version
/// and returns the `ZkSolcVersion` enum variant if it matches a supported version.
Expand All @@ -80,6 +84,9 @@ fn parse_version(version: &str) -> Result<ZkSolcVersion> {
"v1.3.9" => Ok(ZkSolcVersion::V139),
"v1.3.10" => Ok(ZkSolcVersion::V1310),
"v1.3.11" => Ok(ZkSolcVersion::V1311),
"v1.3.13" => Ok(ZkSolcVersion::V1313),
"v1.3.14" => Ok(ZkSolcVersion::V1314),
"v1.3.15" => Ok(ZkSolcVersion::V1315),
_ => Err(Error::msg(
"ZkSolc compiler version not supported. Proper version format: 'v1.3.x'",
)),
Expand All @@ -101,6 +108,9 @@ impl ZkSolcVersion {
ZkSolcVersion::V139 => "v1.3.9",
ZkSolcVersion::V1310 => "v1.3.10",
ZkSolcVersion::V1311 => "v1.3.11",
ZkSolcVersion::V1313 => "v1.3.13",
ZkSolcVersion::V1314 => "v1.3.14",
ZkSolcVersion::V1315 => "v1.3.15",
}
}
}
Expand Down Expand Up @@ -206,8 +216,8 @@ impl ZkSolcManagerOpts {
/// # Example
///
/// ```ignore
/// use foundry_cli::cmd::forge::zksolc_manager::{ZkSolcManagerBuilder, ZkSolcManagerOpts};
/// let opts = ZkSolcManagerOpts::new("v1.3.11")
/// use zkforge::zksolc_manager::{ZkSolcManagerBuilder, ZkSolcManagerOpts};
/// let opts = ZkSolcManagerOpts::new("v1.3.15")
/// let zk_solc_manager = ZkSolcManagerBuilder::new(opts)
/// .build()
/// .expect("Failed to build ZkSolcManager");
Expand Down Expand Up @@ -311,6 +321,7 @@ impl ZkSolcManagerBuilder {
let compilers_path = home_path.to_owned();

let solc_version = parse_version(&version)?;

Ok(ZkSolcManager::new(compilers_path, solc_version, compiler, download_url))
}
}
Expand Down Expand Up @@ -458,14 +469,20 @@ 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<Url> {
let zk_solc_os = get_operating_system()
.map_err(|err| anyhow!("Failed to determine OS to select the binary: {}", err))?;

let download_uri = zk_solc_os.get_download_uri();

let full_download_url =
format!("{}/{}/{}", self.download_url, download_uri, self.get_full_compiler());
// Using the GitHub releases URL pattern
let full_download_url = format!(
"https://github.com/matter-labs/zksolc-bin/releases/download/{}/zksolc-{}-{}",
self.version.get_version(),
download_uri,
self.version.get_version()
);

Url::parse(&full_download_url)
.map_err(|err| anyhow!("Could not parse URL for binary download: {}", err))
Expand Down

0 comments on commit ed8864a

Please sign in to comment.