Skip to content

Commit

Permalink
feat: bumps to 1.5.10 and updates assemblycreate to warningtype
Browse files Browse the repository at this point in the history
  • Loading branch information
dutterbutter committed Jan 17, 2025
1 parent f8ad9ef commit 96171f2
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ zksync_vm_interface = { git = "https://github.com/matter-labs/zksync-era.git", r
zksync_multivm = { git = "https://github.com/matter-labs/zksync-era.git", rev = "core-v25.4.0" }
zksync_utils = { git = "https://github.com/matter-labs/zksync-era.git", rev = "core-v25.4.0" }
zksync_contracts = { git = "https://github.com/matter-labs/zksync-era.git", rev = "core-v25.4.0" }
era-solc = { git = "https://github.com/matter-labs/era-compiler-solidity.git", rev = "b8265327d1530a2ba42473e37756aeebfb0fed75", package = "era-solc" }
era-solc = { git = "https://github.com/matter-labs/era-compiler-solidity.git", tag = "1.5.10", package = "era-solc" }

# macros
proc-macro2 = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/src/opts/build/zksync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ pub struct ZkSyncArgs {
/// Set the warnings to suppress for zksolc.
#[clap(
long = "zk-suppressed-warnings",
alias = "suppressed-warnings",
alias = "suppressed-warnings",
visible_alias = "suppress-warnings",
value_delimiter = ',',
help = "Set the warnings to suppress for zksolc, possible values: [txorigin]"
help = "Set the warnings to suppress for zksolc, possible values: [txorigin, assemblycreate]"
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub suppressed_warnings: Option<Vec<WarningType>>,
Expand All @@ -131,7 +131,7 @@ pub struct ZkSyncArgs {
alias = "suppressed-errors",
visible_alias = "suppress-errors",
value_delimiter = ',',
help = "Set the errors to suppress for zksolc, possible values: [sendtransfer, assemblycreate]"
help = "Set the errors to suppress for zksolc, possible values: [sendtransfer]"
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub suppressed_errors: Option<Vec<ErrorType>>,
Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/zksync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub fn config_create_project(
{
zksolc
} else if !config.offline {
let default_version = semver::Version::new(1, 5, 7);
let default_version = semver::Version::new(1, 5, 10);
let mut zksolc = ZkSolc::find_installed_version(&default_version)?;
if zksolc.is_none() {
ZkSolc::blocking_install(&default_version)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/it/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl ForgeTestProfile {
zk_config.zksync.startup = true;
zk_config.zksync.fallback_oz = true;
zk_config.zksync.optimizer_mode = '3';
zk_config.zksync.zksolc = Some(foundry_config::SolcReq::Version(Version::new(1, 5, 7)));
zk_config.zksync.zksolc = Some(foundry_config::SolcReq::Version(Version::new(1, 5, 10)));
zk_config.fuzz.no_zksync_reserved_addresses = true;
zk_config.invariant.depth = 15;

Expand Down
2 changes: 1 addition & 1 deletion crates/script/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl VerifyBundle {

let contract_bytecode_hash = foundry_zksync_core::hash_bytecode(bytecode);
if bytecode_hash == contract_bytecode_hash {
if artifact.source.extension().map_or(false, |e| e.to_str() == Some("vy")) {
if artifact.source.extension().is_some_and(|e| e.to_str() == Some("vy")) {
warn!("Skipping verification of Vyper contract: {}", artifact.name);
}

Expand Down
8 changes: 1 addition & 7 deletions crates/zksync/compilers/src/compilers/zksolc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub const ZKSOLC: &str = "zksolc";
/// ZKsync solc release used for all ZKsync solc versions
pub const ZKSYNC_SOLC_RELEASE: Version = Version::new(1, 0, 1);
/// Default zksolc version
pub const ZKSOLC_VERSION: Version = Version::new(1, 5, 9);
pub const ZKSOLC_VERSION: Version = Version::new(1, 5, 10);

#[cfg(test)]
macro_rules! take_solc_installer_lock {
Expand Down Expand Up @@ -436,12 +436,6 @@ impl ZkSolc {
pub fn compile_output(&self, input: &ZkSolcInput) -> Result<Vec<u8>> {
let mut cmd = Command::new(&self.zksolc);

// Add the `--suppress-errors assemblycreate` flag for zksolc versions >= 1.5.9
// This prevents compile errors during foundry project compilation
if self.solc_version_info.zksync_version.as_ref() >= Some(&Version::new(1, 5, 9)) {
cmd.arg("--suppress-errors").arg("assemblycreate");
}

if !self.allow_paths.is_empty() {
cmd.arg("--allow-paths");
cmd.arg(self.allow_paths.iter().map(|p| p.display()).join(","));
Expand Down
42 changes: 31 additions & 11 deletions crates/zksync/compilers/tests/zksync_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,19 @@ fn zksync_pre_1_5_7_can_compile_contract_with_suppressed_warnings() {
test_zksync_can_compile_contract_with_suppressed_warnings(compiler);
}

fn test_zksync_can_compile_contract_with_assembly_create_suppressed_errors(
fn test_zksync_can_compile_contract_with_assembly_create_suppressed_warnings(
compiler: ZkSolcCompiler,
) {
let mut project = TempProject::<ZkSolcCompiler, ZkArtifactOutput>::dapptools().unwrap();
project.project_mut().compiler = compiler;

project
.add_source(
"Erroneous",
"Warning",
r#"
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.10;
contract Erroneous {
contract Warning {
function deployWithCreate(bytes memory bytecode) public returns (address addr) {
assembly {
addr := create(0, add(bytecode, 0x20), mload(bytecode))
Expand All @@ -189,24 +189,44 @@ fn test_zksync_can_compile_contract_with_assembly_create_suppressed_errors(
)
.unwrap();

// Compile the project and ensure it succeeds with warnings
let compiled = project.compile().unwrap();
assert!(compiled.has_compiler_errors());
compiled.assert_success();
assert!(
compiled
.output()
.errors
.iter()
.any(|err| err.is_warning() && err.message.contains("create")),
"Expected assembly `create` warning, but none found: {:#?}",
compiled.output().errors
);

project.project_mut().settings.settings.suppressed_errors =
HashSet::from([ErrorType::AssemblyCreate]);
project.project_mut().settings.settings.suppressed_warnings =
HashSet::from([WarningType::AssemblyCreate]);

let compiled = project.compile().unwrap();
compiled.assert_success();
assert!(compiled.find_first("Erroneous").is_some());
assert!(compiled.find_first("Warning").is_some());

assert!(
!compiled
.output()
.errors
.iter()
.any(|err| err.is_warning() && err.message.contains("create")),
"Assembly `create` warning was not suppressed: {:#?}",
compiled.output().errors
)
}

#[test]
fn zksync_can_compile_contract_with_assembly_create_suppressed_errors() {
fn zksync_can_compile_contract_with_assembly_create_suppressed_warnings_1_5_10() {
let compiler = ZkSolcCompiler {
zksolc: ZkSolc::get_path_for_version(&semver::Version::new(1, 5, 9)).unwrap(),
zksolc: ZkSolc::get_path_for_version(&semver::Version::new(1, 5, 10)).unwrap(),
solc: Default::default(),
};
test_zksync_can_compile_contract_with_assembly_create_suppressed_errors(compiler);
test_zksync_can_compile_contract_with_assembly_create_suppressed_warnings(compiler);
}

#[test]
Expand Down Expand Up @@ -536,7 +556,7 @@ contract Util {}
assert!(compiled.output().errors.iter().any(|error| error
.formatted_message
.as_ref()
.map_or(false, |msg| msg.contains("File outside of allowed directories"))));
.is_some_and(|msg| msg.contains("File outside of allowed directories"))));
}

#[test]
Expand Down

0 comments on commit 96171f2

Please sign in to comment.