diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index 51fc69123..56a0026c0 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -71,8 +71,9 @@ def __init__( # TODO: Figure out how to make this work # t_linux_arm = Target("ubuntu-latest", "aarch64-unknown-linux-gnu", "linux-aarch64") t_macos = Target("macos-latest", "aarch64-apple-darwin", "macosx-aarch64") -t_windows = Target("windows-latest", "x86_64-pc-windows-msvc", "windows-amd64") -targets = [t_linux_x86, t_windows] if is_pr else [t_linux_x86, t_macos, t_windows] +# NOTE(zk): ZKsync-era doesn't support windows as of now +# t_windows = Target("windows-latest", "x86_64-pc-windows-msvc", "windows-amd64") +targets = [t_linux_x86] if is_pr else [t_linux_x86, t_macos] config = [ Case( diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82963e7d1..e4498aae5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,12 @@ env: TARGET_RUST_VERSION: "nightly-2024-09-01" jobs: + nextest: + uses: ./.github/workflows/nextest.yml + with: + profile: default + secrets: inherit + doctest: runs-on: ubuntu-22.04 timeout-minutes: 60 diff --git a/Cargo.lock b/Cargo.lock index 9ea6b5511..d72b9c596 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2448,6 +2448,7 @@ dependencies = [ "rayon", "regex", "rpassword", + "rustls 0.23.17", "semver 1.0.23", "serde", "serde_json", @@ -4533,6 +4534,7 @@ dependencies = [ "regex", "reqwest 0.12.9", "revm-inspectors", + "rustls 0.23.17", "semver 1.0.23", "serde", "serde_json", diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 3e9c35256..7d9b07b0f 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -36,6 +36,7 @@ foundry-config.workspace = true foundry-evm.workspace = true foundry-wallets.workspace = true foundry-zksync-core.workspace = true +rustls = { version = "0.23", features = ["ring"] } alloy-chains.workspace = true alloy-consensus = { workspace = true, features = ["serde", "kzg"] } diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 6867c8269..e332c4824 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -265,7 +265,7 @@ async fn cast_send, T: Transport + Clone>( async fn cast_send_zk, Z: ZksyncProvider, T: Transport + Clone>( provider: P, zk_provider: Z, - tx: WithOtherFields, + mut tx: WithOtherFields, zksync_params: ZksyncParams, cast_async: bool, confs: u64, @@ -280,6 +280,7 @@ async fn cast_send_zk, Z: ZksyncProvider, T: Trans paymaster_input: Bytes::from_str(&input).expect("Invalid paymaster input"), }); + tx.inner.transaction_type = Some(zksync_types::l2::TransactionType::EIP712Transaction as u8); let mut zk_tx: ZkTransactionRequest = tx.inner.clone().into(); if let Some(paymaster_params) = paymaster_params { zk_tx.set_paymaster_params(paymaster_params); diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index ffce79099..7df33496a 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -46,6 +46,11 @@ fn main() { } fn run() -> Result<()> { + // NOTE(zk): We need to manually install the crypto provider as zksync-era uses `aws-lc-rs` + // provider, while foundry uses the `ring` provider. As a result, rustls cannot disambiguate + // between the two while selecting a default provider. + let _ = rustls::crypto::ring::default_provider().install_default(); + handler::install(); utils::load_dotenv(); utils::subscriber(); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 43a2d097f..467456ec7 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1273,7 +1273,27 @@ impl Cheatcodes { constructor_args.to_vec(), ); - let factory_deps = self.dual_compiled_contracts.fetch_all_factory_deps(contract); + let mut factory_deps = self.dual_compiled_contracts.fetch_all_factory_deps(contract); + let injected_factory_deps = self + .zk_use_factory_deps + .iter() + .flat_map(|contract| { + let artifact_code = crate::fs::get_artifact_code(self, contract, false) + .inspect(|_| info!(contract, "pushing factory dep")) + .unwrap_or_else(|_| { + panic!( + "failed to get bytecode for injected factory deps contract {contract}" + ) + }) + .to_vec(); + let res = self.dual_compiled_contracts.find_bytecode(&artifact_code).unwrap(); + self.dual_compiled_contracts.fetch_all_factory_deps(res.contract()) + }) + .collect_vec(); + factory_deps.extend(injected_factory_deps); + + // NOTE(zk): Clear injected factory deps so that they are not sent on further transactions + self.zk_use_factory_deps.clear(); tracing::debug!(contract = contract.name, "using dual compiled contract"); let zk_persist_nonce_update = self.zk_persist_nonce_update.check(); @@ -1557,8 +1577,10 @@ where { let prev = account.info.nonce; let nonce = prev.saturating_sub(1); account.info.nonce = nonce; - // NOTE(zk): We sync with the nonce changes to ensure that the nonce matches - foundry_zksync_core::cheatcodes::set_nonce(sender, U256::from(nonce), &mut ecx.inner); + if self.use_zk_vm { + // NOTE(zk): We sync with the nonce changes to ensure that the nonce matches + foundry_zksync_core::cheatcodes::set_nonce(sender, U256::from(nonce), ecx); + } trace!(target: "cheatcodes", %sender, nonce, prev, "corrected nonce"); } @@ -1765,13 +1787,15 @@ where { ecx_inner.journaled_state.state().get_mut(&broadcast.new_origin).unwrap(); let zk_tx = if self.use_zk_vm { - let injected_factory_deps = self.zk_use_factory_deps.iter().map(|contract| { - crate::fs::get_artifact_code(self, contract, false) + let injected_factory_deps = self.zk_use_factory_deps.iter().flat_map(|contract| { + let artifact_code = crate::fs::get_artifact_code(self, contract, false) .inspect(|_| info!(contract, "pushing factory dep")) .unwrap_or_else(|_| { panic!("failed to get bytecode for factory deps contract {contract}") }) - .to_vec() + .to_vec(); + let res = self.dual_compiled_contracts.find_bytecode(&artifact_code).unwrap(); + self.dual_compiled_contracts.fetch_all_factory_deps(res.contract()) }).collect_vec(); factory_deps.extend(injected_factory_deps.clone()); @@ -1932,6 +1956,11 @@ where { info!("running call in zkEVM {:#?}", call); let zk_persist_nonce_update = self.zk_persist_nonce_update.check(); + + // NOTE(zk): Clear injected factory deps here even though it's actually used in broadcast. + // To be consistent with where we clear factory deps in try_create_in_zk. + self.zk_use_factory_deps.clear(); + let ccx = foundry_zksync_core::vm::CheatcodeTracerContext { mocked_calls: self.mocked_calls.clone(), expected_calls: Some(&mut self.expected_calls), diff --git a/crates/cli/src/opts/build/zksync.rs b/crates/cli/src/opts/build/zksync.rs index d6a0e1c2b..216a37da6 100644 --- a/crates/cli/src/opts/build/zksync.rs +++ b/crates/cli/src/opts/build/zksync.rs @@ -1,6 +1,6 @@ use std::{collections::HashSet, path::PathBuf}; -use alloy_primitives::{Address, Bytes}; +use alloy_primitives::{hex, Address, Bytes}; use clap::Parser; use foundry_compilers::zksolc::settings::{ZkSolcError, ZkSolcWarning}; use foundry_config::ZkSyncConfig; @@ -115,7 +115,8 @@ pub struct ZkSyncArgs { #[clap( long = "zk-paymaster-input", value_name = "PAYMASTER_INPUT", - visible_alias = "paymaster-input" + visible_alias = "paymaster-input", + value_parser = parse_hex_bytes )] pub paymaster_input: Option, @@ -185,3 +186,7 @@ impl ZkSyncArgs { zksync } } + +fn parse_hex_bytes(s: &str) -> Result { + hex::decode(s).map(Bytes::from).map_err(|e| format!("Invalid hex string: {e}")) +} diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index cd30adeb6..03a0e44a4 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -104,6 +104,7 @@ watchexec-events = "3.0" watchexec-signals = "3.0" clearscreen = "3.0" evm-disassembler.workspace = true +rustls = { version = "0.23", features = ["ring"] } # doc server axum = { workspace = true, features = ["ws"] } diff --git a/crates/forge/tests/fixtures/zk/DeployCounterWithBytecodeHash.s.sol b/crates/forge/tests/fixtures/zk/DeployCounterWithBytecodeHash.s.sol index fa2710b0c..2e11a7cb8 100644 --- a/crates/forge/tests/fixtures/zk/DeployCounterWithBytecodeHash.s.sol +++ b/crates/forge/tests/fixtures/zk/DeployCounterWithBytecodeHash.s.sol @@ -17,7 +17,7 @@ contract DeployCounterWithBytecodeHash is Script { Factory factory = new Factory(counterBytecodeHash); (bool _success,) = address(vm).call(abi.encodeWithSignature("zkUseFactoryDep(string)", "Counter")); require(_success, "Cheatcode failed"); - address counter = factory.deployAccount(salt); + address counter = factory.deployContract(salt, abi.encode()); require(counter != address(0), "Counter deployment failed"); vm.stopBroadcast(); } diff --git a/crates/forge/tests/fixtures/zk/Factory.sol b/crates/forge/tests/fixtures/zk/Factory.sol index 15f2f62e0..e981ed042 100644 --- a/crates/forge/tests/fixtures/zk/Factory.sol +++ b/crates/forge/tests/fixtures/zk/Factory.sol @@ -4,21 +4,21 @@ pragma solidity ^0.8.17; import "zksync-contracts/zksync-contracts/l2/system-contracts/Constants.sol"; import "zksync-contracts/zksync-contracts/l2/system-contracts/libraries/SystemContractsCaller.sol"; -contract Factory { +contract AAFactory { bytes32 public aaBytecodeHash; constructor(bytes32 _aaBytecodeHash) { aaBytecodeHash = _aaBytecodeHash; } - function deployAccount(bytes32 salt) external returns (address accountAddress) { + function deployAccount(bytes32 salt, bytes memory constructorArgs) external returns (address accountAddress) { (bool success, bytes memory returnData) = SystemContractsCaller.systemCallWithReturndata( uint32(gasleft()), address(DEPLOYER_SYSTEM_CONTRACT), uint128(0), abi.encodeCall( DEPLOYER_SYSTEM_CONTRACT.create2Account, - (salt, aaBytecodeHash, abi.encode(), IContractDeployer.AccountAbstractionVersion.Version1) + (salt, aaBytecodeHash, constructorArgs, IContractDeployer.AccountAbstractionVersion.Version1) ) ); require(success, "Deployment failed"); @@ -26,3 +26,25 @@ contract Factory { (accountAddress) = abi.decode(returnData, (address)); } } + +contract Factory { + bytes32 public bytecodeHash; + + constructor(bytes32 _bytecodeHash) { + bytecodeHash = _bytecodeHash; + } + + + function deployContract(bytes32 salt, bytes memory constructorArgs) external returns (address contractAddress) { + (bool success, bytes memory returnData) = SystemContractsCaller.systemCallWithReturndata( + uint32(gasleft()), + address(DEPLOYER_SYSTEM_CONTRACT), + uint128(0), + abi.encodeCall(DEPLOYER_SYSTEM_CONTRACT.create2, (salt, bytecodeHash, constructorArgs)) + ); + + require(success, "Deployment failed"); + + (contractAddress) = abi.decode(returnData, (address)); + } +} diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index de8a4c7ff..fe06d785f 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -247,6 +247,10 @@ impl ForgeTestData { pub fn new(profile: ForgeTestProfile) -> Self { init_tracing(); + // NOTE(zk): We need to manually install the crypto provider as zksync-era uses `aws-lc-rs` + // provider, while foundry uses the `ring` provider. As a result, rustls cannot + // disambiguate between the two while selecting a default provider. + let _ = rustls::crypto::ring::default_provider().install_default(); let mut project = profile.project(); let output = get_compiled(&mut project); let test_opts = profile.test_opts(&output); diff --git a/crates/forge/tests/it/zk/factory_deps.rs b/crates/forge/tests/it/zk/factory_deps.rs index ec8338e9f..43063a66c 100644 --- a/crates/forge/tests/it/zk/factory_deps.rs +++ b/crates/forge/tests/it/zk/factory_deps.rs @@ -10,7 +10,6 @@ use foundry_test_utils::{ use crate::{config::TestConfig, test_helpers::TEST_DATA_DEFAULT}; #[tokio::test(flavor = "multi_thread")] -#[ignore = "disabled since #476"] async fn test_zk_can_deploy_large_factory_deps() { let runner = TEST_DATA_DEFAULT.runner_zksync(); { @@ -19,20 +18,17 @@ async fn test_zk_can_deploy_large_factory_deps() { } } -forgetest_async!( - #[ignore = "disabled since #476"] - script_zk_can_deploy_large_factory_deps, - |prj, cmd| { - util::initialize(prj.root()); +forgetest_async!(script_zk_can_deploy_large_factory_deps, |prj, cmd| { + util::initialize(prj.root()); - prj.add_source( - "LargeContracts.sol", - include_str!("../../../../../testdata/zk/LargeContracts.sol"), - ) - .unwrap(); - prj.add_script( - "LargeContracts.s.sol", - r#" + prj.add_source( + "LargeContracts.sol", + include_str!("../../../../../testdata/zk/LargeContracts.sol"), + ) + .unwrap(); + prj.add_script( + "LargeContracts.s.sol", + r#" import "forge-std/Script.sol"; import "../src/LargeContracts.sol"; @@ -43,39 +39,42 @@ contract ZkLargeFactoryDependenciesScript is Script { } } "#, - ) - .unwrap(); + ) + .unwrap(); - let node = ZkSyncNode::start(); + let node = ZkSyncNode::start(); - cmd.arg("script").args([ - "--zk-startup", - "./script/LargeContracts.s.sol", - "--broadcast", - "--private-key", - "0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e", - "--chain", - "260", - "--gas-estimate-multiplier", - "310", - "--rpc-url", - node.url().as_str(), - "--slow", - "--evm-version", - "shanghai", - ]); - cmd.assert_success() - .get_output() - .stdout_lossy() - .contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL"); + // foundry default gas-limit is not enough to pay for factory deps in our current + // default environment + let gas_limit = u32::MAX >> 1; - let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast").as_path()) - .find(|file| file.ends_with("run-latest.json")) - .expect("No broadcast artifacts"); + cmd.arg("script").args([ + "--zk-startup", + "./script/LargeContracts.s.sol", + "--broadcast", + "--private-key", + "0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e", + "--chain", + "260", + "--gas-estimate-multiplier", + "310", + "--rpc-url", + node.url().as_str(), + "--slow", + "--gas-limit", + &gas_limit.to_string(), + ]); + cmd.assert_success() + .get_output() + .stdout_lossy() + .contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL"); - let content = foundry_common::fs::read_to_string(run_latest).unwrap(); + let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast").as_path()) + .find(|file| file.ends_with("run-latest.json")) + .expect("No broadcast artifacts"); - let json: serde_json::Value = serde_json::from_str(&content).unwrap(); - assert_eq!(json["transactions"].as_array().expect("broadcastable txs").len(), 1); - } -); + let content = foundry_common::fs::read_to_string(run_latest).unwrap(); + + let json: serde_json::Value = serde_json::from_str(&content).unwrap(); + assert_eq!(json["transactions"].as_array().expect("broadcastable txs").len(), 3); +}); diff --git a/crates/forge/tests/it/zk/paymaster.rs b/crates/forge/tests/it/zk/paymaster.rs index efe4bb6be..e761d13e6 100644 --- a/crates/forge/tests/it/zk/paymaster.rs +++ b/crates/forge/tests/it/zk/paymaster.rs @@ -3,7 +3,7 @@ use foundry_test_utils::{ forgetest_async, util::{self, OutputExt}, - TestProject, + TestProject, ZkSyncNode, }; use crate::test_helpers::run_zk_script_test; @@ -36,6 +36,95 @@ async fn test_zk_contract_paymaster() { assert!(cmd.assert_success().get_output().stdout_lossy().contains("Suite result: ok")); } +// Tests the deployment of contracts using a paymaster for fee abstraction +forgetest_async!(test_zk_deploy_with_paymaster, |prj, cmd| { + setup_deploy_prj(&mut prj); + let node = ZkSyncNode::start(); + let url = node.url(); + + let private_key = + ZkSyncNode::rich_wallets().next().map(|(_, pk, _)| pk).expect("No rich wallets available"); + + // Install required dependencies + cmd.args([ + "install", + "OpenZeppelin/openzeppelin-contracts", + "cyfrin/zksync-contracts", + "--no-commit", + "--shallow", + ]) + .assert_success(); + cmd.forge_fuse(); + + // Deploy the paymaster contract first + let paymaster_deployment = cmd + .forge_fuse() + .args([ + "create", + "./src/MyPaymaster.sol:MyPaymaster", + "--rpc-url", + url.as_str(), + "--private-key", + private_key, + "--via-ir", + "--value", + "1000000000000000000", + "--zksync", + ]) + .assert_success() + .get_output() + .stdout_lossy(); + + // Extract the deployed paymaster address + let re = regex::Regex::new(r"Deployed to: (0x[a-fA-F0-9]{40})").unwrap(); + let paymaster_address = re + .captures(&paymaster_deployment) + .and_then(|caps| caps.get(1)) + .map(|addr| addr.as_str()) + .expect("Failed to extract paymaster address"); + + // Test successful deployment with valid paymaster input + let greeter_deployment = cmd.forge_fuse() + .args([ + "create", + "./src/Greeter.sol:Greeter", + "--rpc-url", + url.as_str(), + "--private-key", + private_key, + "--zk-paymaster-address", + paymaster_address, + "--zk-paymaster-input", + "0x8c5a344500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + "--via-ir", + "--zksync" + ]) + .assert_success() + .get_output() + .stdout_lossy(); + + // Verify successful deployment + assert!(greeter_deployment.contains("Deployed to:")); + + // Test deployment failure with invalid paymaster input + cmd.forge_fuse() + .args([ + "create", + "./src/Greeter.sol:Greeter", + "--rpc-url", + url.as_str(), + "--private-key", + private_key, + "--zk-paymaster-address", + paymaster_address, + "--zk-paymaster-input", + "0x0000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + "--via-ir", + "--zksync" + ]) + .assert_failure(); +}); + forgetest_async!(paymaster_script_test, |prj, cmd| { setup_deploy_prj(&mut prj); cmd.forge_fuse(); diff --git a/crates/zksync/core/src/vm/inspect.rs b/crates/zksync/core/src/vm/inspect.rs index 8b0b9170f..b64a2e906 100644 --- a/crates/zksync/core/src/vm/inspect.rs +++ b/crates/zksync/core/src/vm/inspect.rs @@ -27,8 +27,8 @@ use zksync_multivm::{ }; use zksync_state::interface::{ReadStorage, StoragePtr, WriteStorage}; use zksync_types::{ - get_nonce_key, l2::L2Tx, PackedEthSignature, StorageKey, Transaction, - ACCOUNT_CODE_STORAGE_ADDRESS, CONTRACT_DEPLOYER_ADDRESS, NONCE_HOLDER_ADDRESS, + get_nonce_key, l2::L2Tx, transaction_request::PaymasterParams, PackedEthSignature, StorageKey, + Transaction, ACCOUNT_CODE_STORAGE_ADDRESS, CONTRACT_DEPLOYER_ADDRESS, NONCE_HOLDER_ADDRESS, }; use zksync_utils::{be_words_to_bytes, h256_to_account_address, h256_to_u256, u256_to_h256}; @@ -39,8 +39,8 @@ use std::{ }; use crate::{ - convert::{ConvertAddress, ConvertH160, ConvertH256, ConvertU256}, - is_system_address, + convert::{ConvertAddress, ConvertH160, ConvertH256, ConvertRU256, ConvertU256}, + fix_l2_gas_limit, fix_l2_gas_price, is_system_address, vm::{ db::{ZKVMData, DEFAULT_CHAIN_ID}, env::{create_l1_batch_env, create_system_env}, @@ -96,14 +96,14 @@ where let mut aggregated_result: Option = None; for (idx, mut tx) in txns.into_iter().enumerate() { - let gas_used = aggregated_result - .as_ref() - .map(|r| r.execution_result.gas_used()) - .map(U256::from) - .unwrap_or_default(); - - //deducted gas used so far - tx.common_data.fee.gas_limit -= gas_used; + // cap gas limit so that we do not set a number greater than + // remaining sender balance + let (new_gas_limit, _) = gas_params( + ecx, + tx.common_data.initiator_address.to_address(), + &tx.common_data.paymaster_params, + ); + tx.common_data.fee.gas_limit = new_gas_limit; info!("executing batched tx ({}/{})", idx + 1, total_txns); let mut result = inspect(tx, ecx, ccx, call_ctx.clone())?; @@ -394,6 +394,37 @@ where Ok(execution_result) } +/// Assign gas parameters that satisfy zkSync's fee model. +pub fn gas_params( + ecx: &mut EvmContext, + caller: Address, + paymaster_params: &PaymasterParams, +) -> (U256, U256) +where + DB: Database, + ::Error: Debug, +{ + let value = ecx.env.tx.value.to_u256(); + let use_paymaster = !paymaster_params.paymaster.is_zero(); + + // Get balance of either paymaster or caller depending on who's paying + let address = if use_paymaster { + Address::from_slice(paymaster_params.paymaster.as_bytes()) + } else { + caller + }; + let balance = ZKVMData::new(ecx).get_balance(address); + + if balance.is_zero() { + error!("balance is 0 for {}, transaction will fail", address.to_h160()); + } + + let max_fee_per_gas = fix_l2_gas_price(ecx.env.tx.gas_price.to_u256()); + + let gas_limit = fix_l2_gas_limit(ecx.env.tx.gas_limit.into(), max_fee_per_gas, value, balance); + (gas_limit, max_fee_per_gas) +} + #[allow(dead_code)] struct InnerCreateOutcome { address: H160, @@ -732,20 +763,17 @@ where /// Maximum size allowed for factory_deps during create. /// We batch factory_deps till this upper limit if there are multiple deps. /// These batches are then deployed individually. -/// -/// TODO: This feature is disabled by default via `usize::MAX` due to inconsistencies -/// with determining a value that works in all cases. static MAX_FACTORY_DEPENDENCIES_SIZE_BYTES: LazyLock = LazyLock::new(|| { std::env::var("MAX_FACTORY_DEPENDENCIES_SIZE_BYTES") .ok() .and_then(|value| value.parse::().ok()) - .unwrap_or(usize::MAX) + .unwrap_or(100_000) }); /// Batch factory deps on the basis of size. /// /// For large factory_deps the VM can run out of gas. To avoid this case we batch factory_deps -/// on the basis of [MAX_FACTORY_DEPENDENCIES_SIZE_BYTES] and deploy all but the last batch +/// on the basis of the max factory dependencies size and deploy all but the last batch /// via empty transactions, with the last one deployed normally via create. pub fn batch_factory_dependencies(mut factory_deps: Vec>) -> Vec>> { let factory_deps_count = factory_deps.len(); diff --git a/crates/zksync/core/src/vm/runner.rs b/crates/zksync/core/src/vm/runner.rs index 01af26d4d..7ce9e86aa 100644 --- a/crates/zksync/core/src/vm/runner.rs +++ b/crates/zksync/core/src/vm/runner.rs @@ -5,7 +5,7 @@ use revm::{ primitives::{Address, CreateScheme, Env, ResultAndState, TransactTo, B256, U256 as rU256}, Database, EvmContext, InnerEvmContext, }; -use tracing::{debug, error, info}; +use tracing::{debug, info}; use zksync_basic_types::H256; use zksync_types::{ ethabi, fee::Fee, l2::L2Tx, transaction_request::PaymasterParams, CONTRACT_DEPLOYER_ADDRESS, @@ -16,10 +16,9 @@ use std::{cmp::min, fmt::Debug}; use crate::{ convert::{ConvertAddress, ConvertH160, ConvertRU256, ConvertU256}, - fix_l2_gas_limit, fix_l2_gas_price, vm::{ db::ZKVMData, - inspect::{inspect, inspect_as_batch, ZKVMExecutionResult, ZKVMResult}, + inspect::{gas_params, inspect, inspect_as_batch, ZKVMExecutionResult, ZKVMResult}, tracers::cheatcode::{CallContext, CheatcodeTracerContext}, }, }; @@ -270,37 +269,6 @@ where inspect(tx, ecx, &mut ccx, call_ctx) } -/// Assign gas parameters that satisfy zkSync's fee model. -fn gas_params( - ecx: &mut EvmContext, - caller: Address, - paymaster_params: &PaymasterParams, -) -> (U256, U256) -where - DB: Database, - ::Error: Debug, -{ - let value = ecx.env.tx.value.to_u256(); - let use_paymaster = !paymaster_params.paymaster.is_zero(); - - // Get balance of either paymaster or caller depending on who's paying - let address = if use_paymaster { - Address::from_slice(paymaster_params.paymaster.as_bytes()) - } else { - caller - }; - let balance = ZKVMData::new(ecx).get_balance(address); - - if balance.is_zero() { - error!("balance is 0 for {}, transaction will fail", address.to_h160()); - } - - let max_fee_per_gas = fix_l2_gas_price(ecx.env.tx.gas_price.to_u256()); - - let gas_limit = fix_l2_gas_limit(ecx.env.tx.gas_limit.into(), max_fee_per_gas, value, balance); - (gas_limit, max_fee_per_gas) -} - /// Prepares calldata to invoke deployer contract. pub fn encode_create_params( scheme: &CreateScheme, diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 219b967eb..3d6a6260f 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -6,152 +6,23 @@ pragma solidity >=0.6.2 <0.9.0; pragma experimental ABIEncoderV2; interface Vm { - enum CallerMode { - None, - Broadcast, - RecurrentBroadcast, - Prank, - RecurrentPrank - } - enum AccountAccessKind { - Call, - DelegateCall, - CallCode, - StaticCall, - Create, - SelfDestruct, - Resume, - Balance, - Extcodesize, - Extcodehash, - Extcodecopy - } - enum ForgeContext { - TestGroup, - Test, - Coverage, - Snapshot, - ScriptGroup, - ScriptDryRun, - ScriptBroadcast, - ScriptResume, - Unknown - } - enum BroadcastTxType { - Call, - Create, - Create2 - } - - struct Log { - bytes32[] topics; - bytes data; - address emitter; - } - - struct Rpc { - string key; - string url; - } - - struct EthGetLogs { - address emitter; - bytes32[] topics; - bytes data; - bytes32 blockHash; - uint64 blockNumber; - bytes32 transactionHash; - uint64 transactionIndex; - uint256 logIndex; - bool removed; - } - - struct DirEntry { - string errorMessage; - string path; - uint64 depth; - bool isDir; - bool isSymlink; - } - - struct FsMetadata { - bool isDir; - bool isSymlink; - uint256 length; - bool readOnly; - uint256 modified; - uint256 accessed; - uint256 created; - } - - struct Wallet { - address addr; - uint256 publicKeyX; - uint256 publicKeyY; - uint256 privateKey; - } - - struct FfiResult { - int32 exitCode; - bytes stdout; - bytes stderr; - } - - struct ChainInfo { - uint256 forkId; - uint256 chainId; - } - - struct AccountAccess { - ChainInfo chainInfo; - AccountAccessKind kind; - address account; - address accessor; - bool initialized; - uint256 oldBalance; - uint256 newBalance; - bytes deployedCode; - uint256 value; - bytes data; - bool reverted; - StorageAccess[] storageAccesses; - uint64 depth; - } - - struct StorageAccess { - address account; - bytes32 slot; - bool isWrite; - bytes32 previousValue; - bytes32 newValue; - bool reverted; - } - - struct Gas { - uint64 gasLimit; - uint64 gasTotalUsed; - uint64 gasMemoryUsed; - int64 gasRefunded; - uint64 gasRemaining; - } - - struct DebugStep { - uint256[] stack; - bytes memoryInput; - uint8 opcode; - uint64 depth; - bool isOutOfGas; - address contractAddr; - } - - struct BroadcastTxSummary { - bytes32 txHash; - BroadcastTxType txType; - address contractAddress; - uint64 blockNumber; - bool success; - } - + enum CallerMode { None, Broadcast, RecurrentBroadcast, Prank, RecurrentPrank } + enum AccountAccessKind { Call, DelegateCall, CallCode, StaticCall, Create, SelfDestruct, Resume, Balance, Extcodesize, Extcodehash, Extcodecopy } + enum ForgeContext { TestGroup, Test, Coverage, Snapshot, ScriptGroup, ScriptDryRun, ScriptBroadcast, ScriptResume, Unknown } + enum BroadcastTxType { Call, Create, Create2 } + struct Log { bytes32[] topics; bytes data; address emitter; } + struct Rpc { string key; string url; } + struct EthGetLogs { address emitter; bytes32[] topics; bytes data; bytes32 blockHash; uint64 blockNumber; bytes32 transactionHash; uint64 transactionIndex; uint256 logIndex; bool removed; } + struct DirEntry { string errorMessage; string path; uint64 depth; bool isDir; bool isSymlink; } + struct FsMetadata { bool isDir; bool isSymlink; uint256 length; bool readOnly; uint256 modified; uint256 accessed; uint256 created; } + struct Wallet { address addr; uint256 publicKeyX; uint256 publicKeyY; uint256 privateKey; } + struct FfiResult { int32 exitCode; bytes stdout; bytes stderr; } + struct ChainInfo { uint256 forkId; uint256 chainId; } + struct AccountAccess { ChainInfo chainInfo; AccountAccessKind kind; address account; address accessor; bool initialized; uint256 oldBalance; uint256 newBalance; bytes deployedCode; uint256 value; bytes data; bool reverted; StorageAccess[] storageAccesses; uint64 depth; } + struct StorageAccess { address account; bytes32 slot; bool isWrite; bytes32 previousValue; bytes32 newValue; bool reverted; } + struct Gas { uint64 gasLimit; uint64 gasTotalUsed; uint64 gasMemoryUsed; int64 gasRefunded; uint64 gasRemaining; } + struct DebugStep { uint256[] stack; bytes memoryInput; uint8 opcode; uint64 depth; bool isOutOfGas; address contractAddr; } + struct BroadcastTxSummary { bytes32 txHash; BroadcastTxType txType; address contractAddress; uint64 blockNumber; bool success; } function _expectCheatcodeRevert() external; function _expectCheatcodeRevert(bytes4 revertData) external; function _expectCheatcodeRevert(bytes calldata revertData) external; @@ -160,53 +31,21 @@ interface Vm { function addr(uint256 privateKey) external pure returns (address keyAddr); function allowCheatcodes(address account) external; function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure; - function assertApproxEqAbsDecimal( - uint256 left, - uint256 right, - uint256 maxDelta, - uint256 decimals, - string calldata error - ) external pure; + function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals, string calldata error) external pure; function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure; - function assertApproxEqAbsDecimal( - int256 left, - int256 right, - uint256 maxDelta, - uint256 decimals, - string calldata error - ) external pure; + function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals, string calldata error) external pure; function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure; function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata error) external pure; function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure; function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata error) external pure; - function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals) - external - pure; - function assertApproxEqRelDecimal( - uint256 left, - uint256 right, - uint256 maxPercentDelta, - uint256 decimals, - string calldata error - ) external pure; - function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals) - external - pure; - function assertApproxEqRelDecimal( - int256 left, - int256 right, - uint256 maxPercentDelta, - uint256 decimals, - string calldata error - ) external pure; + function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals) external pure; + function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals, string calldata error) external pure; + function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals) external pure; + function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals, string calldata error) external pure; function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure; - function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata error) - external - pure; + function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata error) external pure; function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure; - function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) - external - pure; + function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) external pure; function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure; function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure; @@ -323,10 +162,7 @@ interface Vm { function cloneAccount(address source, address target) external; function closeFile(string calldata path) external; function coinbase(address newCoinbase) external; - function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) - external - pure - returns (address); + function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address); function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address); function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address); function contains(string calldata subject, string calldata search) external returns (bool result); @@ -349,22 +185,11 @@ interface Vm { function deleteStateSnapshot(uint256 snapshotId) external returns (bool success); function deleteStateSnapshots() external; function deployCode(string calldata artifactPath) external returns (address deployedAddress); - function deployCode(string calldata artifactPath, bytes calldata constructorArgs) - external - returns (address deployedAddress); + function deployCode(string calldata artifactPath, bytes calldata constructorArgs) external returns (address deployedAddress); function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey); - function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index) - external - pure - returns (uint256 privateKey); - function deriveKey(string calldata mnemonic, uint32 index, string calldata language) - external - pure - returns (uint256 privateKey); - function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language) - external - pure - returns (uint256 privateKey); + function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index) external pure returns (uint256 privateKey); + function deriveKey(string calldata mnemonic, uint32 index, string calldata language) external pure returns (uint256 privateKey); + function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language) external pure returns (uint256 privateKey); function difficulty(uint256 newDifficulty) external; function dumpState(string calldata pathToStateJson) external; function ensNamehash(string calldata name) external pure returns (bytes32); @@ -381,39 +206,18 @@ interface Vm { function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value); function envOr(string calldata name, bool defaultValue) external view returns (bool value); function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value); - function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) - external - view - returns (address[] memory value); - function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) - external - view - returns (bytes32[] memory value); - function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) - external - view - returns (string[] memory value); - function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) - external - view - returns (bytes[] memory value); + function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) external view returns (address[] memory value); + function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) external view returns (bytes32[] memory value); + function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) external view returns (string[] memory value); + function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) external view returns (bytes[] memory value); function envOr(string calldata name, int256 defaultValue) external view returns (int256 value); function envOr(string calldata name, address defaultValue) external view returns (address value); function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value); function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value); function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value); - function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) - external - view - returns (bool[] memory value); - function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) - external - view - returns (uint256[] memory value); - function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) - external - view - returns (int256[] memory value); + function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) external view returns (bool[] memory value); + function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) external view returns (uint256[] memory value); + function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) external view returns (int256[] memory value); function envString(string calldata name) external view returns (string memory value); function envString(string calldata name, string calldata delim) external view returns (string[] memory value); function envUint(string calldata name) external view returns (uint256 value); @@ -422,29 +226,19 @@ interface Vm { function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] memory topics) external returns (EthGetLogs[] memory logs); function exists(string calldata path) external view returns (bool result); function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external; - function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count) - external; + function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count) external; function expectCall(address callee, bytes calldata data) external; function expectCall(address callee, bytes calldata data, uint64 count) external; function expectCall(address callee, uint256 msgValue, bytes calldata data) external; function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external; function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external; function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external; - function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) - external; - function expectEmitAnonymous( - bool checkTopic0, - bool checkTopic1, - bool checkTopic2, - bool checkTopic3, - bool checkData, - address emitter - ) external; + function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external; + function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external; function expectEmitAnonymous() external; function expectEmitAnonymous(address emitter) external; function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external; - function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) - external; + function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external; function expectEmit() external; function expectEmit(address emitter) external; function expectPartialRevert(bytes4 revertData) external; @@ -466,25 +260,17 @@ interface Vm { function getBlobhashes() external view returns (bytes32[] memory hashes); function getBlockNumber() external view returns (uint256 height); function getBlockTimestamp() external view returns (uint256 timestamp); - function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) - external - returns (BroadcastTxSummary memory); - function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) - external - returns (BroadcastTxSummary[] memory); + function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary memory); + function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary[] memory); function getBroadcasts(string memory contractName, uint64 chainId) external returns (BroadcastTxSummary[] memory); function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode); function getDeployment(string memory contractName) external returns (address deployedAddress); function getDeployment(string memory contractName, uint64 chainId) external returns (address deployedAddress); - function getDeployments(string memory contractName, uint64 chainId) - external - returns (address[] memory deployedAddresses); + function getDeployments(string memory contractName, uint64 chainId) external returns (address[] memory deployedAddresses); function getFoundryVersion() external view returns (string memory version); function getLabel(address account) external view returns (string memory currentLabel); - function getMappingKeyAndParentOf(address target, bytes32 elementSlot) - external - returns (bool found, bytes32 key, bytes32 parent); + function getMappingKeyAndParentOf(address target, bytes32 elementSlot) external returns (bool found, bytes32 key, bytes32 parent); function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length); function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value); function getNonce(address account) external view returns (uint64 nonce); @@ -524,71 +310,41 @@ interface Vm { function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue); function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue); function parseJsonAddress(string calldata json, string calldata key) external pure returns (address); - function parseJsonAddressArray(string calldata json, string calldata key) - external - pure - returns (address[] memory); + function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory); function parseJsonBool(string calldata json, string calldata key) external pure returns (bool); function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory); function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory); function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32); - function parseJsonBytes32Array(string calldata json, string calldata key) - external - pure - returns (bytes32[] memory); + function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory); function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory); function parseJsonInt(string calldata json, string calldata key) external pure returns (int256); function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory); function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys); function parseJsonString(string calldata json, string calldata key) external pure returns (string memory); function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory); - function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription) - external - pure - returns (bytes memory); - function parseJsonType(string calldata json, string calldata typeDescription) - external - pure - returns (bytes memory); - function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) - external - pure - returns (bytes memory); + function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory); + function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory); + function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory); function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256); function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory); function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData); function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData); function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address); - function parseTomlAddressArray(string calldata toml, string calldata key) - external - pure - returns (address[] memory); + function parseTomlAddressArray(string calldata toml, string calldata key) external pure returns (address[] memory); function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool); function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory); function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory); function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32); - function parseTomlBytes32Array(string calldata toml, string calldata key) - external - pure - returns (bytes32[] memory); + function parseTomlBytes32Array(string calldata toml, string calldata key) external pure returns (bytes32[] memory); function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory); function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256); function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory); function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys); function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory); function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory); - function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription) - external - pure - returns (bytes memory); - function parseTomlType(string calldata toml, string calldata typeDescription) - external - pure - returns (bytes memory); - function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) - external - pure - returns (bytes memory); + function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory); + function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory); + function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory); function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256); function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory); function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData); @@ -622,10 +378,7 @@ interface Vm { function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin); function readDir(string calldata path) external view returns (DirEntry[] memory entries); function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries); - function readDir(string calldata path, uint64 maxDepth, bool followLinks) - external - view - returns (DirEntry[] memory entries); + function readDir(string calldata path, uint64 maxDepth, bool followLinks) external view returns (DirEntry[] memory entries); function readFile(string calldata path) external view returns (string memory data); function readFileBinary(string calldata path) external view returns (bytes memory data); function readLine(string calldata path) external view returns (string memory line); @@ -633,21 +386,11 @@ interface Vm { function record() external; function recordLogs() external; function rememberKey(uint256 privateKey) external returns (address keyAddr); - function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count) - external - returns (address[] memory keyAddrs); - function rememberKeys( - string calldata mnemonic, - string calldata derivationPath, - string calldata language, - uint32 count - ) external returns (address[] memory keyAddrs); + function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count) external returns (address[] memory keyAddrs); + function rememberKeys(string calldata mnemonic, string calldata derivationPath, string calldata language, uint32 count) external returns (address[] memory keyAddrs); function removeDir(string calldata path, bool recursive) external; function removeFile(string calldata path) external; - function replace(string calldata input, string calldata from, string calldata to) - external - pure - returns (string memory output); + function replace(string calldata input, string calldata from, string calldata to) external pure returns (string memory output); function resetGasMetering() external; function resetNonce(address account) external; function resumeGasMetering() external; @@ -667,66 +410,26 @@ interface Vm { function rpcUrlStructs() external view returns (Rpc[] memory urls); function rpcUrls() external view returns (string[2][] memory urls); function rpc(string calldata method, string calldata params) external returns (bytes memory data); - function rpc(string calldata urlOrAlias, string calldata method, string calldata params) - external - returns (bytes memory data); + function rpc(string calldata urlOrAlias, string calldata method, string calldata params) external returns (bytes memory data); function selectFork(uint256 forkId) external; - function serializeAddress(string calldata objectKey, string calldata valueKey, address value) - external - returns (string memory json); - function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values) - external - returns (string memory json); - function serializeBool(string calldata objectKey, string calldata valueKey, bool value) - external - returns (string memory json); - function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values) - external - returns (string memory json); - function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value) - external - returns (string memory json); - function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values) - external - returns (string memory json); - function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value) - external - returns (string memory json); - function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values) - external - returns (string memory json); - function serializeInt(string calldata objectKey, string calldata valueKey, int256 value) - external - returns (string memory json); - function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values) - external - returns (string memory json); + function serializeAddress(string calldata objectKey, string calldata valueKey, address value) external returns (string memory json); + function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values) external returns (string memory json); + function serializeBool(string calldata objectKey, string calldata valueKey, bool value) external returns (string memory json); + function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values) external returns (string memory json); + function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value) external returns (string memory json); + function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values) external returns (string memory json); + function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value) external returns (string memory json); + function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values) external returns (string memory json); + function serializeInt(string calldata objectKey, string calldata valueKey, int256 value) external returns (string memory json); + function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values) external returns (string memory json); function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json); - function serializeJsonType(string calldata typeDescription, bytes memory value) - external - pure - returns (string memory json); - function serializeJsonType( - string calldata objectKey, - string calldata valueKey, - string calldata typeDescription, - bytes memory value - ) external returns (string memory json); - function serializeString(string calldata objectKey, string calldata valueKey, string calldata value) - external - returns (string memory json); - function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values) - external - returns (string memory json); - function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value) - external - returns (string memory json); - function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value) - external - returns (string memory json); - function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values) - external - returns (string memory json); + function serializeJsonType(string calldata typeDescription, bytes memory value) external pure returns (string memory json); + function serializeJsonType(string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes memory value) external returns (string memory json); + function serializeString(string calldata objectKey, string calldata valueKey, string calldata value) external returns (string memory json); + function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values) external returns (string memory json); + function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value) external returns (string memory json); + function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value) external returns (string memory json); + function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values) external returns (string memory json); function setArbitraryStorage(address target) external; function setBlockhash(uint256 blockNumber, bytes32 blockHash) external; function setEnv(string calldata name, string calldata value) external; @@ -801,14 +504,7 @@ interface Vm { function writeLine(string calldata path, string calldata data) external; function writeToml(string calldata json, string calldata path) external; function writeToml(string calldata json, string calldata path, string calldata valueKey) external; - function zkRegisterContract( - string calldata name, - bytes32 evmBytecodeHash, - bytes calldata evmDeployedBytecode, - bytes calldata evmBytecode, - bytes32 zkBytecodeHash, - bytes calldata zkDeployedBytecode - ) external pure; + function zkRegisterContract(string calldata name, bytes32 evmBytecodeHash, bytes calldata evmDeployedBytecode, bytes calldata evmBytecode, bytes32 zkBytecodeHash, bytes calldata zkDeployedBytecode) external pure; function zkUseFactoryDep(string calldata name) external pure; function zkUsePaymaster(address paymaster_address, bytes calldata paymaster_input) external pure; function zkVm(bool enable) external pure;