Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updates zksolc_manager to include versions 13,14,15 zksolc #132

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
MexicanAce marked this conversation as resolved.
Show resolved Hide resolved
"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