Skip to content

Commit 824e42d

Browse files
committed
Merge branch 'main' into upstream-59f354c
2 parents 7f3aadb + 5353a10 commit 824e42d

File tree

54 files changed

+3397
-1917
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3397
-1917
lines changed

Cargo.lock

Lines changed: 32 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ members = [
2323
"crates/script-sequence/",
2424
"crates/macros/",
2525
"crates/test-utils/",
26+
"crates/strategy/zksync/",
2627
]
2728
resolver = "2"
2829

@@ -173,6 +174,7 @@ foundry-linking = { path = "crates/linking" }
173174
foundry-zksync-core = { path = "crates/zksync/core" }
174175
foundry-zksync-compilers = { path = "crates/zksync/compilers" }
175176
foundry-zksync-inspectors = { path = "crates/zksync/inspectors" }
177+
foundry-strategy-zksync = { path = "crates/strategy/zksync" }
176178

177179
# solc & compilation utilities
178180
foundry-block-explorers = { version = "0.9.0", default-features = false }

crates/cast/bin/cmd/call.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ impl CallArgs {
120120
let figment = Into::<Figment>::into(&self.eth).merge(&self);
121121
let evm_opts = figment.extract::<EvmOpts>()?;
122122
let mut config = Config::try_from(figment)?.sanitized();
123+
let strategy = utils::get_executor_strategy(&config);
123124

124125
let Self {
125126
to,
@@ -195,8 +196,15 @@ impl CallArgs {
195196
InternalTraceMode::None
196197
})
197198
.with_state_changes(shell::verbosity() > 4);
198-
let mut executor =
199-
TracingExecutor::new(env, fork, evm_version, trace_mode, odyssey, create2_deployer);
199+
let mut executor = TracingExecutor::new(
200+
env,
201+
fork,
202+
evm_version,
203+
trace_mode,
204+
odyssey,
205+
create2_deployer,
206+
strategy,
207+
);
200208

201209
let value = tx.value.unwrap_or_default();
202210
let input = tx.inner.input.into_input().unwrap_or_default();

crates/cast/bin/cmd/run.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use clap::Parser;
88
use eyre::{Result, WrapErr};
99
use foundry_cli::{
1010
opts::{EtherscanOpts, RpcOpts},
11-
utils::{handle_traces, init_progress, TraceResult},
11+
utils::{self, handle_traces, init_progress, TraceResult},
1212
};
1313
use foundry_common::{is_known_system_sender, shell, SYSTEM_TRANSACTION_TYPE};
1414
use foundry_compilers::artifacts::EvmVersion;
@@ -104,6 +104,7 @@ impl RunArgs {
104104
let figment = Into::<Figment>::into(&self.rpc).merge(&self);
105105
let evm_opts = figment.extract::<EvmOpts>()?;
106106
let mut config = Config::try_from(figment)?.sanitized();
107+
let strategy = utils::get_executor_strategy(&config);
107108

108109
let compute_units_per_second =
109110
if self.no_rate_limit { Some(u64::MAX) } else { self.compute_units_per_second };
@@ -178,6 +179,7 @@ impl RunArgs {
178179
trace_mode,
179180
odyssey,
180181
create2_deployer,
182+
strategy,
181183
);
182184
let mut env =
183185
EnvWithHandlerCfg::new_with_spec_id(Box::new(env.clone()), executor.spec_id());

crates/cheatcodes/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ foundry-evm-traces.workspace = true
3232
foundry-wallets.workspace = true
3333
forge-script-sequence.workspace = true
3434
foundry-zksync-core.workspace = true
35-
foundry-zksync-compilers.workspace = true
3635
foundry-zksync-inspectors.workspace = true
3736

38-
zksync_types.workspace = true
39-
4037
alloy-dyn-abi.workspace = true
4138
alloy-json-abi.workspace = true
4239
alloy-primitives.workspace = true

crates/cheatcodes/src/config.rs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use super::Result;
2-
use crate::Vm::Rpc;
2+
use crate::{
3+
strategy::{CheatcodeInspectorStrategy, EvmCheatcodeInspectorStrategy},
4+
Vm::Rpc,
5+
};
36
use alloy_primitives::{map::AddressHashMap, U256};
47
use foundry_common::{fs::normalize_path, ContractsByArtifact};
58
use foundry_compilers::{utils::canonicalize, ProjectPathsConfig};
@@ -8,8 +11,6 @@ use foundry_config::{
811
ResolvedRpcEndpoints,
912
};
1013
use foundry_evm_core::opts::EvmOpts;
11-
use foundry_zksync_compilers::dual_compiled_contracts::DualCompiledContracts;
12-
use foundry_zksync_core::vm::ZkEnv;
1314
use semver::Version;
1415
use std::{
1516
path::{Path, PathBuf},
@@ -55,16 +56,12 @@ pub struct CheatsConfig {
5556
pub running_contract: Option<String>,
5657
/// Version of the script/test contract which is currently running.
5758
pub running_version: Option<Version>,
58-
/// ZKSolc -> Solc Contract codes
59-
pub dual_compiled_contracts: DualCompiledContracts,
60-
/// Use ZK-VM on startup
61-
pub use_zk: bool,
59+
/// The behavior strategy.
60+
pub strategy: Box<dyn CheatcodeInspectorStrategy>,
6261
/// Whether to enable legacy (non-reverting) assertions.
6362
pub assertions_revert: bool,
6463
/// Optional seed for the RNG algorithm.
6564
pub seed: Option<U256>,
66-
/// Era Vm environment
67-
pub zk_env: Option<ZkEnv>,
6865
}
6966

7067
impl CheatsConfig {
@@ -76,9 +73,7 @@ impl CheatsConfig {
7673
available_artifacts: Option<ContractsByArtifact>,
7774
running_contract: Option<String>,
7875
running_version: Option<Version>,
79-
dual_compiled_contracts: DualCompiledContracts,
80-
use_zk: bool,
81-
zk_env: Option<ZkEnv>,
76+
strategy: Box<dyn CheatcodeInspectorStrategy>,
8277
) -> Self {
8378
let mut allowed_paths = vec![config.root.clone()];
8479
allowed_paths.extend(config.libs.iter().cloned());
@@ -108,11 +103,9 @@ impl CheatsConfig {
108103
available_artifacts,
109104
running_contract,
110105
running_version,
111-
dual_compiled_contracts,
112-
use_zk,
106+
strategy,
113107
assertions_revert: config.assertions_revert,
114108
seed: config.fuzz.seed,
115-
zk_env,
116109
}
117110
}
118111

@@ -124,9 +117,7 @@ impl CheatsConfig {
124117
self.available_artifacts.clone(),
125118
self.running_contract.clone(),
126119
self.running_version.clone(),
127-
self.dual_compiled_contracts.clone(),
128-
self.use_zk,
129-
self.zk_env.clone(),
120+
self.strategy.new_cloned(),
130121
)
131122
}
132123

@@ -255,11 +246,9 @@ impl Default for CheatsConfig {
255246
available_artifacts: Default::default(),
256247
running_contract: Default::default(),
257248
running_version: Default::default(),
258-
dual_compiled_contracts: Default::default(),
259-
use_zk: false,
249+
strategy: Box::new(EvmCheatcodeInspectorStrategy::default()),
260250
assertions_revert: true,
261251
seed: None,
262-
zk_env: Default::default(),
263252
}
264253
}
265254
}
@@ -276,9 +265,7 @@ mod tests {
276265
None,
277266
None,
278267
None,
279-
Default::default(),
280-
false,
281-
None,
268+
Box::new(EvmCheatcodeInspectorStrategy::default()),
282269
)
283270
}
284271

0 commit comments

Comments
 (0)