From 3242f6ec54e9a9508776d65dd1f199aa02a4bdb9 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 18 Jul 2024 01:12:22 +0800 Subject: [PATCH] feat: add `eofVersion` config option (#174) adds key for enabling eof which is supported by https://github.com/ipsilon/solidity/tree/eof-functions-rebased solc allows unknown keys in settings, so setting this wouldn't break default solc. though I think it might make sense to be under a feature flag. wdyt @mattsse --- crates/artifacts/solc/Cargo.toml | 1 + crates/artifacts/solc/src/lib.rs | 12 ++++++++++++ crates/compilers/src/compilers/solc/mod.rs | 2 ++ 3 files changed, 15 insertions(+) diff --git a/crates/artifacts/solc/Cargo.toml b/crates/artifacts/solc/Cargo.toml index 965e3288..33a6361e 100644 --- a/crates/artifacts/solc/Cargo.toml +++ b/crates/artifacts/solc/Cargo.toml @@ -30,6 +30,7 @@ tokio = { workspace = true, optional = true } tracing.workspace = true walkdir.workspace = true yansi.workspace = true +serde_repr = "0.1" [target.'cfg(windows)'.dependencies] path-slash.workspace = true diff --git a/crates/artifacts/solc/src/lib.rs b/crates/artifacts/solc/src/lib.rs index 4acaa903..5d32d8a5 100644 --- a/crates/artifacts/solc/src/lib.rs +++ b/crates/artifacts/solc/src/lib.rs @@ -9,6 +9,7 @@ extern crate tracing; use semver::Version; use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; +use serde_repr::{Deserialize_repr, Serialize_repr}; use std::{ borrow::Cow, collections::{BTreeMap, HashSet}, @@ -271,6 +272,16 @@ pub struct Settings { /// If this key is an empty string, that refers to a global level. #[serde(default)] pub libraries: Libraries, + /// Specify EOF version to produce. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub eof_version: Option, +} + +/// Available EOF versions. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize_repr, Deserialize_repr)] +#[repr(u8)] +pub enum EofVersion { + V1 = 1, } impl Settings { @@ -546,6 +557,7 @@ impl Default for Settings { libraries: Default::default(), remappings: Default::default(), model_checker: None, + eof_version: None, } .with_ast() } diff --git a/crates/compilers/src/compilers/solc/mod.rs b/crates/compilers/src/compilers/solc/mod.rs index a6bcd95d..4a4b36a9 100644 --- a/crates/compilers/src/compilers/solc/mod.rs +++ b/crates/compilers/src/compilers/solc/mod.rs @@ -209,6 +209,7 @@ impl CompilerSettings for SolcSettings { via_ir, debug, libraries, + eof_version, }, .. } = self; @@ -222,6 +223,7 @@ impl CompilerSettings for SolcSettings { && *via_ir == other.settings.via_ir && *debug == other.settings.debug && *libraries == other.settings.libraries + && *eof_version == other.settings.eof_version && output_selection.is_subset_of(&other.settings.output_selection) }