From befb13f41ed7e14502dfb3b1db8864c6ddbabdb9 Mon Sep 17 00:00:00 2001 From: Federico Gimenez Date: Fri, 31 May 2024 16:15:52 +0200 Subject: [PATCH] feat: add Prague evm version --- crates/artifacts/solc/src/lib.rs | 16 +++++++++++++--- crates/core/src/utils.rs | 8 ++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/artifacts/solc/src/lib.rs b/crates/artifacts/solc/src/lib.rs index 5d32d8a5..62461c44 100644 --- a/crates/artifacts/solc/src/lib.rs +++ b/crates/artifacts/solc/src/lib.rs @@ -39,8 +39,7 @@ use crate::output_selection::{ContractOutputSelection, OutputSelection}; use foundry_compilers_core::{ error::SolcError, utils::{ - strip_prefix_owned, BERLIN_SOLC, BYZANTIUM_SOLC, CANCUN_SOLC, CONSTANTINOPLE_SOLC, - ISTANBUL_SOLC, LONDON_SOLC, PARIS_SOLC, PETERSBURG_SOLC, SHANGHAI_SOLC, + strip_prefix_owned, BERLIN_SOLC, BYZANTIUM_SOLC, CANCUN_SOLC, CONSTANTINOPLE_SOLC, ISTANBUL_SOLC, LONDON_SOLC, PARIS_SOLC, PETERSBURG_SOLC, PRAGUE_SOLC, SHANGHAI_SOLC }, }; pub use serde_helpers::{deserialize_bytes, deserialize_opt_bytes}; @@ -813,6 +812,7 @@ pub enum EvmVersion { Shanghai, #[default] Cancun, + Prague, } impl EvmVersion { @@ -822,8 +822,11 @@ impl EvmVersion { if *version >= BYZANTIUM_SOLC { // If the Solc version is the latest, it supports all EVM versions. // For all other cases, cap at the at-the-time highest possible fork. - let normalized = if *version >= CANCUN_SOLC { + + let normalized = if *version >= PRAGUE_SOLC { self + } else if self >= Self::Cancun && *version >= CANCUN_SOLC { + Self::Cancun } else if self >= Self::Shanghai && *version >= SHANGHAI_SOLC { Self::Shanghai } else if self >= Self::Paris && *version >= PARIS_SOLC { @@ -864,6 +867,7 @@ impl EvmVersion { Self::Paris => "paris", Self::Shanghai => "shanghai", Self::Cancun => "cancun", + Self::Prague => "prague", } } @@ -932,6 +936,7 @@ impl FromStr for EvmVersion { "paris" => Ok(Self::Paris), "shanghai" => Ok(Self::Shanghai), "cancun" => Ok(Self::Cancun), + "prague" => Ok(Self::Prague), s => Err(format!("Unknown evm version: {s}")), } } @@ -2004,6 +2009,11 @@ mod tests { ("0.8.24", EvmVersion::Homestead, Some(EvmVersion::Homestead)), ("0.8.24", EvmVersion::Shanghai, Some(EvmVersion::Shanghai)), ("0.8.24", EvmVersion::Cancun, Some(EvmVersion::Cancun)), + // Prague + ("0.8.26", EvmVersion::Homestead, Some(EvmVersion::Homestead)), + ("0.8.26", EvmVersion::Shanghai, Some(EvmVersion::Shanghai)), + ("0.8.26", EvmVersion::Cancun, Some(EvmVersion::Cancun)), + ("0.8.26", EvmVersion::Prague, Some(EvmVersion::Prague)), ] { let version = Version::from_str(solc_version).unwrap(); assert_eq!( diff --git a/crates/core/src/utils.rs b/crates/core/src/utils.rs index 584f3fbf..3fffff72 100644 --- a/crates/core/src/utils.rs +++ b/crates/core/src/utils.rs @@ -85,6 +85,14 @@ pub const SHANGHAI_SOLC: Version = Version::new(0, 8, 20); /// pub const CANCUN_SOLC: Version = Version::new(0, 8, 24); +/// Prague support +/// TBD +pub const PRAGUE_SOLC: Version = Version::new(0, 8, 26); + +/// Prague EOF support +/// TBD +pub const PRAGUE_EOF_SOLC: Version = Version::new(0, 8, 26); + // `--base-path` was introduced in 0.6.9 pub static SUPPORTS_BASE_PATH: Lazy = Lazy::new(|| VersionReq::parse(">=0.6.9").unwrap());