From 49392b53f21714c49b05ee98b24b4ec6b96ebb77 Mon Sep 17 00:00:00 2001 From: Cruz Molina Date: Wed, 8 Jan 2025 10:46:25 -0800 Subject: [PATCH 1/6] Feat: Add `cast chain` support for `ink` & `ink-sepolia` (#9652) feat: add `cast chain` support for `ink` & `ink-sepolia` --- crates/cast/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 72083b1f0995..21ee2f04ec9a 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -454,6 +454,8 @@ where _ => "avalanche", } } + "0x23a2658170ba70d014ba0d0d2709f8fbfe2fa660cd868c5f282f991eecbe38ee" => "ink", + "0xe5fd5cf0be56af58ad5751b401410d6b7a09d830fa459789746a3d0dd1c79834" => "ink-sepolia", _ => "unknown", }) } From 70cd140131cd49875c6f31626bdfae08eba35386 Mon Sep 17 00:00:00 2001 From: Cruz Molina Date: Wed, 8 Jan 2025 12:10:40 -0800 Subject: [PATCH 2/6] chore(deps): bump `alloy-chains` (#9653) --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec194355f5e7..2143edba377c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.52" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f15afc5993458b42739ab3b69bdb6b4c8112acd3997dbea9bc092c9517137c" +checksum = "d38fdd69239714d7625cda1e3730773a3c1a8719d506370eb17bb0103b7c2e15" dependencies = [ "alloy-primitives", "num_enum", From 82cf61d1b2525754cb099e0ae46f3773d4557088 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:30:48 +0100 Subject: [PATCH 3/6] fix: do not remove `snapshots` directory before running the test suite (#9645) * do not remove snapshots directory before running the test suite, the side effect is that any custom group names or file name changes are not reflected - this is delegated to the end user * do not remove the `snapshots` directory upon running `forge clean` --- crates/config/src/lib.rs | 6 ------ crates/forge/bin/cmd/test/mod.rs | 11 ----------- 2 files changed, 17 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d31f2b96b007..94fe5c2bca59 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1059,12 +1059,6 @@ impl Config { remove_test_dir(&self.fuzz.failure_persist_dir); remove_test_dir(&self.invariant.failure_persist_dir); - // Remove snapshot directory. - let snapshot_dir = project.root().join(&self.snapshots); - if snapshot_dir.exists() { - let _ = fs::remove_dir_all(&snapshot_dir); - } - Ok(()) } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 43181a01d53d..a1b05a2393fd 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -301,17 +301,6 @@ impl TestArgs { // Create test options from general project settings and compiler output. let project_root = &project.paths.root; - // Remove the snapshots directory if it exists. - // This is to ensure that we don't have any stale snapshots. - // If `FORGE_SNAPSHOT_CHECK` is set, we don't remove the snapshots directory as it is - // required for comparison. - if std::env::var_os("FORGE_SNAPSHOT_CHECK").is_none() { - let snapshot_dir = project_root.join(&config.snapshots); - if snapshot_dir.exists() { - let _ = fs::remove_dir_all(project_root.join(&config.snapshots)); - } - } - let should_debug = self.debug; let should_draw = self.flamegraph || self.flamechart; From 6cbf3908e218a6a17432db380f204b9b4ed126a6 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:07:53 +0200 Subject: [PATCH 4/6] fix(cheatcodes): record state diff only if balance changed (#9658) --- crates/cheatcodes/src/evm.rs | 14 +++++++------- testdata/default/repros/Issue9643.t.sol | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index ee661dd98d39..32d8cb50d056 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -1149,15 +1149,15 @@ fn get_recorded_state_diffs(state: &mut Cheatcodes) -> BTreeMap Date: Thu, 9 Jan 2025 15:11:52 +0200 Subject: [PATCH 5/6] fix(config): disable optimizer by default (#9657) * fix: disable optimizer by default * Set default optimizer runs to 200 --- crates/cast/tests/cli/main.rs | 10 ++++----- crates/config/README.md | 2 +- crates/config/src/lib.rs | 2 +- crates/forge/tests/cli/build.rs | 3 +++ crates/forge/tests/cli/cmd.rs | 31 ++++++++++++++++++++++---- crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/create.rs | 4 ++-- crates/forge/tests/cli/script.rs | 32 ++++++++++++++------------- crates/forge/tests/cli/test_cmd.rs | 22 ++++++++++-------- crates/forge/tests/it/fuzz.rs | 3 +++ crates/forge/tests/it/inline.rs | 4 +++- crates/forge/tests/it/invariant.rs | 2 ++ crates/forge/tests/it/test_helpers.rs | 3 +++ 13 files changed, 81 insertions(+), 38 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index f037cb166c47..2e6ed7cce8bf 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1832,7 +1832,7 @@ Nothing to compile .stdout_eq(str![[r#" Executing previous transactions from the block. Traces: - [13520] → new @0x5FbDB2315678afecb367f032d93F642f64180aa3 + [..] → new @0x5FbDB2315678afecb367f032d93F642f64180aa3 ├─ emit topic 0: 0xa7263295d3a687d750d1fd377b5df47de69d7db8decc745aaa4bbee44dc1688d │ data: 0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266 └─ ← [Return] 62 bytes of code @@ -1852,7 +1852,7 @@ Executing previous transactions from the block. Compiling project to generate artifacts No files changed, compilation skipped Traces: - [13520] → new LocalProjectContract@0x5FbDB2315678afecb367f032d93F642f64180aa3 + [..] → new LocalProjectContract@0x5FbDB2315678afecb367f032d93F642f64180aa3 ├─ emit LocalProjectContractCreated(owner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266) └─ ← [Return] 62 bytes of code @@ -1914,7 +1914,7 @@ forgetest_async!(show_state_changes_in_traces, |prj, cmd| { .stdout_eq(str![[r#" Executing previous transactions from the block. Traces: - [22287] 0x5FbDB2315678afecb367f032d93F642f64180aa3::setNumber(111) + [..] 0x5FbDB2315678afecb367f032d93F642f64180aa3::setNumber(111) ├─ storage changes: │ @ 0: 0 → 111 └─ ← [Stop] @@ -2005,8 +2005,8 @@ contract CounterInExternalLibScript is Script { .stdout_eq(str![[r#" ... Traces: - [37739] → new @0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 - ├─ [22411] 0xfAb06527117d29EA121998AC4fAB9Fc88bF5f979::updateCounterInExternalLib(0, 100) [delegatecall] + [..] → new @0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 + ├─ [..] 0x52F3e85EC3F0f9D0a2200D646482fcD134D5adc9::updateCounterInExternalLib(0, 100) [delegatecall] │ └─ ← [Stop] └─ ← [Return] 62 bytes of code diff --git a/crates/config/README.md b/crates/config/README.md index 0aa2802e3952..be3055f5816f 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -86,7 +86,7 @@ gas_reports_ignore = [] # solc = '0.8.10' auto_detect_solc = true offline = false -optimizer = true +optimizer = false optimizer_runs = 200 model_checker = { contracts = { 'a.sol' = [ 'A1', diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 94fe5c2bca59..f7392118d849 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2298,7 +2298,7 @@ impl Default for Config { vyper: Default::default(), auto_detect_solc: true, offline: false, - optimizer: true, + optimizer: false, optimizer_runs: 200, optimizer_details: None, model_checker: None, diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 76dd718c6016..15d630f857ba 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -72,6 +72,7 @@ contract Dummy { }); forgetest!(initcode_size_exceeds_limit, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); cmd.args(["build", "--sizes"]).assert_failure().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -103,6 +104,7 @@ Compiler run successful! }); forgetest!(initcode_size_limit_can_be_ignored, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); cmd.args(["build", "--sizes", "--ignore-eip-3860"]).assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -149,6 +151,7 @@ Compiler run successful! // tests build output is as expected forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { prj.write_config(Config { + optimizer: true, solc: Some(foundry_config::SolcReq::Version(semver::Version::new(0, 8, 27))), ..Default::default() }); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 62b6de392a8e..4941a6ea5e61 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1573,6 +1573,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { // report for all prj.write_config(Config { + optimizer: true, gas_reports: (vec!["*".to_string()]), gas_reports_ignore: (vec![]), ..Default::default() @@ -1682,7 +1683,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) .is_json(), ); - prj.write_config(Config { gas_reports: (vec![]), ..Default::default() }); + prj.write_config(Config { optimizer: true, gas_reports: (vec![]), ..Default::default() }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1787,7 +1788,11 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) .is_json(), ); - prj.write_config(Config { gas_reports: (vec!["*".to_string()]), ..Default::default() }); + prj.write_config(Config { + optimizer: true, + gas_reports: (vec!["*".to_string()]), + ..Default::default() + }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1893,6 +1898,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) ); prj.write_config(Config { + optimizer: true, gas_reports: (vec![ "ContractOne".to_string(), "ContractTwo".to_string(), @@ -2010,7 +2016,11 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap(); // report for One - prj.write_config(Config { gas_reports: vec!["ContractOne".to_string()], ..Default::default() }); + prj.write_config(Config { + optimizer: true, + gas_reports: vec!["ContractOne".to_string()], + ..Default::default() + }); cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... @@ -2057,7 +2067,11 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) ); // report for Two - prj.write_config(Config { gas_reports: vec!["ContractTwo".to_string()], ..Default::default() }); + prj.write_config(Config { + optimizer: true, + gas_reports: vec!["ContractTwo".to_string()], + ..Default::default() + }); cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... @@ -2105,6 +2119,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // report for Three prj.write_config(Config { + optimizer: true, gas_reports: vec!["ContractThree".to_string()], ..Default::default() }); @@ -2160,6 +2175,7 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { // ignore ContractOne prj.write_config(Config { + optimizer: true, gas_reports: (vec!["*".to_string()]), gas_reports_ignore: (vec!["ContractOne".to_string()]), ..Default::default() @@ -2242,6 +2258,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // ignore ContractTwo cmd.forge_fuse(); prj.write_config(Config { + optimizer: true, gas_reports: (vec![]), gas_reports_ignore: (vec!["ContractTwo".to_string()]), ..Default::default() @@ -2328,6 +2345,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // indicating the "double listing". cmd.forge_fuse(); prj.write_config(Config { + optimizer: true, gas_reports: (vec![ "ContractOne".to_string(), "ContractTwo".to_string(), @@ -2461,6 +2479,7 @@ Warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. }); forgetest!(gas_report_flatten_multiple_selectors, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.insert_ds_test(); prj.add_source( "Counter.sol", @@ -2579,6 +2598,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // forgetest_init!(gas_report_with_fallback, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_test( "DelegateProxyTest.sol", r#" @@ -2722,6 +2742,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // forgetest_init!(gas_report_size_for_nested_create, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_test( "NestedDeployTest.sol", r#" @@ -3160,6 +3181,7 @@ Error: No source files found in specified build paths. // checks that build --sizes includes all contracts even if unchanged forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.clear_cache(); cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![[r#" @@ -3226,6 +3248,7 @@ interface Counter { // checks that `clean` also works with the "out" value set in Config forgetest_init!(gas_report_include_tests, |prj, cmd| { prj.write_config(Config { + optimizer: true, gas_reports_include_tests: true, fuzz: FuzzConfig { runs: 1, ..Default::default() }, ..Default::default() diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 61e63abf9336..e4c8e25a7ca1 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -426,6 +426,7 @@ Compiler run successful! // test to ensure yul optimizer can be set as intended forgetest!(can_set_yul_optimizer, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_source( "foo.sol", r" diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index 6a78f83231ef..fab7eb720acd 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -168,7 +168,7 @@ Transaction: { "to": null, "maxFeePerGas": "0x77359401", "maxPriorityFeePerGas": "0x1", - "gas": "0x17575", + "gas": "0x241e7", "input": "[..]", "nonce": "0x0", "chainId": "0x7a69" @@ -222,7 +222,7 @@ ABI: [ "to": null, "maxFeePerGas": "0x77359401", "maxPriorityFeePerGas": "0x1", - "gas": "0x17575", + "gas": "0x241e7", "input": "[..]", "nonce": "0x0", "chainId": "0x7a69" diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 09df55668ed0..bfd7fde8f371 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -4,6 +4,7 @@ use crate::constants::TEMPLATE_CONTRACT; use alloy_primitives::{address, hex, Address, Bytes}; use anvil::{spawn, NodeConfig}; use forge_script_sequence::ScriptSequence; +use foundry_config::Config; use foundry_test_utils::{ rpc, snapbox::IntoData, @@ -230,7 +231,7 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new GasWaster@[..] - │ └─ ← [Return] 221 bytes of code + │ └─ ← [Return] 415 bytes of code ├─ [..] GasWaster::wasteGas(200000 [2e5]) │ └─ ← [Stop] └─ ← [Stop] @@ -242,10 +243,10 @@ Script ran successfully. ========================== Simulated On-chain Traces: - [44291] → new GasWaster@[..] - └─ ← [Return] 221 bytes of code + [..] → new GasWaster@[..] + └─ ← [Return] 415 bytes of code - [224] GasWaster::wasteGas(200000 [2e5]) + [..] GasWaster::wasteGas(200000 [2e5]) └─ ← [Stop] @@ -336,7 +337,7 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new GasWaster@[..] - │ └─ ← [Return] 221 bytes of code + │ └─ ← [Return] 415 bytes of code ├─ [..] GasWaster::wasteGas(200000 [2e5]) │ └─ ← [Stop] └─ ← [Stop] @@ -348,10 +349,10 @@ Script ran successfully. ========================== Simulated On-chain Traces: - [44291] → new GasWaster@[..] - └─ ← [Return] 221 bytes of code + [..] → new GasWaster@[..] + └─ ← [Return] 415 bytes of code - [224] GasWaster::wasteGas(200000 [2e5]) + [..] GasWaster::wasteGas(200000 [2e5]) └─ ← [Stop] @@ -520,7 +521,7 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new HashChecker@[..] - │ └─ ← [Return] 368 bytes of code + │ └─ ← [Return] 718 bytes of code └─ ← [Stop] @@ -1925,6 +1926,7 @@ forgetest_async!(adheres_to_json_flag, |prj, cmd| { } foundry_test_utils::util::initialize(prj.root()); + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_script( "Foo", r#" @@ -2372,9 +2374,9 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 - │ └─ ← [Return] 116 bytes of code + │ └─ ← [Return] 175 bytes of code ├─ [..] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 - │ ├─ [145] A::getValue() [staticcall] + │ ├─ [..] A::getValue() [staticcall] │ │ └─ ← [Return] 100 │ └─ ← [Return] 62 bytes of code └─ ← [Stop] @@ -2386,11 +2388,11 @@ Script ran successfully. ========================== Simulated On-chain Traces: - [23273] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 - └─ ← [Return] 116 bytes of code + [..] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 + └─ ← [Return] 175 bytes of code - [15662] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 - ├─ [145] A::getValue() [staticcall] + [..] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 + ├─ [..] A::getValue() [staticcall] │ └─ ← [Return] 100 └─ ← [Return] 62 bytes of code ... diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 64faff26dbe0..f19eefeb92b9 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -591,6 +591,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // https://github.com/foundry-rs/foundry/issues/6579 forgetest_init!(include_custom_types_in_traces, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -958,6 +959,7 @@ contract SetupFailureTest is Test { // https://github.com/foundry-rs/foundry/issues/7530 forgetest_init!(should_show_precompile_labels, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1214,9 +1216,6 @@ forgetest_init!(internal_functions_trace, |prj, cmd| { prj.wipe_contracts(); prj.clear(); - // Disable optimizer because for simple contract most functions will get inlined. - prj.write_config(Config { optimizer: false, ..Default::default() }); - prj.add_test( "Simple", r#" @@ -1264,7 +1263,7 @@ Compiler run successful! Ran 1 test for test/Simple.sol:SimpleContractTest [PASS] test() ([GAS]) Traces: - [244864] SimpleContractTest::test() + [..] SimpleContractTest::test() ├─ [165406] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f │ └─ ← [Return] 826 bytes of code ├─ [22630] SimpleContract::increment() @@ -1292,9 +1291,6 @@ forgetest_init!(internal_functions_trace_memory, |prj, cmd| { prj.wipe_contracts(); prj.clear(); - // Disable optimizer because for simple contract most functions will get inlined. - prj.write_config(Config { optimizer: false, ..Default::default() }); - prj.add_test( "Simple", r#" @@ -1325,7 +1321,7 @@ contract SimpleContractTest is Test { cmd.args(["test", "-vvvv", "--decode-internal"]).assert_success().stdout_eq(str![[r#" ... Traces: - [406629] SimpleContractTest::test() + [..] SimpleContractTest::test() ├─ [370554] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f │ └─ ← [Return] 1737 bytes of code ├─ [2511] SimpleContract::setStr("new value") @@ -1421,6 +1417,7 @@ contract DeterministicRandomnessTest is Test { // Tests that `pauseGasMetering` used at the end of test does not produce meaningless values. // https://github.com/foundry-rs/foundry/issues/5491 forgetest_init!(gas_metering_pause_last_call, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1506,6 +1503,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // https://github.com/foundry-rs/foundry/issues/4523 forgetest_init!(gas_metering_gasleft, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1584,6 +1582,7 @@ contract ATest is Test { // tests `pauseTracing` and `resumeTracing` functions #[cfg(not(feature = "isolate-by-default"))] forgetest_init!(pause_tracing, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.wipe_contracts(); prj.insert_ds_test(); prj.insert_vm(); @@ -2332,6 +2331,7 @@ Logs: // forgetest_init!(metadata_bytecode_traces, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_source( "ParentProxy.sol", r#" @@ -2454,6 +2454,7 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test().silent()).await; + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.insert_vm(); prj.insert_ds_test(); prj.insert_console(); @@ -2702,6 +2703,8 @@ Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] // Tests that test traces display state changes when running with verbosity. #[cfg(not(feature = "isolate-by-default"))] forgetest_init!(should_show_state_changes, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); + cmd.args(["test", "--mt", "test_Increment", "-vvvvv"]).assert_success().stdout_eq(str![[r#" ... Ran 1 test for test/Counter.t.sol:CounterTest @@ -2761,6 +2764,7 @@ Encountered a total of 1 failing tests, 0 tests succeeded // Tests that `start/stopAndReturn` debugTraceRecording does not panic when running with // verbosity > 3. forgetest_init!(should_not_panic_on_debug_trace_verbose, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_test( "DebugTraceRecordingTest.t.sol", r#" @@ -2788,7 +2792,7 @@ Compiler run successful! Ran 1 test for test/DebugTraceRecordingTest.t.sol:DebugTraceRecordingTest [PASS] test_start_stop_recording() ([GAS]) Traces: - [476338] DebugTraceRecordingTest::test_start_stop_recording() + [..] DebugTraceRecordingTest::test_start_stop_recording() └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 8b49d4accad3..627232df9bc5 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -7,6 +7,7 @@ use forge::{ fuzz::CounterExample, result::{SuiteResult, TestStatus}, }; +use foundry_config::Config; use foundry_test_utils::{forgetest_init, str, Filter}; use std::collections::BTreeMap; @@ -117,6 +118,7 @@ async fn test_persist_fuzz_failure() { () => { run_fail!(|config| {}) }; (|$config:ident| $e:expr) => {{ let mut runner = TEST_DATA_DEFAULT.runner_with(|$config| { + $config.optimizer = true; $config.fuzz.runs = 1000; $e }); @@ -161,6 +163,7 @@ async fn test_persist_fuzz_failure() { } forgetest_init!(test_can_scrape_bytecode, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_source( "FuzzerDict.sol", r#" diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index eab7f9ec1bb1..0a1956c456bf 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -7,7 +7,9 @@ use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_fuzz() { let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.optimizer = true; + }); let result = runner.test_collect(&filter); let results = result .into_iter() diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index ab04ae7b5499..fc58805b4878 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -263,6 +263,7 @@ async fn test_invariant_shrink() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { config.fuzz.seed = Some(U256::from(119u32)); + config.optimizer = true; }); match get_counterexample!(runner, &filter) { @@ -795,6 +796,7 @@ contract AssumeTest is Test { // forgetest_init!(should_revert_with_assume_code, |prj, cmd| { let config = Config { + optimizer: true, invariant: { InvariantConfig { fail_on_revert: true, max_assume_rejects: 10, ..Default::default() } }, diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 3dd38a418d6a..68fb231f9da9 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -89,6 +89,9 @@ impl ForgeTestProfile { config.prompt_timeout = 0; + config.optimizer = true; + config.optimizer_runs = 200; + config.gas_limit = u64::MAX.into(); config.chain = None; config.tx_origin = CALLER; From af9ceec4a0fb21c88e42f55e5915492b6ef09cec Mon Sep 17 00:00:00 2001 From: Drake Evans <31104161+DrakeEvans@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:10:14 -0500 Subject: [PATCH 6/6] fix: incorrect repo link in readme for foundry-compilers (#9660) fix: incorrect repo link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd9325191121..3a6b24f23312 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ If you want to contribute, or follow along with contributor discussion, you can [foundry-book]: https://book.getfoundry.sh [foundry-gha]: https://github.com/foundry-rs/foundry-toolchain [ethers-solc]: https://github.com/gakonst/ethers-rs/tree/master/ethers-solc/ -[foundry-compilers]: https://github.com/foundry-rs/foundry-compilers +[foundry-compilers]: https://github.com/foundry-rs/compilers [solmate]: https://github.com/transmissions11/solmate/ [geb]: https://github.com/reflexer-labs/geb [vaults]: https://github.com/rari-capital/vaults