From 9d1dfce9c20546d43223744284b42252c4f7bcbf Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Wed, 26 Feb 2025 12:24:50 +0100 Subject: [PATCH 01/12] fix(inspector): duplicated import fix(inspector): missing field in default --- crates/cheatcodes/src/inspector.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index eb76e9fba..1b748e1a8 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -10,10 +10,7 @@ use crate::{ strategy::CheatcodeInspectorStrategy, test::{ assume::AssumeNoRevert, - expect::{ - self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedCreate, - ExpectedEmitTracker, ExpectedRevert, ExpectedRevertKind, - }, + expect::{self, ExpectedCreate, ExpectedEmitTracker, ExpectedRevert, ExpectedRevertKind}, revert_handlers, }, utils::IgnoredTraces, @@ -556,6 +553,7 @@ impl Clone for Cheatcodes { mocked_functions: self.mocked_functions.clone(), expected_calls: self.expected_calls.clone(), expected_emits: self.expected_emits.clone(), + expected_creates: self.expected_creates.clone(), allowed_mem_writes: self.allowed_mem_writes.clone(), broadcast: self.broadcast.clone(), broadcastable_transactions: self.broadcastable_transactions.clone(), From 42da379f2f521025f478dfaf157f2b510719baae Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Wed, 26 Feb 2025 12:25:19 +0100 Subject: [PATCH 02/12] feat(inspect:zk): `PathOrContractInfo` arg --- crates/forge/bin/cmd/inspect.rs | 2 +- crates/forge/bin/cmd/inspect/zksync.rs | 56 ++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 987389aed..b9628f756 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -81,7 +81,7 @@ impl InspectArgs { let should_compile_with_zksolc = zksync::check_command_for_field(&field)?; if should_compile_with_zksolc { let config = Config { ..Default::default() }; - return zksync::inspect(&field, config, target_path, &contract.name); + return zksync::inspect(&field, config, target_path, contract.name()); } } diff --git a/crates/forge/bin/cmd/inspect/zksync.rs b/crates/forge/bin/cmd/inspect/zksync.rs index 2cc174f6a..fd85f45db 100644 --- a/crates/forge/bin/cmd/inspect/zksync.rs +++ b/crates/forge/bin/cmd/inspect/zksync.rs @@ -46,17 +46,57 @@ pub fn inspect( field: &ContractArtifactField, config: Config, target_path: PathBuf, - contract_name: &str, + contract_name: Option<&str>, ) -> Result<()> { let project = foundry_config::zksync::config_create_project(&config, false, true)?; let compiler = ProjectCompiler::new().quiet(true); - let artifact = compiler - .files([target_path.clone()]) - .zksync_compile(&project)? - .remove(&target_path, contract_name) - .ok_or_else(|| { - eyre::eyre!("Could not find artifact `{}` in the compiled artifacts", contract_name) - })?; + let output = compiler.files([target_path.clone()]).zksync_compile(&project)?; + + let artifact = match contract_name { + Some(name) => output.find(&target_path, name).ok_or_else(|| { + eyre::eyre!("Could not find artifact `{name}` in the compiled artifacts",) + }), + None => { + let possible_targets = output + .artifact_ids() + .filter(|(id, _artifact)| id.source == target_path) + .collect::>(); + + if possible_targets.is_empty() { + eyre::bail!("Could not find artifact linked to source `{target_path:?}` in the compiled artifacts"); + } + + let (target_id, target_artifact) = possible_targets[0].clone(); + if possible_targets.len() == 1 { + Ok(target_artifact) + } else { + // If all artifact_ids in `possible_targets` have the same name (without ".", indicates + // additional compiler profiles), it means that there are multiple contracts in the + // same file. + if !target_id.name.contains(".") + && possible_targets.iter().any(|(id, _)| id.name != target_id.name) + { + eyre::bail!("Multiple contracts found in the same file, please specify the target : or "); + } + + // Otherwise, we're dealing with additional compiler profiles wherein `id.source` is the + // same but `id.path` is different. + let artifact = possible_targets + .iter() + .find_map( + |(id, artifact)| { + if id.profile == "default" { + Some(*artifact) + } else { + None + } + }, + ) + .unwrap_or(target_artifact); + Ok(artifact) + } + } + }?; if matches!(field, ContractArtifactField::Bytecode | ContractArtifactField::DeployedBytecode) { print_json_str(&artifact.bytecode, Some("object"))?; From 15ffad944dd712b05076a8b78e6b83a14b85c878 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Wed, 26 Feb 2025 12:27:17 +0100 Subject: [PATCH 03/12] deps: remove proptest patch deps: restore upstream `alloy-chains` --- Cargo.lock | 70 +++++++++++++++++++++++++++++++++--------------------- Cargo.toml | 6 +---- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b3e060704..010bf2701 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,14 +95,14 @@ dependencies = [ [[package]] name = "alloy-chains" -version = "0.1.61" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a754dbb534198644cb8355b8c23f4aaecf03670fb9409242be1fa1e25897ee9" +checksum = "996564c1782285d4e0299c29b318bc74f24b1d7f456cef3e040810b061ee3256" dependencies = [ "alloy-primitives", "num_enum 0.7.3", "serde", - "strum 0.26.3", + "strum 0.27.1", ] [[package]] @@ -2233,7 +2233,16 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" dependencies = [ - "bit-vec", + "bit-vec 0.6.3", +] + +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec 0.8.0", ] [[package]] @@ -2245,6 +2254,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + [[package]] name = "bitflags" version = "1.3.2" @@ -2960,7 +2975,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] @@ -3948,7 +3963,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -6704,7 +6719,7 @@ checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" dependencies = [ "hermit-abi 0.4.0", "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -6775,7 +6790,7 @@ dependencies = [ "portable-atomic", "portable-atomic-util", "serde", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -7105,7 +7120,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55cb077ad656299f160924eb2912aa147d7339ea7d69e1b5517326fdcec3c1ca" dependencies = [ "ascii-canvas", - "bit-set", + "bit-set 0.5.3", "ena", "itertools 0.11.0", "lalrpop-util", @@ -7176,7 +7191,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -7873,7 +7888,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 2.0.98", @@ -8791,11 +8806,12 @@ dependencies = [ [[package]] name = "proptest" -version = "1.5.0" -source = "git+https://github.com/nbaztec/proptest?branch=v1.5.0-foundry-zksync#bb936381bf0486435a9f7f03a96d7933fb19ed17" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50" dependencies = [ - "bit-set", - "bit-vec", + "bit-set 0.8.0", + "bit-vec 0.8.0", "bitflags 2.8.0", "lazy_static", "num-traits", @@ -9100,7 +9116,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -9642,9 +9658,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.4" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5ef8fb1dd8de3870cb8400d51b4c2023854bbafd5431a3ac7e7317243e22d2f" +checksum = "825df406ec217a8116bd7b06897c6cc8f65ffefc15d030ae2c9540acc9ed50b6" dependencies = [ "alloy-rlp", "arbitrary", @@ -9738,7 +9754,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -10873,7 +10889,7 @@ dependencies = [ "solar-config", "solar-data-structures", "solar-macros", - "thiserror 2.0.11", + "thiserror 1.0.69", "tracing", "unicode-width 0.2.0", ] @@ -10998,7 +11014,7 @@ dependencies = [ "cfg-if", "libc", "psm", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -11137,7 +11153,7 @@ dependencies = [ "serde_json", "sha2 0.10.8", "tempfile", - "thiserror 2.0.11", + "thiserror 1.0.69", "url", "zip", ] @@ -11274,7 +11290,7 @@ dependencies = [ "getrandom 0.3.1", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -11931,7 +11947,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69fff37da548239c3bf9e64a12193d261e8b22b660991c6fd2df057c168f435f" dependencies = [ "cc", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -12598,7 +12614,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] @@ -13450,7 +13466,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b7c0061db44757522f2d82cad02f45dc98267210ac362071234ed08e30fd4d6" dependencies = [ "arrayvec 0.7.6", - "bit-vec", + "bit-vec 0.6.3", "blake2s_simd", "byteorder", "cfg-if", @@ -13628,7 +13644,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8986ad796f8e00d8999fee72effba1a21bce40f5f877d681ac9cd89a94834d8" dependencies = [ "anyhow", - "bit-vec", + "bit-vec 0.6.3", "once_cell", "prost 0.12.6", "prost-reflect", diff --git a/Cargo.toml b/Cargo.toml index e63d0d35c..5f6cf49d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -245,8 +245,7 @@ alloy-sol-macro-input = "0.8.18" alloy-sol-types = "0.8.18" syn-solidity = "0.8.18" -# Note(zk): We need to pin the version of alloy-chain to 0.1.61 because 0.1.62 removes VARIANTS and still need it for now -alloy-chains = "=0.1.61" +alloy-chains = "0.1" alloy-rlp = "0.3" alloy-zksync = "0.11.0" @@ -341,9 +340,6 @@ url = "2" vergen = { version = "8", default-features = false } yansi = { version = "1.0", features = ["detect-tty", "detect-env"] } -[patch.crates-io] -proptest = { git = "https://github.com/nbaztec/proptest", branch = "v1.5.0-foundry-zksync" } - ## alloy-core # alloy-dyn-abi = { path = "../../alloy-rs/core/crates/dyn-abi" } # alloy-json-abi = { path = "../../alloy-rs/core/crates/json-abi" } From 6daa93a71866d35ac0b1982e01c9b43a9473be36 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Thu, 27 Feb 2025 17:10:20 +0100 Subject: [PATCH 04/12] chore: fmt --- crates/cheatcodes/src/inspector.rs | 62 +++++++++++++------------- crates/forge/bin/cmd/inspect.rs | 34 +++++++------- crates/forge/bin/cmd/inspect/zksync.rs | 14 +++--- crates/test-utils/src/rpc.rs | 56 +++++++++++------------ 4 files changed, 83 insertions(+), 83 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 1b748e1a8..85f6a63c9 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -92,9 +92,9 @@ pub trait CheatcodesExecutor { evm.context.evm.inner.journaled_state.depth += 1; // Handle EOF bytecode - let first_frame_or_result = if evm.handler.cfg.spec_id.is_enabled_in(SpecId::OSAKA) - && inputs.scheme == CreateScheme::Create - && inputs.init_code.starts_with(&EOF_MAGIC_BYTES) + let first_frame_or_result = if evm.handler.cfg.spec_id.is_enabled_in(SpecId::OSAKA) && + inputs.scheme == CreateScheme::Create && + inputs.init_code.starts_with(&EOF_MAGIC_BYTES) { evm.handler.execution().eofcreate( &mut evm.context, @@ -730,8 +730,8 @@ impl Cheatcodes { // Apply our prank if let Some(prank) = &self.prank { - if ecx_inner.journaled_state.depth() >= prank.depth - && input.caller() == prank.prank_caller + if ecx_inner.journaled_state.depth() >= prank.depth && + input.caller() == prank.prank_caller { // At the target depth we set `msg.sender` if ecx_inner.journaled_state.depth() == prank.depth { @@ -747,8 +747,8 @@ impl Cheatcodes { // Apply our broadcast if let Some(broadcast) = &self.broadcast { - if ecx_inner.journaled_state.depth() >= broadcast.depth - && input.caller() == broadcast.original_caller + if ecx_inner.journaled_state.depth() >= broadcast.depth && + input.caller() == broadcast.original_caller { if let Err(err) = ecx_inner.journaled_state.load_account(broadcast.new_origin, &mut ecx_inner.db) @@ -851,8 +851,8 @@ where { // Handle expected reverts if let Some(expected_revert) = &self.expected_revert { - if ecx.journaled_state.depth() <= expected_revert.depth - && matches!(expected_revert.kind, ExpectedRevertKind::Default) + if ecx.journaled_state.depth() <= expected_revert.depth && + matches!(expected_revert.kind, ExpectedRevertKind::Default) { let mut expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); return match revert_handlers::handle_expect_revert( @@ -941,9 +941,9 @@ where { created_acc.info.code.clone().unwrap_or_default().original_bytes(); if let Some((index, _)) = self.expected_creates.iter().find_position(|expected_create| { - expected_create.deployer == call.caller - && expected_create.create_scheme.eq(call.scheme) - && expected_create.bytecode == bytecode + expected_create.deployer == call.caller && + expected_create.create_scheme.eq(call.scheme) && + expected_create.bytecode == bytecode }) { self.expected_creates.swap_remove(index); @@ -1071,8 +1071,8 @@ where { None => mocks .iter_mut() .find(|(mock, _)| { - call.input.get(..mock.calldata.len()) == Some(&mock.calldata[..]) - && mock.value.is_none_or(|value| Some(value) == call.transfer_value()) + call.input.get(..mock.calldata.len()) == Some(&mock.calldata[..]) && + mock.value.is_none_or(|value| Some(value) == call.transfer_value()) }) .map(|(_, v)| v), } { @@ -1144,8 +1144,8 @@ where { // // We do this because any subsequent contract calls *must* exist on chain and // we only want to grab *this* call, not internal ones - if ecx_inner.journaled_state.depth() == broadcast.depth - && call.caller == broadcast.original_caller + if ecx_inner.journaled_state.depth() == broadcast.depth && + call.caller == broadcast.original_caller { // At the target depth we set `msg.sender` & tx.origin. // We are simulating the caller as being an EOA, so *both* must be set to the @@ -1405,8 +1405,8 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { fn call_end(&mut self, ecx: Ecx, call: &CallInputs, mut outcome: CallOutcome) -> CallOutcome { let ecx = &mut ecx.inner; - let cheatcode_call = call.target_address == CHEATCODE_ADDRESS - || call.target_address == HARDHAT_CONSOLE_ADDRESS; + let cheatcode_call = call.target_address == CHEATCODE_ADDRESS || + call.target_address == HARDHAT_CONSOLE_ADDRESS; // Clean up pranks/broadcasts if it's not a cheatcode call end. We shouldn't do // it for cheatcode calls because they are not applied for cheatcodes in the `call` hook. @@ -1487,8 +1487,8 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { // Record current reverter address if expect revert is set with expected reverter // address and no actual reverter was set yet or if we're expecting more than one // revert. - if expected_revert.reverter.is_some() - && (expected_revert.reverted_by.is_none() || expected_revert.count > 1) + if expected_revert.reverter.is_some() && + (expected_revert.reverted_by.is_none() || expected_revert.count > 1) { expected_revert.reverted_by = Some(call.target_address); } @@ -1690,9 +1690,9 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { if let TxKind::Call(test_contract) = ecx.env.tx.transact_to { // if a call to a different contract than the original test contract returned with // `Stop` we check if the contract actually exists on the active fork - if ecx.db.is_forked_mode() - && outcome.result.result == InstructionResult::Stop - && call.target_address != test_contract + if ecx.db.is_forked_mode() && + outcome.result.result == InstructionResult::Stop && + call.target_address != test_contract { self.fork_revert_diagnostic = ecx.db.diagnose_revert(call.target_address, &ecx.journaled_state); @@ -1832,8 +1832,8 @@ impl InspectorExt for Cheatcodes { 1 }; - ecx.journaled_state.depth() == target_depth - && (self.broadcast.is_some() || self.config.always_use_create_2_factory) + ecx.journaled_state.depth() == target_depth && + (self.broadcast.is_some() || self.config.always_use_create_2_factory) } else { false } @@ -1897,8 +1897,8 @@ impl Cheatcodes { // Reset gas if spent is less than refunded. // This can happen if gas was paused / resumed or reset. // https://github.com/foundry-rs/foundry/issues/4370 - if interpreter.gas.spent() - < u64::try_from(interpreter.gas.refunded()).unwrap_or_default() + if interpreter.gas.spent() < + u64::try_from(interpreter.gas.refunded()).unwrap_or_default() { interpreter.gas = Gas::new(interpreter.gas.limit()); } @@ -2326,10 +2326,10 @@ pub fn check_if_fixed_gas_limit(ecx: InnerEcx, call_gas_limit: u64) -> bool { fn access_is_call(kind: crate::Vm::AccountAccessKind) -> bool { matches!( kind, - crate::Vm::AccountAccessKind::Call - | crate::Vm::AccountAccessKind::StaticCall - | crate::Vm::AccountAccessKind::CallCode - | crate::Vm::AccountAccessKind::DelegateCall + crate::Vm::AccountAccessKind::Call | + crate::Vm::AccountAccessKind::StaticCall | + crate::Vm::AccountAccessKind::CallCode | + crate::Vm::AccountAccessKind::DelegateCall ) } diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index b9628f756..3205b4e1f 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -506,23 +506,23 @@ impl PartialEq for ContractArtifactField { type Eos = EvmOutputSelection; matches!( (self, other), - (Self::Abi | Self::Events, Cos::Abi) - | (Self::Errors, Cos::Abi) - | (Self::Bytecode, Cos::Evm(Eos::ByteCode(_))) - | (Self::DeployedBytecode, Cos::Evm(Eos::DeployedByteCode(_))) - | (Self::Assembly | Self::AssemblyOptimized, Cos::Evm(Eos::Assembly)) - | (Self::LegacyAssembly, Cos::Evm(Eos::LegacyAssembly)) - | (Self::MethodIdentifiers, Cos::Evm(Eos::MethodIdentifiers)) - | (Self::GasEstimates, Cos::Evm(Eos::GasEstimates)) - | (Self::StorageLayout, Cos::StorageLayout) - | (Self::DevDoc, Cos::DevDoc) - | (Self::Ir, Cos::Ir) - | (Self::IrOptimized, Cos::IrOptimized) - | (Self::Metadata, Cos::Metadata) - | (Self::UserDoc, Cos::UserDoc) - | (Self::Ewasm, Cos::Ewasm(_)) - | (Self::Eof, Cos::Evm(Eos::DeployedByteCode(_))) - | (Self::EofInit, Cos::Evm(Eos::ByteCode(_))) + (Self::Abi | Self::Events, Cos::Abi) | + (Self::Errors, Cos::Abi) | + (Self::Bytecode, Cos::Evm(Eos::ByteCode(_))) | + (Self::DeployedBytecode, Cos::Evm(Eos::DeployedByteCode(_))) | + (Self::Assembly | Self::AssemblyOptimized, Cos::Evm(Eos::Assembly)) | + (Self::LegacyAssembly, Cos::Evm(Eos::LegacyAssembly)) | + (Self::MethodIdentifiers, Cos::Evm(Eos::MethodIdentifiers)) | + (Self::GasEstimates, Cos::Evm(Eos::GasEstimates)) | + (Self::StorageLayout, Cos::StorageLayout) | + (Self::DevDoc, Cos::DevDoc) | + (Self::Ir, Cos::Ir) | + (Self::IrOptimized, Cos::IrOptimized) | + (Self::Metadata, Cos::Metadata) | + (Self::UserDoc, Cos::UserDoc) | + (Self::Ewasm, Cos::Ewasm(_)) | + (Self::Eof, Cos::Evm(Eos::DeployedByteCode(_))) | + (Self::EofInit, Cos::Evm(Eos::ByteCode(_))) ) } } diff --git a/crates/forge/bin/cmd/inspect/zksync.rs b/crates/forge/bin/cmd/inspect/zksync.rs index fd85f45db..1d8fd4e02 100644 --- a/crates/forge/bin/cmd/inspect/zksync.rs +++ b/crates/forge/bin/cmd/inspect/zksync.rs @@ -70,17 +70,17 @@ pub fn inspect( if possible_targets.len() == 1 { Ok(target_artifact) } else { - // If all artifact_ids in `possible_targets` have the same name (without ".", indicates - // additional compiler profiles), it means that there are multiple contracts in the - // same file. - if !target_id.name.contains(".") - && possible_targets.iter().any(|(id, _)| id.name != target_id.name) + // If all artifact_ids in `possible_targets` have the same name (without ".", + // indicates additional compiler profiles), it means that there are + // multiple contracts in the same file. + if !target_id.name.contains(".") && + possible_targets.iter().any(|(id, _)| id.name != target_id.name) { eyre::bail!("Multiple contracts found in the same file, please specify the target : or "); } - // Otherwise, we're dealing with additional compiler profiles wherein `id.source` is the - // same but `id.path` is different. + // Otherwise, we're dealing with additional compiler profiles wherein `id.source` is + // the same but `id.path` is different. let artifact = possible_targets .iter() .find_map( diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 93f503ad2..3c68351f8 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -39,34 +39,34 @@ static ALCHEMY_KEYS: LazyLock> = LazyLock::new(|| { vec![Box::leak(key.into_boxed_str()) as &'static str] } else { vec![ - // "ib1f4u1ojm-9lJJypwkeZeG-75TJRB7O", - // "7mTtk6IW4DwroGnKmG_bOWri2hyaGYhX", - // "GL4M0hfzSYGU5e1_t804HoUDOObWP-FA", - // "WV407BEiBmjNJfKo9Uo_55u0z0ITyCOX", - // "Ge56dH9siMF4T0whP99sQXOcr2mFs8wZ", - "QC55XC151AgkS3FNtWvz9VZGeu9Xd9lb", - "pwc5rmJhrdoaSEfimoKEmsvOjKSmPDrP", - "A5sZ85MIr4SzCMkT0zXh2eeamGIq3vGL", - "9VWGraLx0tMiSWx05WH-ywgSVmMxs66W", - // "U4hsGWgl9lBM1j3jhSgJ4gbjHg2jRwKy", - // "K-uNlqYoYCO9cdBHcifwCDAcEjDy1UHL", - // "GWdgwabOE2XfBdLp_gIq-q6QHa7DSoag", - // "Uz0cF5HCXFtpZlvd9NR7kHxfB_Wdpsx7", - // "wWZMf1SOu9lT1GNIJHOX-5WL1MiYXycT", - // "HACxy4wNUoD-oLlCq_v5LG0bclLc_DRL", - // "_kCjfMjYo8x0rOm6YzmvSI0Qk-c8SO5I", - // "kD-M-g5TKb957S3bbOXxXPeMUxm1uTuU", - // "jQqqfTOQN_7A6gQEjzRYpVwXzxEBN9aj", - // "jGiK5vwDfC3F4r0bqukm-W2GqgdrxdSr", - // "Reoz-NZSjWczcAQOeVTz_Ejukb8mAton", - // "-DQx9U-heCeTgYsAXwaTurmGytc-0mbR", - // "sDNCLu_e99YZRkbWlVHiuM3BQ5uxYCZU", - // "M6lfpxTBrywHOvKXOS4yb7cTTpa25ZQ9", - // "UK8U_ogrbYB4lQFTGJHHDrbiS4UPnac6", - "Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", - // "UVatYU2Ax0rX6bDiqddeTRDdcCxzdpoE", - "bVjX9v-FpmUhf5R_oHIgwJx2kXvYPRbx", - ] + // "ib1f4u1ojm-9lJJypwkeZeG-75TJRB7O", + // "7mTtk6IW4DwroGnKmG_bOWri2hyaGYhX", + // "GL4M0hfzSYGU5e1_t804HoUDOObWP-FA", + // "WV407BEiBmjNJfKo9Uo_55u0z0ITyCOX", + // "Ge56dH9siMF4T0whP99sQXOcr2mFs8wZ", + "QC55XC151AgkS3FNtWvz9VZGeu9Xd9lb", + "pwc5rmJhrdoaSEfimoKEmsvOjKSmPDrP", + "A5sZ85MIr4SzCMkT0zXh2eeamGIq3vGL", + "9VWGraLx0tMiSWx05WH-ywgSVmMxs66W", + // "U4hsGWgl9lBM1j3jhSgJ4gbjHg2jRwKy", + // "K-uNlqYoYCO9cdBHcifwCDAcEjDy1UHL", + // "GWdgwabOE2XfBdLp_gIq-q6QHa7DSoag", + // "Uz0cF5HCXFtpZlvd9NR7kHxfB_Wdpsx7", + // "wWZMf1SOu9lT1GNIJHOX-5WL1MiYXycT", + // "HACxy4wNUoD-oLlCq_v5LG0bclLc_DRL", + // "_kCjfMjYo8x0rOm6YzmvSI0Qk-c8SO5I", + // "kD-M-g5TKb957S3bbOXxXPeMUxm1uTuU", + // "jQqqfTOQN_7A6gQEjzRYpVwXzxEBN9aj", + // "jGiK5vwDfC3F4r0bqukm-W2GqgdrxdSr", + // "Reoz-NZSjWczcAQOeVTz_Ejukb8mAton", + // "-DQx9U-heCeTgYsAXwaTurmGytc-0mbR", + // "sDNCLu_e99YZRkbWlVHiuM3BQ5uxYCZU", + // "M6lfpxTBrywHOvKXOS4yb7cTTpa25ZQ9", + // "UK8U_ogrbYB4lQFTGJHHDrbiS4UPnac6", + "Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", + // "UVatYU2Ax0rX6bDiqddeTRDdcCxzdpoE", + "bVjX9v-FpmUhf5R_oHIgwJx2kXvYPRbx", + ] }; keys.shuffle(&mut rand::thread_rng()); keys From aff2904c5245f6c8710508cbfd2dff927d531024 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Mon, 3 Mar 2025 14:05:13 +0100 Subject: [PATCH 05/12] fix(test:zk): `--no-commit` is now default --- crates/forge/tests/it/test_helpers.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 8ae45170e..116794193 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -572,7 +572,6 @@ pub async fn run_zk_script_test( if let Some(deps) = dependencies { let mut install_args = vec!["install"]; install_args.extend(deps.split_whitespace()); - install_args.push("--no-commit"); cmd.args(&install_args).assert_success(); } From 1b712417b7bd55b994cc4cfce2ab65144a671430 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Tue, 4 Mar 2025 21:46:44 +0100 Subject: [PATCH 06/12] feat: track upstream foundry version in metadata --- Cargo.lock | 61 +++++++++++++++++++++++++++++++--------- Cargo.toml | 4 +++ crates/common/Cargo.toml | 1 + crates/common/build.rs | 10 ++++++- 4 files changed, 61 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 010bf2701..588f68498 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2515,6 +2515,38 @@ dependencies = [ "serde", ] +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.23", + "serde", + "serde_json", + "thiserror 2.0.11", +] + [[package]] name = "cassowary" version = "0.3.0" @@ -2975,7 +3007,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -3963,7 +3995,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4725,6 +4757,7 @@ dependencies = [ "anstyle", "async-trait", "axum", + "cargo_metadata", "chrono", "clap", "comfy-table", @@ -6719,7 +6752,7 @@ checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" dependencies = [ "hermit-abi 0.4.0", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -6790,7 +6823,7 @@ dependencies = [ "portable-atomic", "portable-atomic-util", "serde", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -7191,7 +7224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -7888,7 +7921,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", "syn 2.0.98", @@ -9116,7 +9149,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -9754,7 +9787,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -10889,7 +10922,7 @@ dependencies = [ "solar-config", "solar-data-structures", "solar-macros", - "thiserror 1.0.69", + "thiserror 2.0.11", "tracing", "unicode-width 0.2.0", ] @@ -11014,7 +11047,7 @@ dependencies = [ "cfg-if", "libc", "psm", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -11153,7 +11186,7 @@ dependencies = [ "serde_json", "sha2 0.10.8", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.11", "url", "zip", ] @@ -11290,7 +11323,7 @@ dependencies = [ "getrandom 0.3.1", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -11947,7 +11980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69fff37da548239c3bf9e64a12193d261e8b22b660991c6fd2df057c168f435f" dependencies = [ "cc", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -12614,7 +12647,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5f6cf49d9..4982ad342 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,10 @@ members = [ ] resolver = "2" +[workspace.metadata] +# NOTE(zk): track upstream version after each merge +metadata.upstream_version = "1.0.0" + [workspace.package] version = "0.0.9" # x-release-please-version edition = "2021" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index e1d1dbea6..8e7501df1 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -75,6 +75,7 @@ terminal_size.workspace = true [build-dependencies] chrono.workspace = true vergen = { workspace = true, features = ["build", "git", "gitcl"] } +cargo_metadata = "0.19.2" [dev-dependencies] similar-asserts.workspace = true diff --git a/crates/common/build.rs b/crates/common/build.rs index 54890ffda..c11ed46cc 100644 --- a/crates/common/build.rs +++ b/crates/common/build.rs @@ -40,7 +40,7 @@ fn main() -> Result<(), Box> { } // Set formatted version strings - let pkg_version = env::var("CARGO_PKG_VERSION")?; + let pkg_version = upstream_version()?; // Append the profile to the version string let out_dir = env::var("OUT_DIR").unwrap(); @@ -88,3 +88,11 @@ fn main() -> Result<(), Box> { Ok(()) } + +fn upstream_version() -> Result> { + let metadata = cargo_metadata::MetadataCommand::new().exec()?; + Ok(metadata.workspace_metadata["metadata"]["upstream_version"] + .as_str() + .ok_or("Unable to retrieve upstream version from metadat")? + .to_string()) +} From f08bc09c199718ddf56c627e566d9ae068b11956 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Tue, 4 Mar 2025 22:11:47 +0100 Subject: [PATCH 07/12] fix(test:zk): remove unnecessary `--no-commit` --- crates/forge/tests/it/zk/contracts.rs | 2 +- crates/forge/tests/it/zk/paymaster.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/forge/tests/it/zk/contracts.rs b/crates/forge/tests/it/zk/contracts.rs index 1ae90b0ec..ca7ffb75e 100644 --- a/crates/forge/tests/it/zk/contracts.rs +++ b/crates/forge/tests/it/zk/contracts.rs @@ -62,7 +62,7 @@ async fn test_zk_contract_create2() { ); util::initialize(prj.root()); - cmd.args(["install", "matter-labs/era-contracts", "--no-commit", "--shallow"]).assert_success(); + cmd.args(["install", "matter-labs/era-contracts", "--shallow"]).assert_success(); cmd.forge_fuse(); let mut config = cmd.config(); diff --git a/crates/forge/tests/it/zk/paymaster.rs b/crates/forge/tests/it/zk/paymaster.rs index dc3f69782..c6054fa85 100644 --- a/crates/forge/tests/it/zk/paymaster.rs +++ b/crates/forge/tests/it/zk/paymaster.rs @@ -20,7 +20,6 @@ async fn test_zk_contract_paymaster() { "install", "OpenZeppelin/openzeppelin-contracts", "cyfrin/zksync-contracts", - "--no-commit", "--shallow", ]) .assert_success(); @@ -58,7 +57,6 @@ forgetest_async!(test_zk_deploy_with_paymaster, |prj, cmd| { "install", "OpenZeppelin/openzeppelin-contracts", "cyfrin/zksync-contracts", - "--no-commit", "--shallow", ]) .assert_success(); From 1b8884d4958660cf2e5579aaa96a1d5c8a51d511 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Tue, 4 Mar 2025 22:12:02 +0100 Subject: [PATCH 08/12] fix(test): vyper released 0.4.1 --- crates/forge/tests/cli/compiler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/cli/compiler.rs b/crates/forge/tests/cli/compiler.rs index 0b58221f2..ecc9e707f 100644 --- a/crates/forge/tests/cli/compiler.rs +++ b/crates/forge/tests/cli/compiler.rs @@ -206,7 +206,7 @@ forgetest!(can_list_resolved_multiple_compiler_versions_skipped_json, |prj, cmd| ], "Vyper": [ { - "version": "0.4.0", + "version": "0.4.1", "paths": [ "src/Counter.vy", "src/ICounter.vyi" From c8aa0c461c494370eac4eda33095f66ef99a625a Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Tue, 4 Mar 2025 22:14:06 +0100 Subject: [PATCH 09/12] chore: typo --- crates/common/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/common/build.rs b/crates/common/build.rs index c11ed46cc..5045a502f 100644 --- a/crates/common/build.rs +++ b/crates/common/build.rs @@ -93,6 +93,6 @@ fn upstream_version() -> Result> { let metadata = cargo_metadata::MetadataCommand::new().exec()?; Ok(metadata.workspace_metadata["metadata"]["upstream_version"] .as_str() - .ok_or("Unable to retrieve upstream version from metadat")? + .ok_or("Unable to retrieve upstream version from metadata")? .to_string()) } From cd08fc49c7a348d69854e60f5fbc32696b6c93fd Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 1 Mar 2025 22:05:10 +0100 Subject: [PATCH 10/12] ci: pin vyper (#9989) --- .github/workflows/nextest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nextest.yml b/.github/workflows/nextest.yml index 5cb002224..9afaa021e 100644 --- a/.github/workflows/nextest.yml +++ b/.github/workflows/nextest.yml @@ -74,7 +74,7 @@ jobs: with: python-version: 3.11 - name: Install Vyper - run: pip install vyper~=0.4.0 + run: pip install vyper==0.4.0 - name: Forge RPC cache uses: actions/cache@v3 From 3dfbe8b169d5e15059289f8bdd12dfe04882a211 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Wed, 5 Mar 2025 16:33:08 +0100 Subject: [PATCH 11/12] Revert "fix(test): vyper released 0.4.1" This reverts commit 1b8884d4958660cf2e5579aaa96a1d5c8a51d511. --- crates/forge/tests/cli/compiler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/cli/compiler.rs b/crates/forge/tests/cli/compiler.rs index ecc9e707f..0b58221f2 100644 --- a/crates/forge/tests/cli/compiler.rs +++ b/crates/forge/tests/cli/compiler.rs @@ -206,7 +206,7 @@ forgetest!(can_list_resolved_multiple_compiler_versions_skipped_json, |prj, cmd| ], "Vyper": [ { - "version": "0.4.1", + "version": "0.4.0", "paths": [ "src/Counter.vy", "src/ICounter.vyi" From 0ef6d14667ad70b218aff6dc24b35ab9526f3cfc Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Wed, 5 Mar 2025 16:36:53 +0100 Subject: [PATCH 12/12] fix(test:zk:inspect): exclude logging output --- crates/forge/tests/cli/zk_inspect.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/forge/tests/cli/zk_inspect.rs b/crates/forge/tests/cli/zk_inspect.rs index adb0ed526..231d7153a 100644 --- a/crates/forge/tests/cli/zk_inspect.rs +++ b/crates/forge/tests/cli/zk_inspect.rs @@ -42,6 +42,8 @@ contract ContractOne { .stdout_lossy(); cmd.forge_fuse(); + let out_solc_bytecode = out_solc_bytecode.lines().last().expect("inspect returns output"); + let out_zk_bytecode = cmd .arg("inspect") .arg("ContractOne") @@ -52,6 +54,8 @@ contract ContractOne { .stdout_lossy(); cmd.forge_fuse(); + let out_zk_bytecode = out_zk_bytecode.lines().last().expect("inspect returns output"); + let out_deployedbytecode = cmd .arg("inspect") .arg("ContractOne") @@ -62,6 +66,8 @@ contract ContractOne { .stdout_lossy(); cmd.forge_fuse(); + let out_deployedbytecode = out_deployedbytecode.lines().last().expect("inspect returns output"); + // The solc and zksolc bytecodes returned by inspect should be different assert_ne!(out_solc_bytecode, out_zk_bytecode);