Skip to content

Commit

Permalink
enable the optimizer (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege authored Jan 29, 2024
1 parent 82294cf commit 71701dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ foundry-common = { git = "https://github.com/polytope-labs/foundry", rev = "acdf
foundry-config = { git = "https://github.com/polytope-labs/foundry", rev = "acdfeeb24263903d5ab8135d67c42c8595f54192" }
foundry-evm = { git = "https://github.com/polytope-labs/foundry", rev = "acdfeeb24263903d5ab8135d67c42c8595f54192" }
ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "594627dc1c3b490ba8f513f8f5e23d11448cbcf8", features = ["ethers-solc"] }
ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "594627dc1c3b490ba8f513f8f5e23d11448cbcf8", features = ["svm-solc"] }
once_cell = "1.19.0"
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
use ethers::{
abi::{Detokenize, Tokenize},
solc::{remappings::Remapping, Project, ProjectPathsConfig},
types::{Log, U256},
};
use ethers_solc::{remappings::Remapping, Project, ProjectPathsConfig, SolcConfig};
use forge::{
executor::{
inspector::CheatsConfig,
Expand Down Expand Up @@ -82,7 +82,15 @@ fn runner_with_root(root: PathBuf) -> MultiContractRunner {
paths.remappings.push(mapping)
});

let project = Project::builder().paths(paths).build().unwrap();
let mut config = SolcConfig::builder().build();
// enable the optimizer manually
config.settings.optimizer.enabled = Some(true);
let project = Project::builder()
.paths(paths)
.solc_config(config)
.set_auto_detect(true)
.build()
.unwrap();

let compiled = project.compile().unwrap();
if compiled.has_compiler_errors() {
Expand Down

0 comments on commit 71701dc

Please sign in to comment.