Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

fix bug 2370 #2371

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 12 additions & 6 deletions ethers-solc/src/artifacts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ impl EvmVersion {
pub fn normalize_version(self, version: &Version) -> Option<EvmVersion> {
// the EVM version flag was only added at 0.4.21
// we work our way backwards
if version >= &CONSTANTINOPLE_SOLC {
if version >= &BYZANTIUM_SOLC {
// If the Solc is at least at london, it supports all EVM versions
Some(if version >= &LONDON_SOLC {
self
Expand All @@ -769,8 +769,10 @@ impl EvmVersion {
EvmVersion::Istanbul
} else if version >= &PETERSBURG_SOLC && self >= EvmVersion::Petersburg {
EvmVersion::Petersburg
} else if self >= EvmVersion::Constantinople {
} else if version >= &CONSTANTINOPLE_SOLC && self >= EvmVersion::Constantinople {
EvmVersion::Constantinople
} else if self >= EvmVersion::Byzantium {
EvmVersion::Byzantium
} else {
self
})
Expand Down Expand Up @@ -2151,12 +2153,16 @@ mod tests {
#[test]
fn test_evm_version_normalization() {
for (solc_version, evm_version, expected) in &[
// Ensure 0.4.21 it always returns None
// Ensure before 0.4.21 it always returns None
("0.4.20", EvmVersion::Homestead, None),
// Constantinople clipping
// Byzantium clipping
("0.4.21", EvmVersion::Homestead, Some(EvmVersion::Homestead)),
("0.4.21", EvmVersion::Constantinople, Some(EvmVersion::Constantinople)),
("0.4.21", EvmVersion::London, Some(EvmVersion::Constantinople)),
("0.4.21", EvmVersion::Constantinople, Some(EvmVersion::Byzantium)),
("0.4.21", EvmVersion::London, Some(EvmVersion::Byzantium)),
// Constantinople bug fix
("0.4.22", EvmVersion::Homestead, Some(EvmVersion::Homestead)),
("0.4.22", EvmVersion::Constantinople, Some(EvmVersion::Constantinople)),
("0.4.22", EvmVersion::London, Some(EvmVersion::Constantinople)),
// Petersburg
("0.5.5", EvmVersion::Homestead, Some(EvmVersion::Homestead)),
("0.5.5", EvmVersion::Petersburg, Some(EvmVersion::Petersburg)),
Expand Down
6 changes: 5 additions & 1 deletion ethers-solc/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ pub const SOLC: &str = "solc";

/// Support for configuring the EVM version
/// <https://blog.soliditylang.org/2018/03/08/solidity-0.4.21-release-announcement/>
pub const CONSTANTINOPLE_SOLC: Version = Version::new(0, 4, 21);
pub const BYZANTIUM_SOLC: Version = Version::new(0, 4, 21);

/// Bug fix for configuring the EVM version with Constantinople
/// <https://blog.soliditylang.org/2018/03/08/solidity-0.4.21-release-announcement/>
pub const CONSTANTINOPLE_SOLC: Version = Version::new(0, 4, 22);

/// Petersburg support
/// <https://blog.soliditylang.org/2019/03/05/solidity-0.5.5-release-announcement/>
Expand Down