Skip to content

Commit

Permalink
merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec committed Jun 27, 2024
1 parent 1dace28 commit dbb26e9
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 42 deletions.
7 changes: 5 additions & 2 deletions crates/cli/src/opts/build/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,12 @@ impl<'a> From<&'a CoreBuildArgs> for Figment {
.extend(figment.extract_inner::<Vec<Remapping>>("remappings").unwrap_or_default());
// override only set values from the CLI for zksync
let zksync =
args.compiler.zk.apply_overrides(figment.extract_inner("zksync").unwrap_or_default());
args.compiler.zk.apply_overrides(figment.extract_inner("zksync").unwrap_or_default());

figment = figment.merge(("remappings", remappings.into_inner())).merge(args).merge(("zksync", zksync));
figment = figment
.merge(("remappings", remappings.into_inner()))
.merge(args)
.merge(("zksync", zksync));

if let Some(skip) = &args.skip {
let mut skip = skip.iter().map(|s| s.file_pattern().to_string()).collect::<Vec<_>>();
Expand Down
9 changes: 1 addition & 8 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ use foundry_compilers::{
multi::{MultiCompiler, MultiCompilerSettings},
solc::{Solc, SolcCompiler},
vyper::{Vyper, VyperSettings},
zksolc::{
settings::{
BytecodeHash as ZkSolcBytecodeHash, Optimizer as ZkSolcOptimizer,
OptimizerDetails as ZkSolcOptimizerDetails,
SettingsMetadata as ZkSolcSettingsMetadata,
},
ZkSolc,
},
zksolc::ZkSolc,
Compiler,
},
error::SolcError,
Expand Down
11 changes: 6 additions & 5 deletions crates/config/src/zksync.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use foundry_compilers::{
artifacts::Libraries,
zksync::artifacts::{BytecodeHash, Optimizer, OptimizerDetails, Settings, SettingsMetadata},
EvmVersion,
artifacts::{EvmVersion, Libraries},
zksolc::settings::{
BytecodeHash, Optimizer, OptimizerDetails, SettingsMetadata, ZkSolcSettings,
},
};

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -91,7 +92,7 @@ impl ZkSyncConfig {
libraries: Libraries,
evm_version: EvmVersion,
via_ir: bool,
) -> Settings {
) -> ZkSolcSettings {
let optimizer = Optimizer {
enabled: Some(self.optimizer),
mode: Some(self.optimizer_mode),
Expand All @@ -101,7 +102,7 @@ impl ZkSyncConfig {
jump_table_density_threshold: None,
};

Settings {
ZkSolcSettings {
libraries,
optimizer,
evm_version: Some(evm_version),
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/bin/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl BuildArgs {
}
}

let mut compiler = ProjectCompiler::new()
let compiler = ProjectCompiler::new()
.print_names(self.names)
.print_sizes(self.sizes)
.quiet(self.format_json)
Expand Down
8 changes: 0 additions & 8 deletions crates/forge/bin/cmd/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,6 @@ impl CoverageArgs {
.evm_spec(config.evm_spec_id())
.sender(evm_opts.sender)
.with_fork(evm_opts.get_fork(&config, env.clone()))
// XTODO
// .with_cheats_config(CheatsConfig::new(
// &config,
// evm_opts.clone(),
// None,
// Default::default(),
// false,
// ))
.with_test_options(TestOptions {
fuzz: config.fuzz.clone(),
invariant: config.invariant.clone(),
Expand Down
4 changes: 0 additions & 4 deletions crates/forge/bin/cmd/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ pub struct CreateArgs {
impl CreateArgs {
/// Executes the command to create a contract
pub async fn run(mut self) -> Result<()> {
let mut config = self.eth.try_load_config_emit_warnings()?;
let project_root = config.project_paths().root;
let zksync = self.opts.compiler.zk.enabled();

// Find Project & Compile
let project = self.opts.project()?;

Expand Down
20 changes: 9 additions & 11 deletions crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ impl TestArgs {

let output = compiler.compile(&project)?;

let zk_compiler = ProjectCompiler::new().quiet_if(self.json || self.opts.silent);
let zk_output = zk_compiler.zksync_compile(&project)?;
let zk_output = foundry_zksync_compiler::compile_project(&project)?;
let dual_compiled_contracts =
DualCompiledContracts::new(&output, &zk_output, &project.paths);

Expand Down Expand Up @@ -312,16 +311,16 @@ impl TestArgs {
.evm_spec(config.evm_spec_id())
.sender(evm_opts.sender)
.with_fork(evm_opts.get_fork(&config, env.clone()))
.with_cheats_config(CheatsConfig::new(
&config,
evm_opts.clone(),
None,
dual_compiled_contracts,
config.zksync,
))
.with_test_options(test_options.clone())
.enable_isolation(evm_opts.isolate)
.build(project_root, output, env, evm_opts, dual_compiled_contracts, config.zksync)?;
.build(
project_root,
output,
env,
evm_opts,
dual_compiled_contracts,
config.zksync.run_in_zk_mode(),
)?;

if let Some(debug_test_pattern) = &self.debug {
let test_pattern = &mut filter.args_mut().test_pattern;
Expand All @@ -333,7 +332,6 @@ impl TestArgs {
}
*test_pattern = Some(debug_test_pattern.clone());
}
runner.use_zk = config.zksync;

let libraries = runner.libraries.clone();
let outcome = self.run_tests(runner, config, verbosity, &filter).await?;
Expand Down
4 changes: 2 additions & 2 deletions crates/script/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ impl ScriptConfig {
Some(script_wallets),
Some(target.version),
dual_compiled_contracts,
self.config.zksync,
self.config.zksync.run_in_zk_mode(),
)
.into(),
)
Expand All @@ -614,7 +614,7 @@ impl ScriptConfig {
}

let mut executor = builder.build(env, db);
executor.use_zk = self.config.zksync;
executor.use_zk = self.config.zksync.run_in_zk_mode();
Ok(ScriptRunner::new(executor, self.evm_opts.clone()))
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/script/src/simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl PreSimulationState {
to,
tx.input.clone().into_input(),
tx.value,
(self.script_config.config.zksync, zk.clone()),
(self.script_config.config.zksync.run_in_zk_mode(), zk.clone()),
)
.wrap_err("Internal EVM error during simulation")?;

Expand Down

0 comments on commit dbb26e9

Please sign in to comment.