Skip to content

feat(forge): optimize compilation through preprocessing and caching #10010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
009e9a8
feat(forge): optimize compilation through preprocessing and caching
grandizzy Mar 4, 2025
b99643c
Add various test scenarios
grandizzy Mar 5, 2025
ae93985
Changes after review: rename cache_tests, add build option
grandizzy Mar 5, 2025
5a95025
Merge branch 'master' into issue-9863
grandizzy Mar 14, 2025
5c22e1c
Update solar and compilers revs
grandizzy Mar 14, 2025
9326bb0
Merge branch 'master' into issue-9863
grandizzy Mar 24, 2025
9cdccb4
Update refs, add test with constructor args without name
grandizzy Mar 25, 2025
a53489e
Merge branch 'master' into issue-9863
grandizzy Mar 25, 2025
2e834fa
Bump compilers rev
grandizzy Mar 25, 2025
fb614a8
Merge branch 'master' into issue-9863
grandizzy Mar 25, 2025
fb112dd
add test for named args, bump solar and compilers
grandizzy Mar 25, 2025
03aa006
feat(forge): add vm.deployCode cheats with msg.value and salt
grandizzy Mar 25, 2025
056f998
Merge branch 'master' into issue-9863
grandizzy Mar 26, 2025
4c69396
Bump compilers, ctor test with value and salt, ignore win panic
grandizzy Mar 26, 2025
863435e
Bump compilers with fix for win panic
grandizzy Mar 27, 2025
3c23f1f
Merge branch 'master' into issue-9863
grandizzy Mar 28, 2025
619f10a
Bump compilers
grandizzy Mar 28, 2025
abc2301
Merge branch 'master' into issue-9863
grandizzy Mar 28, 2025
3f85768
Update crates/common/src/compile.rs
grandizzy Mar 31, 2025
df1b3b6
Merge branch 'master' into issue-9863
DaniPopes Mar 31, 2025
797133d
bump
DaniPopes Apr 2, 2025
bd2b8ca
bump solar
DaniPopes Apr 3, 2025
3f73080
bump solar 2
DaniPopes Apr 3, 2025
c3dd142
bump compilers
DaniPopes Apr 3, 2025
0cc772c
ename config dynamic_test_linking, bump compilers
grandizzy Apr 3, 2025
b1fc2a5
Dynamic test linking default enabled
grandizzy Apr 3, 2025
ab58a04
More test fixes
grandizzy Apr 3, 2025
d7ab9a1
chore: move preprocessor from compilers
DaniPopes Apr 3, 2025
26d5354
bump
DaniPopes Apr 3, 2025
503cc44
Ensure no cached artifacts in projects
grandizzy Apr 3, 2025
e005150
Disable by default
grandizzy Apr 3, 2025
6182d31
Merge branch 'master' into issue-9863
grandizzy Apr 4, 2025
e3d2677
Handle constructor expectRevert
grandizzy Apr 4, 2025
836d315
Collect deps from call args too
grandizzy Apr 6, 2025
d6eeb84
Merge branch 'master' into issue-9863
grandizzy Apr 7, 2025
1592db4
Bump solar, use upstream fix for call args deps
grandizzy Apr 7, 2025
0a75a65
Merge branch 'master' into issue-9863
grandizzy Apr 7, 2025
093ef49
Bump solar, compilers and block explorers
grandizzy Apr 7, 2025
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
101 changes: 74 additions & 27 deletions Cargo.lock

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

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ foundry-wallets = { path = "crates/wallets" }
foundry-linking = { path = "crates/linking" }

# solc & compilation utilities
foundry-block-explorers = { version = "0.11.0", default-features = false }
foundry-compilers = { version = "0.13.5", default-features = false }
foundry-block-explorers = { version = "0.13.0", default-features = false }
foundry-compilers = { version = "0.14.0", default-features = false }
foundry-fork-db = "0.12"
solang-parser = "=0.3.3"
solar-parse = { version = "=0.1.1", default-features = false }
solar-parse = { version = "=0.1.2", default-features = false }
solar-sema = { version = "=0.1.2", default-features = false }

## revm
revm = { version = "19.4.0", default-features = false }
Expand Down Expand Up @@ -309,6 +310,7 @@ tracing-subscriber = "0.3"
url = "2"
vergen = { version = "8", default-features = false }
yansi = { version = "1.0", features = ["detect-tty", "detect-env"] }
path-slash = "0.2"

[patch.crates-io]
## alloy-core
Expand Down
29 changes: 16 additions & 13 deletions crates/cheatcodes/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,22 @@ fn deploy_code(
revm::primitives::CreateScheme::Create
};

let address = executor
.exec_create(
CreateInputs {
caller: ccx.caller,
scheme,
value: value.unwrap_or(U256::ZERO),
init_code: bytecode.into(),
gas_limit: ccx.gas_limit,
},
ccx,
)?
.address
.ok_or_else(|| fmt_err!("contract creation failed"))?;
let outcome = executor.exec_create(
CreateInputs {
caller: ccx.caller,
scheme,
value: value.unwrap_or(U256::ZERO),
init_code: bytecode.into(),
gas_limit: ccx.gas_limit,
},
ccx,
)?;

if !outcome.result.result.is_ok() {
return Err(crate::Error::from(outcome.result.output))
}

let address = outcome.address.ok_or_else(|| fmt_err!("contract creation failed"))?;

Ok(address.abi_encode())
}
Expand Down
9 changes: 9 additions & 0 deletions crates/cli/src/opts/build/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ pub struct BuildOpts {
#[serde(skip)]
pub no_cache: bool,

/// Enable dynamic test linking.
#[arg(long, conflicts_with = "no_cache")]
#[serde(skip)]
pub dynamic_test_linking: bool,

/// Set pre-linked libraries.
#[arg(long, help_heading = "Linker options", env = "DAPP_LIBRARIES")]
#[serde(skip_serializing_if = "Vec::is_empty")]
Expand Down Expand Up @@ -245,6 +250,10 @@ impl Provider for BuildOpts {
dict.insert("cache".to_string(), false.into());
}

if self.dynamic_test_linking {
dict.insert("dynamic_test_linking".to_string(), true.into());
}

if self.build_info {
dict.insert("build_info".to_string(), self.build_info.into());
}
Expand Down
4 changes: 4 additions & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ alloy-transport.workspace = true
alloy-consensus = { workspace = true, features = ["k256"] }
alloy-network.workspace = true

solar-parse.workspace = true
solar-sema.workspace = true

tower.workspace = true

async-trait.workspace = true
Expand All @@ -64,6 +67,7 @@ tracing.workspace = true
url.workspace = true
walkdir.workspace = true
yansi.workspace = true
path-slash.workspace = true

anstream.workspace = true
anstyle.workspace = true
Expand Down
Loading
Loading