Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions crates/artifacts/solc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ 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,
ISTANBUL_SOLC, LONDON_SOLC, PARIS_SOLC, PETERSBURG_SOLC, PRAGUE_SOLC, SHANGHAI_SOLC,
},
};
pub use serde_helpers::{deserialize_bytes, deserialize_opt_bytes};
Expand Down Expand Up @@ -813,6 +813,7 @@ pub enum EvmVersion {
Shanghai,
#[default]
Cancun,
Prague,
}

impl EvmVersion {
Expand All @@ -822,8 +823,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 {
Expand Down Expand Up @@ -864,6 +868,7 @@ impl EvmVersion {
Self::Paris => "paris",
Self::Shanghai => "shanghai",
Self::Cancun => "cancun",
Self::Prague => "prague",
}
}

Expand Down Expand Up @@ -932,6 +937,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}")),
}
}
Expand Down Expand Up @@ -2004,6 +2010,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.27", EvmVersion::Prague, Some(EvmVersion::Prague)),
] {
let version = Version::from_str(solc_version).unwrap();
assert_eq!(
Expand Down
5 changes: 5 additions & 0 deletions crates/core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ pub const SHANGHAI_SOLC: Version = Version::new(0, 8, 20);
/// <https://soliditylang.org/blog/2024/01/26/solidity-0.8.24-release-announcement/>
pub const CANCUN_SOLC: Version = Version::new(0, 8, 24);

/// Prague support
/// <https://github.com/ethereum/solidity/pull/15152>
/// Was merged between 0.8.26 and 0.8.27, so we are expecting it to be available in 0.8.27
pub const PRAGUE_SOLC: Version = Version::new(0, 8, 27);

// `--base-path` was introduced in 0.6.9 <https://github.com/ethereum/solidity/releases/tag/v0.6.9>
pub static SUPPORTS_BASE_PATH: Lazy<VersionReq> =
Lazy::new(|| VersionReq::parse(">=0.6.9").unwrap());
Expand Down