Skip to content

Commit

Permalink
fix: normalize EVM version in chisel (#9040)
Browse files Browse the repository at this point in the history
* fix: normalize EVM version in chisel

* rm test

* clippy

* fix
  • Loading branch information
klkvr authored Oct 6, 2024
1 parent a5f922d commit 8905af3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 37 deletions.
16 changes: 5 additions & 11 deletions crates/chisel/src/session_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,6 @@ impl SessionSourceConfig {

match solc_req {
SolcReq::Version(version) => {
// Validate that the requested evm version is supported by the solc version
let req_evm_version = self.foundry_config.evm_version;
if let Some(compat_evm_version) = req_evm_version.normalize_version_solc(&version) {
if req_evm_version > compat_evm_version {
eyre::bail!(
"The set evm version, {req_evm_version}, is not supported by solc {version}. Upgrade to a newer solc version."
);
}
}

let solc = if let Some(solc) = Solc::find_svm_installed_version(&version)? {
solc
} else {
Expand Down Expand Up @@ -322,7 +312,11 @@ impl SessionSource {

let settings = Settings {
remappings,
evm_version: Some(self.config.foundry_config.evm_version),
evm_version: self
.config
.foundry_config
.evm_version
.normalize_version_solc(&self.solc.version),
..Default::default()
};

Expand Down
27 changes: 1 addition & 26 deletions crates/chisel/tests/cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use chisel::session::ChiselSession;
use foundry_compilers::artifacts::EvmVersion;
use foundry_config::{Config, SolcReq};
use semver::Version;
use foundry_config::Config;
use serial_test::serial;
use std::path::Path;

Expand Down Expand Up @@ -221,27 +220,3 @@ fn test_load_latest_cache() {
assert_eq!(new_env.id.unwrap(), "1");
assert_eq!(new_env.session_source.to_repl_source(), env.session_source.to_repl_source());
}

#[test]
#[serial]
fn test_solc_evm_configuration_mismatch() {
// Create and clear the cache directory
ChiselSession::create_cache_dir().unwrap();
ChiselSession::clear_cache().unwrap();

// Force the solc version to be 0.8.13 which does not support Paris
let foundry_config = Config {
evm_version: EvmVersion::Paris,
solc: Some(SolcReq::Version(Version::new(0, 8, 13))),
..Default::default()
};

// Create a new session that is expected to fail
let error = ChiselSession::new(chisel::session_source::SessionSourceConfig {
foundry_config,
..Default::default()
})
.unwrap_err();

assert_eq!(error.to_string(), "The set evm version, paris, is not supported by solc 0.8.13. Upgrade to a newer solc version.");
}

0 comments on commit 8905af3

Please sign in to comment.