Skip to content

Commit 3804b02

Browse files
authored
Merge pull request #1057 from matter-labs/upstream-39f524d
chore: Upstream 39f524d
2 parents 1eb5988 + af46e8a commit 3804b02

File tree

39 files changed

+670
-372
lines changed

39 files changed

+670
-372
lines changed

Cargo.lock

Lines changed: 159 additions & 259 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ foundry-compilers.opt-level = 3
102102
serde_json.opt-level = 3
103103
serde.opt-level = 3
104104

105-
solang-parser.opt-level = 3
105+
foundry-solang-parser.opt-level = 3
106106
lalrpop-util.opt-level = 3
107107

108108
solar-ast.opt-level = 3
@@ -202,7 +202,7 @@ foundry-strategy-zksync = { path = "crates/strategy/zksync" }
202202
foundry-block-explorers = { version = "0.13.3", default-features = false }
203203
foundry-compilers = { version = "0.14.0", default-features = false }
204204
foundry-fork-db = "0.12"
205-
solang-parser = "=0.3.3"
205+
solang-parser = { version = "=0.3.7", package = "foundry-solang-parser" }
206206
solar-parse = { version = "=0.1.2", default-features = false }
207207
solar-sema = { version = "=0.1.2", default-features = false }
208208
solar-ast = { version = "=0.1.2", default-features = false }

crates/anvil/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ ctrlc = { version = "3", optional = true }
9898
fdlimit = { version = "0.3", optional = true }
9999
clap_complete_fig = "4"
100100

101-
[target.'cfg(unix)'.dependencies]
102-
tikv-jemallocator = { workspace = true, optional = true }
103-
104101
[dev-dependencies]
105102
alloy-provider = { workspace = true, features = ["txpool-api"] }
106103
alloy-pubsub.workspace = true
@@ -112,7 +109,7 @@ op-alloy-rpc-types.workspace = true
112109
[features]
113110
default = ["cli", "jemalloc"]
114111
asm-keccak = ["alloy-primitives/asm-keccak"]
115-
jemalloc = ["dep:tikv-jemallocator"]
112+
jemalloc = ["foundry-cli/jemalloc"]
116113
cli = ["tokio/full", "cmd"]
117114
cmd = [
118115
"clap",

crates/anvil/bin/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
33
use anvil::args::run;
44

5-
#[cfg(all(feature = "jemalloc", unix))]
65
#[global_allocator]
7-
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
6+
static ALLOC: foundry_cli::utils::Allocator = foundry_cli::utils::new_allocator();
87

98
fn main() {
109
if let Err(err) = run() {

crates/cast/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,14 @@ tracing.workspace = true
9090
yansi.workspace = true
9191
evmole.workspace = true
9292

93-
[target.'cfg(unix)'.dependencies]
94-
tikv-jemallocator = { workspace = true, optional = true }
95-
9693
[dev-dependencies]
9794
anvil.workspace = true
9895
foundry-test-utils.workspace = true
9996

10097
[features]
10198
default = ["jemalloc"]
10299
asm-keccak = ["alloy-primitives/asm-keccak"]
103-
jemalloc = ["dep:tikv-jemallocator"]
100+
jemalloc = ["foundry-cli/jemalloc"]
104101
aws-kms = ["foundry-wallets/aws-kms", "dep:aws-sdk-kms"]
105102
gcp-kms = ["foundry-wallets/gcp-kms", "dep:gcloud-sdk"]
106103
isolate-by-default = ["foundry-config/isolate-by-default"]

crates/cast/bin/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ use foundry_cli::utils;
66
use foundry_common::{POSTHOG_API_KEY, TELEMETRY_CONFIG_NAME};
77
use zksync_telemetry::init_telemetry;
88

9-
#[cfg(all(feature = "jemalloc", unix))]
109
#[global_allocator]
11-
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
10+
static ALLOC: foundry_cli::utils::Allocator = foundry_cli::utils::new_allocator();
1211

1312
fn main() {
1413
let _ = utils::block_on(init_telemetry(

crates/cast/src/cmd/wallet/mod.rs

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,29 @@ impl WalletSubcommands {
454454
} else {
455455
wallet.sign_message(&Self::hex_str_to_bytes(&message)?).await?
456456
};
457-
sh_println!("0x{}", hex::encode(sig.as_bytes()))?;
457+
458+
if shell::verbosity() > 0 {
459+
if shell::is_json() {
460+
sh_println!(
461+
"{}",
462+
serde_json::to_string_pretty(&json!({
463+
"message": message,
464+
"address": wallet.address(),
465+
"signature": hex::encode(sig.as_bytes()),
466+
}))?
467+
)?;
468+
} else {
469+
sh_println!(
470+
"Successfully signed!\n Message: {}\n Address: {}\n Signature: 0x{}",
471+
message,
472+
wallet.address(),
473+
hex::encode(sig.as_bytes()),
474+
)?;
475+
}
476+
} else {
477+
// Pipe friendly output
478+
sh_println!("0x{}", hex::encode(sig.as_bytes()))?;
479+
}
458480
}
459481
Self::SignAuth { rpc, nonce, chain, wallet, address } => {
460482
let wallet = wallet.signer().await?;
@@ -472,7 +494,31 @@ impl WalletSubcommands {
472494
let auth = Authorization { chain_id: U256::from(chain_id), address, nonce };
473495
let signature = wallet.sign_hash(&auth.signature_hash()).await?;
474496
let auth = auth.into_signed(signature);
475-
sh_println!("{}", hex::encode_prefixed(alloy_rlp::encode(&auth)))?;
497+
498+
if shell::verbosity() > 0 {
499+
if shell::is_json() {
500+
sh_println!(
501+
"{}",
502+
serde_json::to_string_pretty(&json!({
503+
"nonce": nonce,
504+
"chain_id": chain_id,
505+
"address": wallet.address(),
506+
"signature": hex::encode_prefixed(alloy_rlp::encode(&auth)),
507+
}))?
508+
)?;
509+
} else {
510+
sh_println!(
511+
"Successfully signed!\n Nonce: {}\n Chain ID: {}\n Address: {}\n Signature: 0x{}",
512+
nonce,
513+
chain_id,
514+
wallet.address(),
515+
hex::encode_prefixed(alloy_rlp::encode(&auth)),
516+
)?;
517+
}
518+
} else {
519+
// Pipe friendly output
520+
sh_println!("{}", hex::encode_prefixed(alloy_rlp::encode(&auth)))?;
521+
}
476522
}
477523
Self::Verify { message, signature, address } => {
478524
let recovered_address = Self::recover_address_from_message(&message, &signature)?;

crates/cast/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<P: Provider<AnyNetwork>> Cast<P> {
370370
let block = self
371371
.provider
372372
.get_block(block)
373-
.full()
373+
.kind(full.into())
374374
.await?
375375
.ok_or_else(|| eyre::eyre!("block {:?} not found", block))?;
376376

crates/cast/tests/cli/zk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ casttest!(test_zk_cast_run_with_create, async |prj, cmd| {
715715
output.contains(&format!(
716716
"Traces:
717717
[91] → new <unknown>@{deployed_addr}
718-
└─ ← [Return] 224 bytes of code
718+
└─ ← [Return] 288 bytes of code
719719
"
720720
)),
721721
"trace mismatch, got output:\n{output}"

crates/cheatcodes/src/evm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ impl Cheatcode for coolCall {
577577
let Self { target } = self;
578578
if let Some(account) = ccx.ecx.journaled_state.state.get_mut(target) {
579579
account.unmark_touch();
580-
account.storage.clear();
580+
account.storage.values_mut().for_each(|slot| slot.mark_cold());
581581
}
582582
Ok(Default::default())
583583
}

crates/cheatcodes/src/inspector.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,14 +787,23 @@ impl Cheatcodes {
787787
// Apply our prank
788788
if let Some(prank) = &self.get_prank(curr_depth) {
789789
if curr_depth >= prank.depth && input.caller() == prank.prank_caller {
790+
let mut prank_applied = false;
790791
// At the target depth we set `msg.sender`
791792
if ecx_inner.journaled_state.depth() == prank.depth {
792793
input.set_caller(prank.new_caller);
794+
prank_applied = true;
793795
}
794796

795797
// At the target depth, or deeper, we set `tx.origin`
796798
if let Some(new_origin) = prank.new_origin {
797799
ecx_inner.env.tx.caller = new_origin;
800+
prank_applied = true;
801+
}
802+
// If prank applied for first time, then update
803+
if prank_applied {
804+
if let Some(applied_prank) = prank.first_time_applied() {
805+
self.pranks.insert(curr_depth, applied_prank);
806+
}
798807
}
799808
}
800809
}
@@ -1758,8 +1767,9 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes {
17581767
})
17591768
.collect::<Vec<_>>();
17601769

1761-
// Not all emits were matched.
1762-
if self.expected_emits.iter().any(|(expected, _)| !expected.found) {
1770+
// Revert if not all emits expected were matched.
1771+
if self.expected_emits.iter().any(|(expected, _)| !expected.found && expected.count > 0)
1772+
{
17631773
outcome.result.result = InstructionResult::Revert;
17641774
outcome.result.output = "log != expected log".abi_encode().into();
17651775
return outcome;

crates/chisel/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,10 @@ yansi.workspace = true
5858
tracing.workspace = true
5959
walkdir.workspace = true
6060

61-
[target.'cfg(unix)'.dependencies]
62-
tikv-jemallocator = { workspace = true, optional = true }
63-
6461
[dev-dependencies]
6562
tracing-subscriber.workspace = true
6663

6764
[features]
6865
default = ["jemalloc"]
6966
asm-keccak = ["alloy-primitives/asm-keccak"]
70-
jemalloc = ["dep:tikv-jemallocator"]
67+
jemalloc = ["foundry-cli/jemalloc"]

crates/chisel/bin/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
33
use chisel::args::run;
44

5-
#[cfg(all(feature = "jemalloc", unix))]
65
#[global_allocator]
7-
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
6+
static ALLOC: foundry_cli::utils::Allocator = foundry_cli::utils::new_allocator();
87

98
fn main() {
109
if let Err(err) = run() {

crates/cli/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ alloy-rlp.workspace = true
3333
alloy-chains.workspace = true
3434
alloy-zksync.workspace = true
3535

36+
cfg-if = "1.0"
3637
clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] }
3738
color-eyre.workspace = true
3839
dotenvy = "0.15"
@@ -60,5 +61,9 @@ foundry-zksync-compilers.workspace = true
6061
[dev-dependencies]
6162
tempfile.workspace = true
6263

64+
[target.'cfg(unix)'.dependencies]
65+
tikv-jemallocator = { workspace = true, optional = true }
66+
6367
[features]
6468
tracy = ["dep:tracing-tracy"]
69+
jemalloc = ["dep:tikv-jemallocator"]

crates/cli/src/utils/allocator.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! Abstract global allocator implementation.
2+
3+
// If jemalloc feature is enabled on Unix systems, use jemalloc as the global allocator.
4+
// Otherwise, explicitly use the system allocator.
5+
cfg_if::cfg_if! {
6+
if #[cfg(all(feature = "jemalloc", unix))] {
7+
type AllocatorInner = tikv_jemallocator::Jemalloc;
8+
} else {
9+
type AllocatorInner = std::alloc::System;
10+
}
11+
}
12+
13+
pub type Allocator = AllocatorInner;
14+
15+
/// Creates a new [allocator][Allocator].
16+
pub const fn new_allocator() -> Allocator {
17+
AllocatorInner {}
18+
}

crates/cli/src/utils/cmd.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ pub fn has_different_gas_calc(chain_id: u64) -> bool {
220220
NamedChain::Moonbeam |
221221
NamedChain::MoonbeamDev |
222222
NamedChain::Moonriver |
223-
NamedChain::Metis
223+
NamedChain::Metis |
224+
NamedChain::Abstract |
225+
NamedChain::ZkSync |
226+
NamedChain::ZkSyncTestnet
224227
);
225228
}
226229
false

crates/cli/src/utils/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ pub use suggestions::*;
2929
mod abi;
3030
pub use abi::*;
3131

32+
mod allocator;
33+
pub use allocator::*;
34+
3235
// reexport all `foundry_config::utils`
3336
#[doc(hidden)]
3437
pub use foundry_config::utils::*;

crates/common/src/contracts.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,29 @@ pub fn find_target_path(project: &Project, identifier: &PathOrContractInfo) -> R
454454
match identifier {
455455
PathOrContractInfo::Path(path) => Ok(canonicalized(project.root().join(path))),
456456
PathOrContractInfo::ContractInfo(info) => {
457+
if let Some(path) = info.path.as_ref() {
458+
let path = canonicalized(project.root().join(path));
459+
let sources = project.sources()?;
460+
let contract_path = sources
461+
.iter()
462+
.find_map(|(src_path, _)| {
463+
if **src_path == path {
464+
return Some(src_path.clone());
465+
}
466+
None
467+
})
468+
.ok_or_else(|| {
469+
eyre::eyre!(
470+
"Could not find source file for contract `{}` at {}",
471+
info.name,
472+
path.strip_prefix(project.root()).unwrap().display()
473+
)
474+
})?;
475+
return Ok(contract_path)
476+
}
477+
// If ContractInfo.path hasn't been provided we try to find the contract using the name.
478+
// This will fail if projects have multiple contracts with the same name. In that case,
479+
// path must be specified.
457480
let path = project.find_contract_path(&info.name)?;
458481
Ok(path)
459482
}

0 commit comments

Comments
 (0)