From ed7ec89182d12c28b4e20e75f9dbb04653ebd386 Mon Sep 17 00:00:00 2001 From: MozirDmitriy Date: Sat, 17 May 2025 14:52:32 +0300 Subject: [PATCH 1/2] feat: implemented initialization of evm_opts and env in TestRunnerConfig and their use in configure_executor --- crates/forge/src/multi_runner.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 03e889c8c5544..94738e23be377 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -308,9 +308,9 @@ impl TestRunnerConfig { self.odyssey = config.odyssey; self.isolation = config.isolate; - // Specific to Forge, not present in config. - // TODO: self.evm_opts - // TODO: self.env + // Update evm_opts and env from the new config + self.evm_opts = figment::Figment::from(&*config).extract::().expect("Failed to extract EvmOpts from config"); + self.env = self.evm_opts.local_evm_env(); // self.coverage = N/A; // self.debug = N/A; // self.decode_internal = N/A; @@ -320,10 +320,9 @@ impl TestRunnerConfig { /// Configures the given executor with this configuration. pub fn configure_executor(&self, executor: &mut Executor) { - // TODO: See above - + // Apply env and evm_opts to the executor let inspector = executor.inspector_mut(); - // inspector.set_env(&self.env); + inspector.set_env(&self.env); if let Some(cheatcodes) = inspector.cheatcodes.as_mut() { cheatcodes.config = Arc::new(cheatcodes.config.clone_with(&self.config, self.evm_opts.clone())); @@ -332,11 +331,11 @@ impl TestRunnerConfig { inspector.collect_coverage(self.coverage); inspector.enable_isolation(self.isolation); inspector.odyssey(self.odyssey); - // inspector.set_create2_deployer(self.evm_opts.create2_deployer); + inspector.set_create2_deployer(self.evm_opts.create2_deployer); - // executor.env_mut().clone_from(&self.env); + executor.env_mut().clone_from(&self.env); executor.set_spec_id(self.spec_id); - // executor.set_gas_limit(self.evm_opts.gas_limit()); + executor.set_gas_limit(self.evm_opts.gas_limit()); executor.set_legacy_assertions(self.config.legacy_assertions); } From ca23b716a2b2a61e937931948d51c8a92eb63c9d Mon Sep 17 00:00:00 2001 From: MozirDmitriy Date: Tue, 20 May 2025 18:07:28 +0300 Subject: [PATCH 2/2] Update Cargo.toml --- crates/forge/Cargo.toml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 48a0f26586a80..7f09db6fa78d8 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -24,7 +24,6 @@ foundry-common.workspace = true foundry-compilers = { workspace = true, features = ["full"] } foundry-config.workspace = true foundry-evm.workspace = true -foundry-evm-core.workspace = true foundry-wallets.workspace = true foundry-linking.workspace = true forge-script-sequence.workspace = true @@ -58,8 +57,6 @@ alloy-serde.workspace = true alloy-signer.workspace = true alloy-transport.workspace = true -revm.workspace = true - clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } clap_complete = "4" clap_complete_fig = "4" @@ -81,9 +78,9 @@ thiserror.workspace = true tokio = { workspace = true, features = ["time"] } toml = { workspace = true, features = ["preserve_order"] } toml_edit = "0.22" -watchexec = "8.0" -watchexec-events = "6.0" -watchexec-signals = "5.0" +watchexec = "6.0" +watchexec-events = "5.0" +watchexec-signals = "4.0" clearscreen = "4.0" evm-disassembler.workspace = true @@ -96,6 +93,8 @@ opener = "0.7" soldeer-commands.workspace = true quick-junit = "0.5.0" +figment = "0.10" + [dev-dependencies] anvil.workspace = true foundry-test-utils.workspace = true @@ -116,8 +115,6 @@ alloy-signer-local.workspace = true default = ["jemalloc"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["foundry-cli/jemalloc"] -mimalloc = ["foundry-cli/mimalloc"] -tracy-allocator = ["foundry-cli/tracy-allocator"] aws-kms = ["foundry-wallets/aws-kms"] gcp-kms = ["foundry-wallets/gcp-kms"] isolate-by-default = ["foundry-config/isolate-by-default"]