Skip to content

Commit

Permalink
Merge branch 'master' into abstract-strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec authored Jan 9, 2025
2 parents eb62afc + af9ceec commit d52a318
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 66 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions crates/cast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ where
_ => "avalanche",
}
}
"0x23a2658170ba70d014ba0d0d2709f8fbfe2fa660cd868c5f282f991eecbe38ee" => "ink",
"0xe5fd5cf0be56af58ad5751b401410d6b7a09d830fa459789746a3d0dd1c79834" => "ink-sepolia",
_ => "unknown",
})
}
Expand Down
10 changes: 5 additions & 5 deletions crates/cast/tests/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,7 @@ Nothing to compile
.stdout_eq(str![[r#"
Executing previous transactions from the block.
Traces:
[13520] → new <unknown>@0x5FbDB2315678afecb367f032d93F642f64180aa3
[..] → new <unknown>@0x5FbDB2315678afecb367f032d93F642f64180aa3
├─ emit topic 0: 0xa7263295d3a687d750d1fd377b5df47de69d7db8decc745aaa4bbee44dc1688d
│ data: 0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266
└─ ← [Return] 62 bytes of code
Expand All @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -2005,8 +2005,8 @@ contract CounterInExternalLibScript is Script {
.stdout_eq(str![[r#"
...
Traces:
[37739] → new <unknown>@0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
├─ [22411] 0xfAb06527117d29EA121998AC4fAB9Fc88bF5f979::updateCounterInExternalLib(0, 100) [delegatecall]
[..] → new <unknown>@0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
├─ [..] 0x52F3e85EC3F0f9D0a2200D646482fcD134D5adc9::updateCounterInExternalLib(0, 100) [delegatecall]
│ └─ ← [Stop]
└─ ← [Return] 62 bytes of code
Expand Down
14 changes: 7 additions & 7 deletions crates/cheatcodes/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,15 +1149,15 @@ fn get_recorded_state_diffs(state: &mut Cheatcodes) -> BTreeMap<Address, Account
account_access.oldBalance != account_access.newBalance
})
.for_each(|account_access| {
let account_diff = state_diffs.entry(account_access.account).or_insert_with(|| {
AccountStateDiffs {
label: state.labels.get(&account_access.account).cloned(),
..Default::default()
}
});

// Record account balance diffs.
if account_access.oldBalance != account_access.newBalance {
let account_diff =
state_diffs.entry(account_access.account).or_insert_with(|| {
AccountStateDiffs {
label: state.labels.get(&account_access.account).cloned(),
..Default::default()
}
});
// Update balance diff. Do not overwrite the initial balance if already set.
if let Some(diff) = &mut account_diff.balance_diff {
diff.new_value = account_access.newBalance;
Expand Down
2 changes: 1 addition & 1 deletion crates/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 1 addition & 7 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down Expand Up @@ -2304,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,
Expand Down
11 changes: 0 additions & 11 deletions crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,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;

Expand Down
3 changes: 3 additions & 0 deletions crates/forge/tests/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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()
});
Expand Down
31 changes: 27 additions & 4 deletions crates/forge/tests/cli/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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#"
...
╭----------------------------------------+-----------------+-------+--------+-------+---------╮
Expand Down Expand Up @@ -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#"
...
╭----------------------------------------+-----------------+-------+--------+-------+---------╮
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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#"
...
Expand Down Expand Up @@ -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#"
...
Expand Down Expand Up @@ -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()
});
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -2579,6 +2598,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests)

// <https://github.com/foundry-rs/foundry/issues/9115>
forgetest_init!(gas_report_with_fallback, |prj, cmd| {
prj.write_config(Config { optimizer: true, ..Default::default() });
prj.add_test(
"DelegateProxyTest.sol",
r#"
Expand Down Expand Up @@ -2722,6 +2742,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests)

// <https://github.com/foundry-rs/foundry/issues/9300>
forgetest_init!(gas_report_size_for_nested_create, |prj, cmd| {
prj.write_config(Config { optimizer: true, ..Default::default() });
prj.add_test(
"NestedDeployTest.sol",
r#"
Expand Down Expand Up @@ -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#"
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions crates/forge/tests/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions crates/forge/tests/cli/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Transaction: {
"to": null,
"maxFeePerGas": "0x77359401",
"maxPriorityFeePerGas": "0x1",
"gas": "0x17575",
"gas": "0x241e7",
"input": "[..]",
"nonce": "0x0",
"chainId": "0x7a69"
Expand Down Expand Up @@ -222,7 +222,7 @@ ABI: [
"to": null,
"maxFeePerGas": "0x77359401",
"maxPriorityFeePerGas": "0x1",
"gas": "0x17575",
"gas": "0x241e7",
"input": "[..]",
"nonce": "0x0",
"chainId": "0x7a69"
Expand Down
Loading

0 comments on commit d52a318

Please sign in to comment.