Skip to content
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
20 changes: 1 addition & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ foundry-test-utils = { path = "crates/test-utils" }
foundry-utils = { path = "crates/utils" }
ui = { path = "crates/ui" }

## revm
revm = { version = "3", default-features = false }
revm-primitives = { version = "1", default-features = false }

ethers = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
Expand Down Expand Up @@ -156,3 +160,4 @@ tikv-jemallocator = "0.5.4"

[patch.crates-io]
revm = { git = "https://github.com/bluealloy/revm/", rev = "6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" }
revm-primitives = { git = "https://github.com/bluealloy/revm/", rev = "6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" }
2 changes: 1 addition & 1 deletion crates/anvil/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository.workspace = true
[dependencies]
# foundry internal
foundry-evm = { path = "../../evm" }
revm = { version = "3", default-features = false, features = ["std", "serde", "memory_limit"] }
revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] }

ethers-core.workspace = true
serde = { version = "1", features = ["derive"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/chisel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ serde = "1"
serde_json = { version = "1", features = ["raw_value"] }
semver = "1"
bytes = "1"
revm = "3"
revm.workspace = true
eyre = "0.6"
dirs = "5"
time = { version = "0.3", features = ["formatting"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/chisel/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl SessionSource {
)
})
.gas_limit(self.config.evm_opts.gas_limit())
.spec(foundry_evm::utils::evm_spec(self.config.foundry_config.evm_version))
.spec(self.config.foundry_config.evm_spec_id())
.build(env, backend);

// Create a [ChiselRunner] with a default balance of [U256::MAX] and
Expand Down
1 change: 1 addition & 0 deletions crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repository.workspace = true
ethers-core.workspace = true
ethers-solc = { workspace = true, features = ["async", "svm-solc"] }
ethers-etherscan.workspace = true
revm-primitives.workspace = true

# formats
Inflector = "0.11"
Expand Down
7 changes: 7 additions & 0 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub mod fix;

// reexport so cli types can implement `figment::Provider` to easily merge compiler arguments
pub use figment;
use revm_primitives::SpecId;
use tracing::warn;

/// config providers
Expand Down Expand Up @@ -685,6 +686,12 @@ impl Config {
Ok(None)
}

/// Returns the [SpecId] derived from the configured [EvmVersion]
#[inline]
pub fn evm_spec_id(&self) -> SpecId {
evm_spec_id(&self.evm_version)
}

/// Returns whether the compiler version should be auto-detected
///
/// Returns `false` if `solc_version` is explicitly set, otherwise returns the value of
Expand Down
24 changes: 23 additions & 1 deletion crates/config/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

use crate::Config;
use ethers_core::types::{serde_helpers::Numeric, U256};
use ethers_solc::remappings::{Remapping, RemappingError};
use ethers_solc::{
remappings::{Remapping, RemappingError},
EvmVersion,
};
use figment::value::Value;
use revm_primitives::SpecId;
use serde::{de::Error, Deserialize, Deserializer};
use std::{
path::{Path, PathBuf},
Expand Down Expand Up @@ -255,6 +259,24 @@ where
Ok(num)
}

/// Returns the [SpecId] derived from [EvmVersion]
#[inline]
pub fn evm_spec_id(evm_version: &EvmVersion) -> SpecId {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapped this in a simple util function, and we use this on config

match evm_version {
EvmVersion::Homestead => SpecId::HOMESTEAD,
EvmVersion::TangerineWhistle => SpecId::TANGERINE,
EvmVersion::SpuriousDragon => SpecId::SPURIOUS_DRAGON,
EvmVersion::Byzantium => SpecId::BYZANTIUM,
EvmVersion::Constantinople => SpecId::CONSTANTINOPLE,
EvmVersion::Petersburg => SpecId::PETERSBURG,
EvmVersion::Istanbul => SpecId::ISTANBUL,
EvmVersion::Berlin => SpecId::BERLIN,
EvmVersion::London => SpecId::LONDON,
EvmVersion::Paris => SpecId::MERGE,
EvmVersion::Shanghai => SpecId::SHANGHAI,
}
}

#[cfg(test)]
mod tests {
use crate::get_available_profiles;
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ once_cell = "1"
# EVM
bytes = "1"
hashbrown = { version = "0.13", features = ["serde"] }
revm = { version = "3", default-features = false, features = [
revm = { workspace = true, default-features = false, features = [
"std",
"serde",
"memory_limit",
Expand Down
9 changes: 3 additions & 6 deletions crates/evm/src/trace/executor.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use crate::{
executor::{fork::CreateFork, opts::EvmOpts, Backend, Executor, ExecutorBuilder},
utils::evm_spec,
};
use crate::executor::{fork::CreateFork, opts::EvmOpts, Backend, Executor, ExecutorBuilder};
use ethers::solc::EvmVersion;
use foundry_config::Config;
use foundry_config::{utils::evm_spec_id, Config};
use revm::primitives::Env;
use std::ops::{Deref, DerefMut};

Expand All @@ -25,7 +22,7 @@ impl TracingExecutor {
// tracing will be enabled only for the targeted transaction
executor: ExecutorBuilder::new()
.inspectors(|stack| stack.trace(true).debug(debug))
.spec(evm_spec(version.unwrap_or_default()))
.spec(evm_spec_id(&version.unwrap_or_default()))
.build(env, db),
}
}
Expand Down
19 changes: 0 additions & 19 deletions crates/evm/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use ethers::{
abi::{Abi, FixedBytes, Function},
solc::EvmVersion,
types::{Block, Chain, H256, U256},
};
use eyre::ContextCompat;
Expand Down Expand Up @@ -112,24 +111,6 @@ pub fn halt_to_instruction_result(halt: Halt) -> InstructionResult {
}
}

/// Converts an `EvmVersion` into a `SpecId`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed this as this was duped from this pr onwards

#[inline]
pub fn evm_spec(evm: EvmVersion) -> SpecId {
match evm {
EvmVersion::Homestead => SpecId::HOMESTEAD,
EvmVersion::TangerineWhistle => SpecId::TANGERINE,
EvmVersion::SpuriousDragon => SpecId::SPURIOUS_DRAGON,
EvmVersion::Byzantium => SpecId::BYZANTIUM,
EvmVersion::Constantinople => SpecId::CONSTANTINOPLE,
EvmVersion::Petersburg => SpecId::PETERSBURG,
EvmVersion::Istanbul => SpecId::ISTANBUL,
EvmVersion::Berlin => SpecId::BERLIN,
EvmVersion::London => SpecId::LONDON,
EvmVersion::Paris => SpecId::MERGE,
EvmVersion::Shanghai => SpecId::SHANGHAI,
}
}

/// Depending on the configured chain id and block number this should apply any specific changes
///
/// This checks for:
Expand Down
4 changes: 1 addition & 3 deletions crates/forge/bin/cmd/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use foundry_cli::{
};
use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs};
use foundry_config::{Config, SolcReq};
use foundry_evm::utils::evm_spec;
use semver::Version;
use std::{collections::HashMap, sync::mpsc::channel};
use tracing::trace;
Expand Down Expand Up @@ -286,11 +285,10 @@ impl CoverageArgs {
let root = project.paths.root;

// Build the contract runner
let evm_spec = evm_spec(config.evm_version);
let env = evm_opts.evm_env().await?;
let mut runner = MultiContractRunnerBuilder::default()
.initial_balance(evm_opts.initial_balance)
.evm_spec(evm_spec)
.evm_spec(config.evm_spec_id())
.sender(evm_opts.sender)
.with_fork(evm_opts.get_fork(&config, env.clone()))
.with_cheats_config(CheatsConfig::new(&config, &evm_opts))
Expand Down
3 changes: 1 addition & 2 deletions crates/forge/bin/cmd/script/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use forge::{
};
use foundry_cli::utils::{ensure_clean_constructor, needs_setup};
use foundry_common::{shell, RpcUrl};
use foundry_evm::utils::evm_spec;
use futures::future::join_all;
use parking_lot::RwLock;
use std::{collections::VecDeque, sync::Arc};
Expand Down Expand Up @@ -305,7 +304,7 @@ impl ScriptArgs {
// We need to enable tracing to decode contract names: local or external.
let mut builder = ExecutorBuilder::new()
.inspectors(|stack| stack.trace(true))
.spec(evm_spec(script_config.config.evm_version))
.spec(script_config.config.evm_spec_id())
.gas_limit(script_config.evm_opts.gas_limit());

if let SimulationStage::Local = stage {
Expand Down
6 changes: 2 additions & 4 deletions crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use foundry_config::{
},
get_available_profiles, Config,
};
use foundry_evm::{fuzz::CounterExample, utils::evm_spec};
use foundry_evm::fuzz::CounterExample;
use regex::Regex;
use std::{collections::BTreeMap, path::PathBuf, sync::mpsc::channel, time::Duration};
use tracing::trace;
Expand Down Expand Up @@ -177,11 +177,9 @@ impl TestArgs {
let env = evm_opts.evm_env().await?;

// Prepare the test builder
let evm_spec = evm_spec(config.evm_version);

let mut runner = MultiContractRunnerBuilder::default()
.initial_balance(evm_opts.initial_balance)
.evm_spec(evm_spec)
.evm_spec(config.evm_spec_id())
.sender(evm_opts.sender)
.with_fork(evm_opts.get_fork(&config, env.clone()))
.with_cheats_config(CheatsConfig::new(&config, &evm_opts))
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/fixtures/can_test_repeatedly.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ No files changed, compilation skipped

Running 2 tests for test/Counter.t.sol:CounterTest
[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387)
[PASS] test_Increment() (gas: 28357)
[PASS] test_Increment() (gas: 28379)
Test result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms

Ran 1 test suites: 2 tests passed, 0 failed, 0 skipped (2 total tests)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Solc 0.8.13 finished in 1.95s
Compiler run successful!

Running 1 test for test/Contract.t.sol:ContractTest
[PASS] test() (gas: 70373)
[PASS] test() (gas: 70351)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s

Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)
2 changes: 1 addition & 1 deletion crates/ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ ethers.workspace = true

crossterm = "0.26"
eyre = "0.6"
revm = { version = "3", features = ["std", "serde"] }
revm = { workspace = true, features = ["std", "serde"] }
ratatui = { version = "0.22.0", default-features = false, features = ["crossterm"]}