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

Adding support for the newest 1.3.11 zksolc compiler #95

Merged
merged 1 commit into from
May 30, 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
11 changes: 8 additions & 3 deletions cli/src/cmd/forge/zk_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
/// easy-to-use interface for contract compilation while taking care of the underlying complexities.
use super::build::CoreBuildArgs;
use super::zksolc::{ZkSolc, ZkSolcOpts};
use super::zksolc_manager::{ZkSolcManager, ZkSolcManagerBuilder, ZkSolcManagerOpts};
use super::zksolc_manager::{
ZkSolcManager, ZkSolcManagerBuilder, ZkSolcManagerOpts, DEFAULT_ZKSOLC_VERSION,
};
use crate::cmd::{Cmd, LoadConfig};
use clap::Parser;
use ethers::prelude::Project;
Expand Down Expand Up @@ -74,7 +76,7 @@ pub struct ZkBuildArgs {
help_heading = "ZkSync Compiler options",
value_name = "ZK_SOLC_VERSION",
long = "use-zksolc",
default_value = "v1.3.9"
default_value = DEFAULT_ZKSOLC_VERSION
)]
#[serde(skip)]
pub use_zksolc: String,
Expand Down Expand Up @@ -160,7 +162,10 @@ impl ZkBuildArgs {
}

if !zksolc_manager.exists() {
println!("Downloading zksolc compiler from {:?}", zksolc_manager.get_full_download_url().unwrap().to_string());
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))?;
Expand Down
13 changes: 10 additions & 3 deletions cli/src/cmd/forge/zksolc_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, Context};
use anyhow::{anyhow, Context, Error, Result};
use dirs;
use reqwest::blocking::Client;
use serde::Serialize;
Expand Down Expand Up @@ -49,8 +49,11 @@ pub enum ZkSolcVersion {
V138,
V139,
V1310,
V1311,
}

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

/// `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 @@ -70,6 +73,7 @@ fn parse_version(version: &str) -> Result<ZkSolcVersion> {
"v1.3.8" => Ok(ZkSolcVersion::V138),
"v1.3.9" => Ok(ZkSolcVersion::V139),
"v1.3.10" => Ok(ZkSolcVersion::V1310),
"v1.3.11" => Ok(ZkSolcVersion::V1311),
_ => Err(Error::msg(
"ZkSolc compiler version not supported. Proper version format: 'v1.3.x'",
)),
Expand All @@ -90,6 +94,7 @@ impl ZkSolcVersion {
ZkSolcVersion::V138 => "v1.3.8",
ZkSolcVersion::V139 => "v1.3.9",
ZkSolcVersion::V1310 => "v1.3.10",
ZkSolcVersion::V1311 => "v1.3.11",
}
}
}
Expand All @@ -98,7 +103,7 @@ impl ZkSolcVersion {
enum ZkSolcOS {
Linux,
MacAMD,
MacARM
MacARM,
}

/// `get_operating_system` identifies the current operating system and returns the corresponding `ZkSolcOS` variant.
Expand Down Expand Up @@ -242,7 +247,9 @@ impl ZkSolcManagerBuilder {
///
/// This function can return an `Err` if the operating system cannot be determined using `get_operating_system`.
fn get_compiler(self) -> Result<String> {
get_operating_system().with_context(|| "Failed to determine OS for compiler").map(|it| it.get_compiler().to_string())
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.
Expand Down