Skip to content

Commit

Permalink
Merge branch 'elfedy-compiler-lock' of github.com:matter-labs/foundry…
Browse files Browse the repository at this point in the history
…-zksync into elfedy-compiler-lock
  • Loading branch information
elfedy committed Aug 6, 2024
2 parents 4d9addb + 5c3c0c2 commit 9efdb6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 66 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This repository enhances Foundry to support zkSync Era, enabling Solidity-based

> 🔧 **Fork Notice:** This is a Foundry fork with added zkSync support.
>
> ⚠️ **Alpha Stage:** The project is in alpha, so you might encounter issues.
> ⚠️ **Alpha Stage:** The project is in alpha, so you might encounter issues. For more information, please review [Limitations](#limitations) section.
>
> 🐞 **Found an Issue?** Please report it to help us improve.
Expand Down Expand Up @@ -59,6 +59,7 @@ While `foundry-zksync` is **alpha stage**, there are some limitations to be awar
- **Contract Verification**: Currently contract verification via the `--verify` flag do not work as expected but will be added shortly.
- **Specific Foundry Features**: Currently features such as `--gas-report`, `--coverage` may not work as intended. We are actively working on providing support for these feature types.
- **Solc Compatibility**: `zksolc` requires a `solc` binary to be run as a child process. The version/path to use for each can be specified by the `zksolc` and `solc` options in `foundry.toml`. Not all `solc` versions are supported by all `zksolc` versions, compiling with a `solc` version higher than the one supported may lead to unexpected errors. [Read the docs](https://docs.zksync.io/zk-stack/components/compiler/toolchain/solidity.html#limitations) about version limitations and check the [zksolc changelog](https://github.com/matter-labs/era-compiler-solidity/blob/main/CHANGELOG.md) to see the latest supported `solc` version.
- **Windows Compatibility**: Windows is not officially supported yet. The reported issues would be investigated on a best-effort basis.
For the most effective use of our library, we recommend familiarizing yourself with these features and limitations.
Expand Down
66 changes: 1 addition & 65 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ use foundry_compilers::{
multi::{MultiCompiler, MultiCompilerSettings},
solc::{Solc, SolcCompiler},
vyper::{Vyper, VyperSettings},
zksolc::ZkSolc,
Compiler,
},
error::SolcError,
zksolc::ZkSolcSettings,
zksync::config::ZkSolcConfig,
ConfigurableArtifacts, Project, ProjectPathsConfig,
};
use inflector::Inflector;
Expand Down Expand Up @@ -822,36 +820,12 @@ impl Config {
builder = builder.sparse_output(filter);
}

let mut project = builder.build(self.compiler()?)?;
let project = builder.build(self.compiler()?)?;

if self.force {
self.cleanup(&project)?;
}

// Set up zksolc project values
// TODO: maybe some of these could be included
// when setting up the builder for the sake of consistency (requires dedicated
// builder methods)
project.zksync_zksolc_config = ZkSolcConfig { settings: self.zksync_zksolc_settings()? };

if let Some(zksolc) = self.zksync_ensure_zksolc()? {
project.zksync_zksolc = zksolc;
} else {
// TODO: we automatically install a zksolc version
// if none is found, but maybe we should mirror auto detect settings
// as done with solc
if !self.offline {
let default_version = Version::new(1, 4, 1);
let mut zksolc = ZkSolc::find_installed_version(&default_version)?;
if zksolc.is_none() {
ZkSolc::blocking_install(&default_version)?;
zksolc = ZkSolc::find_installed_version(&default_version)?;
}
project.zksync_zksolc = zksolc
.unwrap_or_else(|| panic!("Could not install zksolc v{}", default_version));
}
}

Ok(project)
}

Expand Down Expand Up @@ -911,44 +885,6 @@ impl Config {
Ok(None)
}

/// Ensures that the configured version is installed if explicitly set
///
/// If `zksolc` is [`SolcReq::Version`] then this will download and install the solc version if
/// it's missing, unless the `offline` flag is enabled, in which case an error is thrown.
///
/// If `zksolc` is [`SolcReq::Local`] then this will ensure that the path exists.
fn zksync_ensure_zksolc(&self) -> Result<Option<ZkSolc>, SolcError> {
if let Some(ref zksolc) = self.zksync.zksolc {
let zksolc = match zksolc {
SolcReq::Version(version) => {
let mut zksolc = ZkSolc::find_installed_version(version)?;
if zksolc.is_none() {
if self.offline {
return Err(SolcError::msg(format!(
"can't install missing zksolc {version} in offline mode"
)))
}
ZkSolc::blocking_install(version)?;
zksolc = ZkSolc::find_installed_version(version)?;
}
zksolc
}
SolcReq::Local(zksolc) => {
if !zksolc.is_file() {
return Err(SolcError::msg(format!(
"`zksolc` {} does not exist",
zksolc.display()
)))
}
Some(ZkSolc::new(zksolc))
}
};
return Ok(zksolc)
}

Ok(None)
}

/// Returns the [SpecId] derived from the configured [EvmVersion]
#[inline]
pub fn evm_spec_id(&self) -> SpecId {
Expand Down

0 comments on commit 9efdb6b

Please sign in to comment.