Skip to content

Commit 6f35d1b

Browse files
authored
Merge branch 'master' into rusowsky/ast-fuzz-dict
2 parents dc1b287 + 92d7b35 commit 6f35d1b

File tree

14 files changed

+183
-23
lines changed

14 files changed

+183
-23
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cheatcodes/assets/cheatcodes.json

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cheatcodes/spec/src/vm.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,18 @@ interface Vm {
609609
#[cheatcode(group = Evm, safety = Unsafe)]
610610
function coolSlot(address target, bytes32 slot) external;
611611

612+
/// Returns the test or script execution evm version.
613+
///
614+
/// **Note:** The execution evm version is not the same as the compilation one.
615+
#[cheatcode(group = Evm, safety = Safe)]
616+
function getEvmVersion() external pure returns (string memory evm);
617+
618+
/// Set the exact test or script execution evm version, e.g. `berlin`, `cancun`.
619+
///
620+
/// **Note:** The execution evm version is not the same as the compilation one.
621+
#[cheatcode(group = Evm, safety = Safe)]
622+
function setEvmVersion(string calldata evm) external;
623+
612624
// -------- Call Manipulation --------
613625
// --- Mocks ---
614626

crates/cheatcodes/src/evm.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use foundry_common::{
2121
SlotInfo,
2222
},
2323
};
24+
use foundry_compilers::artifacts::EvmVersion;
2425
use foundry_evm_core::{
2526
ContextExt,
2627
backend::{DatabaseExt, RevertStateSnapshotAction},
@@ -45,6 +46,7 @@ use std::{
4546

4647
mod record_debug_step;
4748
use foundry_common::fmt::format_token_raw;
49+
use foundry_config::evm_spec_id;
4850
use record_debug_step::{convert_call_trace_to_debug_step, flatten_call_trace};
4951
use serde::Serialize;
5052

@@ -1103,6 +1105,23 @@ impl Cheatcode for stopAndReturnDebugTraceRecordingCall {
11031105
}
11041106
}
11051107

1108+
impl Cheatcode for setEvmVersionCall {
1109+
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
1110+
let Self { evm } = self;
1111+
ccx.ecx.cfg.spec = evm_spec_id(
1112+
EvmVersion::from_str(evm)
1113+
.map_err(|_| Error::from(format!("invalid evm version {evm}")))?,
1114+
);
1115+
Ok(Default::default())
1116+
}
1117+
}
1118+
1119+
impl Cheatcode for getEvmVersionCall {
1120+
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
1121+
Ok(ccx.ecx.cfg.spec.to_string().to_lowercase().abi_encode())
1122+
}
1123+
}
1124+
11061125
pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Address) -> Result {
11071126
let account = ccx.ecx.journaled_state.load_account(*address)?;
11081127
Ok(account.info.nonce.abi_encode())

crates/cli/src/opts/evm.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ pub struct EvmArgs {
136136
#[arg(long)]
137137
#[serde(skip)]
138138
pub isolate: bool,
139-
140-
/// Whether to enable Celo precompiles.
141-
#[arg(long)]
142-
#[serde(skip)]
143-
pub celo: bool,
144139
}
145140

146141
// Make this set of options a `figment::Provider` so that it can be merged into the `Config`
@@ -167,10 +162,6 @@ impl Provider for EvmArgs {
167162
dict.insert("isolate".to_string(), self.isolate.into());
168163
}
169164

170-
if self.celo {
171-
dict.insert("celo".to_string(), self.celo.into());
172-
}
173-
174165
if self.always_use_create_2_factory {
175166
dict.insert(
176167
"always_use_create_2_factory".to_string(),

crates/config/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ foundry-compilers = { workspace = true, features = ["svm-solc"] }
2020
alloy-chains = { workspace = true, features = ["serde"] }
2121
alloy-primitives = { workspace = true, features = ["serde"] }
2222

23+
foundry-evm-networks.workspace = true
24+
2325
revm.workspace = true
2426

2527
solar.workspace = true

crates/config/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub use compilation::{CompilationRestrictions, SettingsOverrides};
128128
pub mod extend;
129129
use extend::Extends;
130130

131+
use foundry_evm_networks::NetworkConfigs;
131132
pub use semver;
132133

133134
/// Foundry configuration
@@ -530,9 +531,9 @@ pub struct Config {
530531
#[serde(default, skip_serializing_if = "Vec::is_empty")]
531532
pub extra_args: Vec<String>,
532533

533-
/// Whether to enable Celo precompiles.
534-
#[serde(default)]
535-
pub celo: bool,
534+
/// Networks with enabled features.
535+
#[serde(flatten)]
536+
pub networks: NetworkConfigs,
536537

537538
/// Timeout for transactions in seconds.
538539
pub transaction_timeout: u64,
@@ -2568,7 +2569,7 @@ impl Default for Config {
25682569
legacy_assertions: false,
25692570
warnings: vec![],
25702571
extra_args: vec![],
2571-
celo: false,
2572+
networks: Default::default(),
25722573
transaction_timeout: 120,
25732574
additional_compiler_profiles: Default::default(),
25742575
compilation_restrictions: Default::default(),

crates/evm/networks/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::collections::BTreeMap;
1414

1515
pub mod celo;
1616

17-
#[derive(Clone, Debug, Default, Parser, Copy, Serialize, Deserialize)]
17+
#[derive(Clone, Debug, Default, Parser, Copy, Serialize, Deserialize, PartialEq)]
1818
pub struct NetworkConfigs {
1919
/// Enable Optimism network features.
2020
#[arg(help_heading = "Networks", long, visible_alias = "optimism", conflicts_with = "celo")]
@@ -23,6 +23,7 @@ pub struct NetworkConfigs {
2323
optimism: bool,
2424
/// Enable Celo network features.
2525
#[arg(help_heading = "Networks", long, conflicts_with = "optimism")]
26+
#[serde(default)]
2627
celo: bool,
2728
}
2829

crates/forge/src/multi_runner.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,7 @@ impl TestRunnerConfig {
319319

320320
self.spec_id = config.evm_spec_id();
321321
self.sender = config.sender;
322-
if config.celo {
323-
self.networks = NetworkConfigs::with_celo();
324-
}
322+
self.networks = config.networks;
325323
self.isolation = config.isolate;
326324

327325
// Specific to Forge, not present in config.

crates/forge/tests/cli/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ forgetest!(can_extract_config_values, |prj, cmd| {
350350
assertions_revert: true,
351351
legacy_assertions: false,
352352
extra_args: vec![],
353-
celo: false,
353+
networks: Default::default(),
354354
transaction_timeout: 120,
355355
additional_compiler_profiles: Default::default(),
356356
compilation_restrictions: Default::default(),

0 commit comments

Comments
 (0)