Skip to content

Commit

Permalink
feat: add Prague evm version
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimenez authored and klkvr committed Jul 26, 2024
1 parent c3c6a66 commit befb13f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/artifacts/solc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -813,6 +812,7 @@ pub enum EvmVersion {
Shanghai,
#[default]
Cancun,
Prague,
}

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

Expand Down Expand Up @@ -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}")),
}
}
Expand Down Expand Up @@ -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!(
Expand Down
8 changes: 8 additions & 0 deletions crates/core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ 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
/// 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 <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

0 comments on commit befb13f

Please sign in to comment.