From 0e7c3a95a4cd61161b91335d4e0af0fe768fbae0 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Fri, 1 Nov 2024 17:16:38 +0100 Subject: [PATCH 1/2] feat: zksolc 1.5.7 support --- .../artifacts/zksolc/src/output_selection.rs | 12 ++++++------ .../src/compilers/zksolc/settings.rs | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/crates/artifacts/zksolc/src/output_selection.rs b/crates/artifacts/zksolc/src/output_selection.rs index a063fb16..e05b2751 100644 --- a/crates/artifacts/zksolc/src/output_selection.rs +++ b/crates/artifacts/zksolc/src/output_selection.rs @@ -7,18 +7,18 @@ use std::collections::HashSet; #[derive(Debug, Default, Serialize, Deserialize, Eq, PartialEq, Clone)] pub struct OutputSelection { /// Only the 'all' wildcard is available for robustness reasons. - #[serde(rename = "*", skip_serializing_if = "Option::is_none")] - pub all: Option, + #[serde(rename = "*")] + pub all: FileOutputSelection, } #[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)] pub struct FileOutputSelection { /// The per-file output selections. - #[serde(rename = "", skip_serializing_if = "Option::is_none")] - pub per_file: Option>, + #[serde(rename = "")] + pub per_file: HashSet, /// The per-contract output selections. - #[serde(rename = "*", skip_serializing_if = "Option::is_none")] - pub per_contract: Option>, + #[serde(rename = "*")] + pub per_contract: HashSet, } /// diff --git a/crates/compilers/src/compilers/zksolc/settings.rs b/crates/compilers/src/compilers/zksolc/settings.rs index 1711f3c4..1c978a42 100644 --- a/crates/compilers/src/compilers/zksolc/settings.rs +++ b/crates/compilers/src/compilers/zksolc/settings.rs @@ -15,6 +15,19 @@ use std::{ str::FromStr, }; +/// +/// The Solidity compiler codegen. +/// +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum Codegen { + /// The Yul IR. + #[default] + Yul, + /// The EVM legacy assembly IR. + EVMLA, +} + /// zksolc standard json input settings. See: /// https://docs.zksync.io/zk-stack/components/compiler/toolchain/solidity.html#standard-json for differences #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] @@ -25,6 +38,9 @@ pub struct ZkSettings { /// false by default. #[serde(rename = "viaIR", default, skip_serializing_if = "Option::is_none")] pub via_ir: Option, + /// The Solidity codegen. + #[serde(default)] + pub codegen: Codegen, // TODO: era-compiler-solidity uses a BTreeSet of strings. In theory the serialization // should be the same but maybe we should double check #[serde(default, skip_serializing_if = "Vec::is_empty")] @@ -143,6 +159,7 @@ impl Default for ZkSettings { enable_eravm_extensions: false, llvm_options: Default::default(), force_evmla: false, + codegen: Default::default(), } } } @@ -168,6 +185,7 @@ impl CompilerSettings for ZkSolcSettings { enable_eravm_extensions, llvm_options, force_evmla, + codegen, }, .. } = self; @@ -183,6 +201,7 @@ impl CompilerSettings for ZkSolcSettings { && *enable_eravm_extensions == other.settings.enable_eravm_extensions && *llvm_options == other.settings.llvm_options && *force_evmla == other.settings.force_evmla + && *codegen == other.settings.codegen } fn with_remappings(mut self, remappings: &[Remapping]) -> Self { From 91e91d7fe7058536ca8152d4847855f3046b56bf Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Fri, 1 Nov 2024 17:52:08 +0100 Subject: [PATCH 2/2] chore: update version constants --- crates/compilers/src/compilers/zksolc/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/compilers/src/compilers/zksolc/mod.rs b/crates/compilers/src/compilers/zksolc/mod.rs index 153b76da..e502cf96 100644 --- a/crates/compilers/src/compilers/zksolc/mod.rs +++ b/crates/compilers/src/compilers/zksolc/mod.rs @@ -38,7 +38,7 @@ pub use settings::ZkSolcSettings; pub const ZKSOLC: &str = "zksolc"; pub const ZKSYNC_SOLC_RELEASE: Version = Version::new(1, 0, 1); -pub const ZKSOLC_VERSION: Version = Version::new(1, 5, 4); +pub const ZKSOLC_VERSION: Version = Version::new(1, 5, 7); #[derive(Debug, Clone, Serialize)] enum ZkSolcOS { @@ -336,7 +336,7 @@ impl ZkSolc { pub fn solc_available_versions() -> Vec { let mut ret = vec![]; let min_max_patch_by_minor_versions = - vec![(4, 12, 26), (5, 0, 17), (6, 0, 12), (7, 0, 6), (8, 0, 27)]; + vec![(4, 12, 26), (5, 0, 17), (6, 0, 12), (7, 0, 6), (8, 0, 28)]; for (minor, min_patch, max_patch) in min_max_patch_by_minor_versions { for i in min_patch..=max_patch { ret.push(Version::new(0, minor, i));